blob: 7c2c9717c8904a5b79b121bdeb9b254b4a268048 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include <libc.h>
#include <ctype.h>
#include <stddef.h>
int strncasecmp(const char *s1, const char *s2, size_t n)
{
unsigned char c1, c2;
if (n == 0)
return 0;
while (n-- > 0 && *s1 && *s2) {
c1 = (unsigned char)tolower((unsigned char)*s1);
c2 = (unsigned char)tolower((unsigned char)*s2);
if (c1 != c2)
return c1 - c2;
s1++;
s2++;
}
if (n == (size_t)-1)
return 0;
return (unsigned char)tolower((unsigned char)*s1) -
(unsigned char)tolower((unsigned char)*s2);
}
__weak int strncasecmp_l(const char *s1, const char *s2, size_t n,
locale_t __unused locale)
{
return strncasecmp(s1, s2, n);
}
|