avstring: Add locale independent implementations of strcasecmp/strncasecmp
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:

committed by
Martin Storsjö

parent
07b172fe8f
commit
ba04ecfdac
@@ -134,6 +134,27 @@ char *av_get_token(const char **buf, const char *term)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int av_strcasecmp(const char *a, const char *b)
|
||||
{
|
||||
uint8_t c1, c2;
|
||||
do {
|
||||
c1 = av_tolower(*a++);
|
||||
c2 = av_tolower(*b++);
|
||||
} while (c1 && c1 == c2);
|
||||
return c1 - c2;
|
||||
}
|
||||
|
||||
int av_strncasecmp(const char *a, const char *b, size_t n)
|
||||
{
|
||||
const char *end = a + n;
|
||||
uint8_t c1, c2;
|
||||
do {
|
||||
c1 = av_tolower(*a++);
|
||||
c2 = av_tolower(*b++);
|
||||
} while (a < end && c1 && c1 == c2);
|
||||
return c1 - c2;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#undef printf
|
||||
|
Reference in New Issue
Block a user