2009-04-06 Mike Burgess <wizardsguild@earthlink.net>

* libc/string/strncasecmp.c: Optimized rewrite.
This commit is contained in:
Jeff Johnston 2009-04-06 22:42:08 +00:00
parent 43b1cfeca5
commit 3d66f2c9ae
2 changed files with 13 additions and 10 deletions

View File

@ -1,3 +1,7 @@
2009-04-06 Mike Burgess <wizardsguild@earthlink.net>
* libc/string/strncasecmp.c: Optimized rewrite.
2009-04-06 Ken Werner <ken.werner@de.ibm.com> 2009-04-06 Ken Werner <ken.werner@de.ibm.com>
* libc/include/sys/features.h: Undefine _POSIX_TIMERS for spu. * libc/include/sys/features.h: Undefine _POSIX_TIMERS for spu.

View File

@ -49,16 +49,15 @@ _DEFUN (strncasecmp, (s1, s2, n),
_CONST char *s2 _AND _CONST char *s2 _AND
size_t n) size_t n)
{ {
if (n == 0) _CONST unsigned char *ucs1 = (_CONST unsigned char *) s1;
return 0; _CONST unsigned char *ucs2 = (_CONST unsigned char *) s2;
int d = 0;
while (n-- != 0 && tolower(*s1) == tolower(*s2)) for ( ; n != 0; n--)
{ {
if (n == 0 || *s1 == '\0' || *s2 == '\0') _CONST int c1 = tolower(*ucs1++);
break; _CONST int c2 = tolower(*ucs2++);
s1++; if (((d = c1 - c2) != 0) || (c2 == '\0'))
s2++; break;
} }
return d;
return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
} }