583
|
1 #ifdef HAVE_CONFIG_H |
|
2 # include <config.h> |
|
3 #endif |
|
4 |
|
5 #include <sys/types.h> |
|
6 #include <ctype.h> |
|
7 |
|
8 #if _LIBC || STDC_HEADERS |
|
9 # define TOLOWER(c) tolower (c) |
|
10 #else |
|
11 # define TOLOWER(c) (ISUPPER (c) ? tolower (c) : (c)) |
|
12 #endif |
|
13 |
|
14 #include "memcasecmp.h" |
|
15 |
|
16 /* Like memcmp, but ignore differences in case. */ |
|
17 |
|
18 int |
|
19 memcasecmp (const void *vs1, const void *vs2, size_t n) |
|
20 { |
|
21 unsigned int i; |
|
22 unsigned char *s1 = (unsigned char *) vs1; |
|
23 unsigned char *s2 = (unsigned char *) vs2; |
|
24 for (i = 0; i < n; i++) |
|
25 { |
|
26 unsigned char u1 = *s1++; |
|
27 unsigned char u2 = *s2++; |
|
28 if (TOLOWER (u1) != TOLOWER (u2)) |
|
29 return TOLOWER (u1) - TOLOWER (u2); |
|
30 } |
|
31 return 0; |
|
32 } |