? string.patch Index: strcasecmp.c =================================================================== RCS file: /cvs/src/src/newlib/libc/string/strcasecmp.c,v retrieving revision 1.2 diff -u -p -r1.2 strcasecmp.c --- strcasecmp.c 28 Oct 2005 21:33:23 -0000 1.2 +++ strcasecmp.c 6 Apr 2009 21:14:00 -0000 @@ -22,7 +22,7 @@ DESCRIPTION RETURNS If <<*<[a]>>> sorts lexicographically after <<*<[b]>>> (after - both are converted to uppercase), <> returns a + both are converted to lowercase), <> returns a number greater than zero. If the two strings match, <> returns zero. If <<*<[a]>>> sorts lexicographically before <<*<[b]>>>, <> returns a @@ -35,7 +35,7 @@ PORTABILITY tolower() from elsewhere in this library. QUICKREF - strcasecmp + strcasecmp */ #include @@ -46,11 +46,15 @@ _DEFUN (strcasecmp, (s1, s2), _CONST char *s1 _AND _CONST char *s2) { - while (*s1 != '\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 ( ; ; ) { - 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; } Index: strlwr.c =================================================================== RCS file: /cvs/src/src/newlib/libc/string/strlwr.c,v retrieving revision 1.2 diff -u -p -r1.2 strlwr.c --- strlwr.c 28 Oct 2005 21:33:23 -0000 1.2 +++ strlwr.c 6 Apr 2009 21:14:00 -0000 @@ -33,18 +33,14 @@ QUICKREF #include #include -char * -strlwr (a) - char *a; -{ - char *ret = a; - - while (*a != '\0') - { - if (isupper (*a)) - *a = tolower (*a); - ++a; - } - - return ret; +char * +_DEFUN (strlwr, (s), + char *s) +{ + unsigned char *ucs = (unsigned char *) s; + for ( ; *ucs != '\0'; ucs++) + { + *ucs = tolower(*ucs); + } + return s; } Index: strncasecmp.c =================================================================== RCS file: /cvs/src/src/newlib/libc/string/strncasecmp.c,v retrieving revision 1.3 diff -u -p -r1.3 strncasecmp.c --- strncasecmp.c 6 Apr 2009 22:42:08 -0000 1.3 +++ strncasecmp.c 6 Apr 2009 21:14:00 -0000 @@ -24,7 +24,7 @@ DESCRIPTION RETURNS If <<*<[a]>>> sorts lexicographically after <<*<[b]>>> (after - both are converted to uppercase), <> returns a + both are converted to lowercase), <> returns a number greater than zero. If the two strings are equivalent, <> returns zero. If <<*<[a]>>> sorts lexicographically before <<*<[b]>>>, <> returns a Index: strupr.c =================================================================== RCS file: /cvs/src/src/newlib/libc/string/strupr.c,v retrieving revision 1.2 diff -u -p -r1.2 strupr.c --- strupr.c 28 Oct 2005 21:33:23 -0000 1.2 +++ strupr.c 6 Apr 2009 21:14:00 -0000 @@ -27,23 +27,20 @@ PORTABILITY <> requires no supporting OS subroutines. QUICKREF - strupr */ + strupr +*/ #include #include -char * -strupr (a) - char *a; -{ - char *ret = a; - - while (*a != '\0') - { - if (islower (*a)) - *a = toupper (*a); - ++a; - } - - return ret; +char * +_DEFUN (strupr, (s), + char *s) +{ + unsigned char *ucs = (unsigned char *) s; + for ( ; *ucs != '\0'; ucs++) + { + *ucs = toupper(*ucs); + } + return s; }