1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
1 |
#include <ctype.h> |
2 |
#include <sys/types.h> |
|
3 |
||
4 |
/* UnixWare doesn't have these functions in its standard C library */
|
|
5 |
||
6 |
int strncasecmp (char *s1, char *s2, size_t n) |
|
7 |
{
|
|
8 |
register int c1, c2, l = 0; |
|
9 |
||
10 |
while (*s1 && *s2 && l < n) |
|
11 |
{
|
|
12 |
c1 = tolower ((unsigned char) *s1); |
|
13 |
c2 = tolower ((unsigned char) *s2); |
|
14 |
if (c1 != c2) |
|
15 |
return (c1 - c2); |
|
16 |
s1++; |
|
17 |
s2++; |
|
18 |
l++; |
|
19 |
}
|
|
20 |
if (l == n) |
|
21 |
return (int) (0); |
|
22 |
else
|
|
23 |
return (int) (*s1 - *s2); |
|
24 |
}
|
|
25 |
||
26 |
int strcasecmp (char *s1, char *s2) |
|
27 |
{
|
|
28 |
register int c1, c2; |
|
29 |
||
30 |
while (*s1 && *s2) |
|
31 |
{
|
|
32 |
c1 = tolower ((unsigned char) *s1); |
|
33 |
c2 = tolower ((unsigned char) *s2); |
|
34 |
if (c1 != c2) |
|
35 |
return (c1 - c2); |
|
36 |
s1++; |
|
37 |
s2++; |
|
38 |
}
|
|
39 |
return (int) (*s1 - *s2); |
|
40 |
}
|