forked from len0rd/rockbox
case insensitive string comparisons
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1057 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b1fe81d8c7
commit
d38ab69072
1 changed files with 28 additions and 0 deletions
28
firmware/common/strcasecmp.c
Normal file
28
firmware/common/strcasecmp.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int strcasecmp(const char *s1, const char *s2)
|
||||
{
|
||||
while (*s1 != '\0' && tolower(*s1) == tolower(*s2)) {
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
|
||||
}
|
||||
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
if(!n)
|
||||
return 0;
|
||||
|
||||
while (n-- != 0 && tolower(*s1) == tolower(*s2)) {
|
||||
if(n == 0 || *s1 == '\0')
|
||||
break;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue