1 /* $NetBSD: strcasecmp.c,v 1.3 2019/08/13 08:48:07 christos Exp $ */
2
3 /*
4 * Written by Martin Husemann <martin@NetBSD.org>
5 * Public domain.
6 */
7
8 #include <strings.h>
9
10 /*
11 * Simple strcasecmp, try to avoid pulling in real locales
12 */
13 int
strcasecmp(const char * s1,const char * s2)14 strcasecmp(const char *s1, const char *s2)
15 {
16 unsigned char c1, c2;
17
18 do {
19 c1 = *s1++;
20 c2 = *s2++;
21 if (c1 >= 'A' && c1 <= 'Z')
22 c1 += 'a' - 'A';
23 if (c2 >= 'A' && c2 <= 'Z')
24 c2 += 'a' - 'A';
25 } while (c1 == c2 && c1 != 0 && c2 != 0);
26
27 return ((c1 == c2) ? 0 : ((c1 > c2) ? 1 : -1));
28 }
29