summary refs log tree commit diff
path: root/string
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-02-16 21:21:52 +0000
committerUlrich Drepper <drepper@redhat.com>1999-02-16 21:21:52 +0000
commitd30da2a80056799a51b8e04eb75f8b081d00cf56 (patch)
tree7f076fb9ac75410dcedf09c6742c7a21357284cb /string
parent6686d05a252164441b71bdb9864c07c1cb5a992b (diff)
downloadglibc-d30da2a80056799a51b8e04eb75f8b081d00cf56.tar.gz
glibc-d30da2a80056799a51b8e04eb75f8b081d00cf56.tar.xz
glibc-d30da2a80056799a51b8e04eb75f8b081d00cf56.zip
Only use strncmp optimization if count argument is constant.
Diffstat (limited to 'string')
-rw-r--r--string/bits/string2.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/string/bits/string2.h b/string/bits/string2.h
index 0c28b3e122..3de175d0a8 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -687,12 +687,13 @@ __stpcpy_small (char *__dest,
 
 /* Compare N characters of S1 and S2.  */
 #ifndef _HAVE_STRING_ARCH_strncmp
-# define strncmp(s1, s2, n) \
-  (__extension__ (__builtin_constant_p (s1) && strlen (s1) < ((size_t) (n))   \
-		  ? strcmp (s1, s2)					      \
-		  : (__builtin_constant_p (s2) && strlen (s2) < ((size_t) (n))\
-		     ? strcmp (s1, s2)					      \
-		     : strncmp (s1, s2, n))))
+# define strncmp(s1, s2, n)						      \
+  (__extension__ (__builtin_constant_p (n)				      \
+		  && ((__builtin_constant_p (s1)			      \
+		       && strlen (s1) < ((size_t) (n)))			      \
+		      || (__builtin_constant_p (s2)			      \
+			  && strlen (s2) < ((size_t) (n))))		      \
+		  ? strcmp (s1, s2) : strncmp (s1, s2, n)))
 #endif