X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=strcasecmp.c;h=76ab9be3eb8087b851d65896b85b5a282945e5bc;hb=49268a95ee78bc179fd3439b3f06e9a06c993c92;hp=c1f3bbd82296d3ab9b41ab586950b7116327cd2d;hpb=dc6faf2379170e7cac5005854ce48958115d4896;p=~andy%2Ffetchmail diff --git a/strcasecmp.c b/strcasecmp.c index c1f3bbd8..76ab9be3 100644 --- a/strcasecmp.c +++ b/strcasecmp.c @@ -6,18 +6,18 @@ */ #include -strcasecmp(char *s1, char *s2) +int strcasecmp(char *s1, char *s2) { - while (toupper(*s1) == toupper(*s2++)) + while (toupper((unsigned char)*s1) == toupper((unsigned char)*s2++)) if (*s1++ == '\0') - return(0); - return(toupper(*s1) - toupper(*--s2)); + return 0; + return(toupper((unsigned char)*s1) - toupper((unsigned char)*--s2)); } -strncasecmp(char *s1, char *s2, register int n) +int strncasecmp(char *s1, char *s2, register int n) { - while (--n >= 0 && toupper(*s1) == toupper(*s2++)) - if (toupper(*s1++) == '\0') - return(0); - return(n < 0 ? 0 : toupper(*s1) - toupper(*--s2)); + while (--n >= 0 && toupper((unsigned char)*s1) == toupper((unsigned char)*s2++)) + if (*s1++ == '\0') + return 0; + return(n < 0 ? 0 : toupper((unsigned char)*s1) - toupper((unsigned char)*--s2)); }