blob: 76ab9be3eb8087b851d65896b85b5a282945e5bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/*
* scratch implementation of strcasecmp(),
* in case your C library doesn't have it
*
* For license terms, see the file COPYING in this directory.
*/
#include <ctype.h>
int strcasecmp(char *s1, char *s2)
{
while (toupper((unsigned char)*s1) == toupper((unsigned char)*s2++))
if (*s1++ == '\0')
return 0;
return(toupper((unsigned char)*s1) - toupper((unsigned char)*--s2));
}
int strncasecmp(char *s1, char *s2, register int n)
{
while (--n >= 0 && toupper((unsigned char)*s1) == toupper((unsigned char)*s2++))
if (*s1++ == '\0')
return 0;
return(n < 0 ? 0 : toupper((unsigned char)*s1) - toupper((unsigned char)*--s2));
}
|