Rocco Rutte:
[apps/madmutt.git] / strcasecmp.c
1 /*
2  * Copyright notice from original mutt:
3  * [none]
4  *
5  * This file is part of mutt-ng, see http://www.muttng.org/.
6  * It's licensed under the GNU General Public License,
7  * please see the file GPL in the top level source directory.
8  */
9
10 #include <ctype.h>
11 #include <sys/types.h>
12
13 /* UnixWare doesn't have these functions in its standard C library */
14
15 int strncasecmp (char *s1, char *s2, size_t n)
16 {
17   register int c1, c2, l = 0;
18
19   while (*s1 && *s2 && l < n) {
20     c1 = tolower ((unsigned char) *s1);
21     c2 = tolower ((unsigned char) *s2);
22     if (c1 != c2)
23       return (c1 - c2);
24     s1++;
25     s2++;
26     l++;
27   }
28   if (l == n)
29     return (int) (0);
30   else
31     return (int) (*s1 - *s2);
32 }
33
34 int strcasecmp (char *s1, char *s2)
35 {
36   register int c1, c2;
37
38   while (*s1 && *s2) {
39     c1 = tolower ((unsigned char) *s1);
40     c2 = tolower ((unsigned char) *s2);
41     if (c1 != c2)
42       return (c1 - c2);
43     s1++;
44     s2++;
45   }
46   return (int) (*s1 - *s2);
47 }