1 /* $NetBSD: strcasecmp.c,v 1.2 2019/08/12 09:34:53 martin 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 14 strcasecmp(const char *s1, const char *s2) 15 { 16 unsigned int 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