summaryrefslogtreecommitdiffstats
path: root/XUtils.h
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2023-10-09 10:48:38 +1100
committerNathan Scott <nathans@redhat.com>2023-10-10 09:18:47 +1100
commit4103c23327359a0bd6385c2f891554f206fec397 (patch)
tree30eec810c157643b63713af1776d9bfb1de141c6 /XUtils.h
parent2978af01a79d1627d7fa90fda0efec9cf774d901 (diff)
strchrnul is a GNU libc extension, add a wrapper for other platforms
Diffstat (limited to 'XUtils.h')
-rw-r--r--XUtils.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/XUtils.h b/XUtils.h
index fd1087d5..7526df3e 100644
--- a/XUtils.h
+++ b/XUtils.h
@@ -56,6 +56,17 @@ void String_freeArray(char** s);
char* String_readLine(FILE* fd) ATTR_MALLOC;
+static inline char* String_strchrnul(const char* s, int c) {
+#ifdef HAVE_STRCHRNUL
+ return strchrnul(s, c);
+#else
+ char* result = strchr(s, c);
+ if (result)
+ return result;
+ return strchr(s, '\0');
+#endif
+}
+
/* Always null-terminates dest. Caller must pass a strictly positive size. */
ATTR_ACCESS3_W(1, 3)
ATTR_ACCESS3_R(2, 3)

© 2014-2024 Faster IT GmbH | imprint | privacy policy