about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-12-06 05:11:32 +0000
committerUlrich Drepper <drepper@redhat.com>2001-12-06 05:11:32 +0000
commitf5e6e2ee301eaf4ba89399a30418e777c0d0f9d7 (patch)
tree051050960143ec194f7b26c5e02a45d933750c38
parentc7b4c95cd167d4e0b8c4fccac98233217283df45 (diff)
downloadglibc-f5e6e2ee301eaf4ba89399a30418e777c0d0f9d7.tar.gz
glibc-f5e6e2ee301eaf4ba89399a30418e777c0d0f9d7.tar.xz
glibc-f5e6e2ee301eaf4ba89399a30418e777c0d0f9d7.zip
Update.
	* sysdeps/generic/strncase.c: Likewise.
-rw-r--r--ChangeLog1
-rw-r--r--sysdeps/generic/strncase.c16
2 files changed, 7 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index dc6083c73d..0bf76aab4d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
 	* sysdeps/generic/strcasecmp.c (__strcasecmp): Little performance
 	patch.
+	* sysdeps/generic/strncase.c: Likewise.
 
 2001-12-05  Geoff Keating  <geoffk@redhat.com>
 
diff --git a/sysdeps/generic/strncase.c b/sysdeps/generic/strncase.c
index 429fb1af6b..4251dc1ce4 100644
--- a/sysdeps/generic/strncase.c
+++ b/sysdeps/generic/strncase.c
@@ -1,6 +1,6 @@
 /* Compare at most N characters of two strings without taking care for
    the case.
-   Copyright (C) 1992, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1996, 1997, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -58,20 +58,16 @@ __strncasecmp (s1, s2, n LOCALE_PARAM)
 {
   const unsigned char *p1 = (const unsigned char *) s1;
   const unsigned char *p2 = (const unsigned char *) s2;
-  unsigned char c1, c2;
+  int result;
 
   if (p1 == p2 || n == 0)
     return 0;
 
-  do
-    {
-      c1 = TOLOWER (*p1++);
-      c2 = TOLOWER (*p2++);
-      if (c1 == '\0' || c1 != c2)
-	return c1 - c2;
-    } while (--n > 0);
+  while ((result = TOLOWER (*p1) - TOLOWER (*p2++)) == 0)
+    if (*p1++ == '\0' || --n == 0)
+      break;
 
-  return c1 - c2;
+  return result;
 }
 #ifndef __strncasecmp
 weak_alias (__strncasecmp, strncasecmp)