Use strlen when searching for a nul char

Message ID AM3PR08MB0088E8648CC7845B7C9DAFB783680@AM3PR08MB0088.eurprd08.prod.outlook.com
State Not applicable
Headers

Commit Message

Wilco Dijkstra April 15, 2016, 12:36 p.m. UTC
  ping
  

Patch

diff --git a/string/bits/string2.h b/string/bits/string2.h
index bebd158c5ff0f7bd7d9e4a4c3e120cd45b6e2143..f34fedb170352eaca0ed784ca6e76d7bbbfaefc2 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -62,14 +62,15 @@ 
 #endif


-#ifndef _HAVE_STRING_ARCH_strchr
+#ifndef _HAVE_STRING_ARCH_rawmemchr
 extern void *__rawmemchr (const void *__s, int __c);
-# if __GNUC_PREREQ (3, 2)
-#  define strchr(s, c) \
-  (__extension__ (__builtin_constant_p (c) && !__builtin_constant_p (s)              \
-                 && (c) == '\0'                                              \
-                 ? (char *) __rawmemchr (s, c)                               \
-                 : __builtin_strchr (s, c)))
+# define __rawmemchr(s, c) \
+    (__extension__ ({ char *__s = (char *)(s);         \
+      __builtin_constant_p (c) && (c) == '\0'          \
+      ? (void *)(__s + strlen (__s))                   \
+      : __rawmemchr (__s, (c));}))
+# ifdef __USE_GNU
+#  define rawmemchr(s,c) __rawmemchr ((s), (c))
 # endif
 #endif