]> Pileus Git - ~andy/fetchmail/blob - strcasecmp.c
Reimplement this to get rid of BSD Classic license.
[~andy/fetchmail] / strcasecmp.c
1 /* 
2  * scratch implementation of strcasecmp(), 
3  * in case your C library doesn't have it 
4  */
5 #include <ctype.h>
6
7 strcasecmp(char *s1, char *s2)
8 {
9     while (toupper(*s1) == toupper(*s2++))
10         if (*s1++ == '\0')
11             return(0);
12     return(toupper(*s1) - toupper(*--s2));
13 }
14
15 strncasecmp(char *s1, char *s2, register int n)
16 {
17     while (--n >= 0 && toupper(*s1) == toupper(*s2++))
18         if (toupper(*s1++) == '\0')
19             return(0);
20     return(n < 0 ? 0 : toupper(*s1) - toupper(*--s2));
21 }