diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-02-12 20:28:12 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-02-12 20:28:12 +0000 |
commit | ce4b0fa7e84539992a0cccb618c4fc9d9cfabc50 (patch) | |
tree | be09bc4851bc285f96bdb32abad8d98b79ebdc9c /libc/string/strcasecmp.c | |
parent | f3aece684ded006182453378e8037b2b2cd290b8 (diff) |
Mark Robson noticed that our strcasecmp() behaviour was not
standards compliant. Brian Stafford then provided these new
implementations, which apprear to properly follow SUSv2.
-Erik
Diffstat (limited to 'libc/string/strcasecmp.c')
-rw-r--r-- | libc/string/strcasecmp.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/libc/string/strcasecmp.c b/libc/string/strcasecmp.c index 0ec81f641..e0d11170a 100644 --- a/libc/string/strcasecmp.c +++ b/libc/string/strcasecmp.c @@ -6,16 +6,16 @@ #include <string.h> #include <ctype.h> -int strcasecmp( const char *s, const char *d) +int strcasecmp (const char *a, const char *b) { - for (;;) { - if (*s != *d) { - if (tolower(*s) != tolower(*d)) - return *s - *d; - } else if (*s == '\0') - break; - s++; - d++; - } - return 0; + register int n; + + while (*a == *b || (n = tolower (*a) - tolower (*b)) == 0) + { + if (*a == '\0') + return 0; + a++, b++; + } + return n; } + |