From 4103c23327359a0bd6385c2f891554f206fec397 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Mon, 9 Oct 2023 10:48:38 +1100 Subject: strchrnul is a GNU libc extension, add a wrapper for other platforms --- XUtils.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'XUtils.h') 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) -- cgit v1.2.3