Andreas Krennmair:
[apps/madmutt.git] / strcasecmp.c
1 #include <ctype.h>
2 #include <sys/types.h>
3
4 /* UnixWare doesn't have these functions in its standard C library */
5
6 int strncasecmp (char *s1, char *s2, size_t n)
7 {
8   register int c1, c2, l = 0;
9
10   while (*s1 && *s2 && l < n) {
11     c1 = tolower ((unsigned char) *s1);
12     c2 = tolower ((unsigned char) *s2);
13     if (c1 != c2)
14       return (c1 - c2);
15     s1++;
16     s2++;
17     l++;
18   }
19   if (l == n)
20     return (int) (0);
21   else
22     return (int) (*s1 - *s2);
23 }
24
25 int strcasecmp (char *s1, char *s2)
26 {
27   register int c1, c2;
28
29   while (*s1 && *s2) {
30     c1 = tolower ((unsigned char) *s1);
31     c2 = tolower ((unsigned char) *s2);
32     if (c1 != c2)
33       return (c1 - c2);
34     s1++;
35     s2++;
36   }
37   return (int) (*s1 - *s2);
38 }