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)
{
if(!n)
return 0;
while (n-- != 0 && tolower(*s1) == tolower(*s2)) {
if(n == 0 || *s1 == '\0')
break;
s1++;
s2++;
int d = 0;
for(; n != 0; n--)
{
int c1 = tolower(*s1++);
int c2 = tolower(*s2++);
if((d = c1 - c2) != 0 || c2 == '\0')
break;
}
return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
return d;
}