diff options
author | Nathan Scott <nathans@redhat.com> | 2023-10-09 10:48:38 +1100 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2023-10-10 09:18:47 +1100 |
commit | 4103c23327359a0bd6385c2f891554f206fec397 (patch) | |
tree | 30eec810c157643b63713af1776d9bfb1de141c6 /XUtils.h | |
parent | 2978af01a79d1627d7fa90fda0efec9cf774d901 (diff) |
strchrnul is a GNU libc extension, add a wrapper for other platforms
Diffstat (limited to 'XUtils.h')
-rw-r--r-- | XUtils.h | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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) |