libc: Rename fold() to lowercase() in strcasecmp and strncasecmp
This commit is contained in:
parent
da182f1c2f
commit
d7692a7f59
@ -2,7 +2,7 @@
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
static char fold(char c)
|
||||
static char lowercase(char c)
|
||||
{
|
||||
if (isalpha(c)) return (char)tolower(c);
|
||||
return c;
|
||||
@ -22,22 +22,22 @@ extern "C"
|
||||
|
||||
int strcasecmp(const char* a, const char* b)
|
||||
{
|
||||
while (*a && (fold(*a) == fold(*b)))
|
||||
while (*a && (lowercase(*a) == lowercase(*b)))
|
||||
{
|
||||
a++;
|
||||
b++;
|
||||
}
|
||||
return (unsigned char)fold(*a) - (unsigned char)fold(*b);
|
||||
return (unsigned char)lowercase(*a) - (unsigned char)lowercase(*b);
|
||||
}
|
||||
|
||||
int strncasecmp(const char* a, const char* b, size_t max)
|
||||
{
|
||||
const char* base = a;
|
||||
while (*a && (fold(*a) == fold(*b)) && (size_t)(a - base) < (max - 1))
|
||||
while (*a && (lowercase(*a) == lowercase(*b)) && (size_t)(a - base) < (max - 1))
|
||||
{
|
||||
a++;
|
||||
b++;
|
||||
}
|
||||
return (unsigned char)fold(*a) - (unsigned char)fold(*b);
|
||||
return (unsigned char)lowercase(*a) - (unsigned char)lowercase(*b);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user