summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2011-11-25 14:37:07 +0100
committerFrancisco Jerez <[email protected]>2012-05-11 12:39:42 +0200
commit0a62af3bcc530a6d09130368055c64263ba48848 (patch)
tree97979be67cda6744e4bd2e0456688db1855d39e6 /src
parent57c048f291ffcb97d7df3177d92f9634e510dcc0 (diff)
gallium/util: Define util_strchrnul.
Reviewed-by: Jakob Bornecrantz <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/util/u_string.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/util/u_string.h b/src/gallium/auxiliary/util/u_string.h
index cc7992d7391..ed15981f1a5 100644
--- a/src/gallium/auxiliary/util/u_string.h
+++ b/src/gallium/auxiliary/util/u_string.h
@@ -48,6 +48,21 @@
extern "C" {
#endif
+#ifdef _GNU_SOURCE
+
+#define util_strchrnul strchrnul
+
+#else
+
+static INLINE char *
+util_strchrnul(const char *s, char c)
+{
+ for (; *s && *s != c; ++s);
+
+ return (char *)s;
+}
+
+#endif
#ifdef WIN32
@@ -72,12 +87,9 @@ util_sprintf(char *str, const char *format, ...)
static INLINE char *
util_strchr(const char *s, char c)
{
- while(*s) {
- if(*s == c)
- return (char *)s;
- ++s;
- }
- return NULL;
+ char *p = util_strchrnul(s, c);
+
+ return *p ? p : NULL;
}
static INLINE char*