]> Pileus Git - ~andy/fetchmail/blobdiff - strcasecmp.c
Update website for 6.3.24.
[~andy/fetchmail] / strcasecmp.c
index d52bd2905a18a8321f69591612994997c7f4dc2d..76ab9be3eb8087b851d65896b85b5a282945e5bc 100644 (file)
@@ -1,21 +1,23 @@
 /* 
  * scratch implementation of strcasecmp(), 
  * in case your C library doesn't have it 
+ *
+ * For license terms, see the file COPYING in this directory.
  */
 #include <ctype.h>
 
-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));
 }