Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2009-04-07 02:42:08 +0400
committerJeff Johnston <jjohnstn@redhat.com>2009-04-07 02:42:08 +0400
commit3d66f2c9ae95425175d52f27ddfea36f52b5b740 (patch)
tree7d50054b878d0ceec3521381ea03f16521a84465 /newlib/libc/string
parent43b1cfeca529918cb01fc07309c9bae7c1ad3630 (diff)
2009-04-06 Mike Burgess <wizardsguild@earthlink.net>
* libc/string/strncasecmp.c: Optimized rewrite.
Diffstat (limited to 'newlib/libc/string')
-rw-r--r--newlib/libc/string/strncasecmp.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/newlib/libc/string/strncasecmp.c b/newlib/libc/string/strncasecmp.c
index c877ba53c..c2eb5b86c 100644
--- a/newlib/libc/string/strncasecmp.c
+++ b/newlib/libc/string/strncasecmp.c
@@ -49,16 +49,15 @@ _DEFUN (strncasecmp, (s1, s2, n),
_CONST char *s2 _AND
size_t n)
{
- if (n == 0)
- return 0;
-
- while (n-- != 0 && tolower(*s1) == tolower(*s2))
+ _CONST unsigned char *ucs1 = (_CONST unsigned char *) s1;
+ _CONST unsigned char *ucs2 = (_CONST unsigned char *) s2;
+ int d = 0;
+ for ( ; n != 0; n--)
{
- if (n == 0 || *s1 == '\0' || *s2 == '\0')
- break;
- s1++;
- s2++;
+ _CONST int c1 = tolower(*ucs1++);
+ _CONST int c2 = tolower(*ucs2++);
+ if (((d = c1 - c2) != 0) || (c2 == '\0'))
+ break;
}
-
- return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
+ return d;
}