b3dd1fab85951b0ce7e95c88265ce60837f6a305
[debian/amanda] / common-src / strcasecmp.c
1 /* Provided by Michael Schmitz <mschmitz@sema.de>; public domain? */
2 #ifdef HAVE_CONFIG_H
3 #include <config.h>
4 #endif
5
6 #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
7 #include <string.h>
8 #else
9 #include <strings.h>
10 #endif
11
12 /* Compare S1 and S2 ignoring case, returning less than,
13    equal to or greater than zero if S1 is lexicographically
14    less than, equal to or greater than S2.  */
15 int
16 strcasecmp(s1, s2)
17       const char *s1;
18       const char *s2;
19 {
20   register const unsigned char *p1 = (const unsigned char *) s1;
21   register const unsigned char *p2 = (const unsigned char *) s2;
22   unsigned char c1, c2;
23
24   if (p1 == p2)
25     return 0;
26
27   do
28     {
29       c1 = tolower (*p1++);
30       c2 = tolower (*p2++);
31       if (c1 == '\0' || c2 == '\0' || c1 != c2)
32         return c1 - c2;
33     } while ( 1 == 1 );
34 }