mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-27 14:23:06 +00:00
Better implementation of string_is_equal_noncase and fix bug
in string_list
This commit is contained in:
parent
271edb4ca1
commit
dd1da5154f
@ -50,27 +50,20 @@ static INLINE bool string_is_equal(const char *a, const char *b)
|
||||
|
||||
static INLINE bool string_is_equal_noncase(const char *a, const char *b)
|
||||
{
|
||||
bool ret;
|
||||
int i;
|
||||
char *cp1, *cp2;
|
||||
int result;
|
||||
const unsigned char *p1 = (const unsigned char*)a;
|
||||
const unsigned char *p2 = (const unsigned char*)b;
|
||||
|
||||
if (!a || !b)
|
||||
return false;
|
||||
if (p1 == p2)
|
||||
return false;
|
||||
|
||||
cp1 = (char*)malloc(strlen(a) + 1);
|
||||
cp2 = (char*)malloc(strlen(b) + 1);
|
||||
while ((result = tolower (*p1) - tolower (*p2++)) == 0)
|
||||
if (*p1++ == '\0')
|
||||
break;
|
||||
|
||||
for (i = 0; i < strlen(a) + 1; i++)
|
||||
cp1[i] = tolower((int) (unsigned char) a[i]);
|
||||
for (i = 0; i < strlen(b) + 1; i++)
|
||||
cp2[i] = tolower((int) (unsigned char) b[i]);
|
||||
|
||||
ret = string_is_equal(cp1, cp2);
|
||||
|
||||
free(cp1);
|
||||
free(cp2);
|
||||
|
||||
return ret;
|
||||
return (result == 0);
|
||||
}
|
||||
|
||||
char *string_to_upper(char *s);
|
||||
|
@ -304,7 +304,7 @@ bool string_list_find_elem_prefix(const struct string_list *list,
|
||||
for (i = 0; i < list->size; i++)
|
||||
{
|
||||
if (string_is_equal_noncase(list->elems[i].data, elem) ||
|
||||
string_is_equal_noncase(list->elems[i].data, prefixed) == 0)
|
||||
string_is_equal_noncase(list->elems[i].data, prefixed))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user