1
0
Fork 0
forked from len0rd/rockbox

Optimize (size and speed) strncasecmp (based on a newlib patch).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24542 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Amaury Pouly 2010-02-07 00:37:47 +00:00
parent 8a36f0bad4
commit 64c0cfb0bd

View file

@ -14,15 +14,15 @@ int strcasecmp(const char *s1, const char *s2)
int strncasecmp(const char *s1, const char *s2, size_t n) int strncasecmp(const char *s1, const char *s2, size_t n)
{ {
if(!n) int d = 0;
return 0;
for(; n != 0; n--)
while (n-- != 0 && tolower(*s1) == tolower(*s2)) { {
if(n == 0 || *s1 == '\0') int c1 = tolower(*s1++);
break; int c2 = tolower(*s2++);
s1++; if((d = c1 - c2) != 0 || c2 == '\0')
s2++; break;
} }
return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2); return d;
} }