1
0
Fork 0
forked from len0rd/rockbox
foxbox/firmware/common/strcasecmp.c
Roman Artiukhin e08b8fcc74 strcasecmp: Optimize size and speed
Applies changes similar to strncasecmp in 64c0cfb0.

Change-Id: I5f80b0031dd12c58d982578f5c5224c7f59cd915
2025-05-18 16:57:35 -04:00

34 lines
566 B
C

#include <string.h>
#include <ctype.h>
#ifndef strcasecmp
int strcasecmp(const char *s1, const char *s2)
{
int d, c1, c2;
do
{
c1 = tolower(*s1++);
c2 = tolower(*s2++);
}
while ((d = c1 - c2) == 0 && c1 && c2);
return d;
}
#endif
#ifndef strncasecmp
int strncasecmp(const char *s1, const char *s2, size_t n)
{
int d = 0;
for(; n != 0; n--)
{
int c1 = tolower(*s1++);
int c2 = tolower(*s2++);
if((d = c1 - c2) != 0 || c2 == '\0')
break;
}
return d;
}
#endif