Create rarch_strcasestr

This commit is contained in:
twinaphex 2015-05-26 02:31:29 +02:00
parent fd59696f8f
commit c94e29ed02
3 changed files with 27 additions and 1 deletions

View File

@ -364,3 +364,27 @@ char *rarch_strtok_r__(char *str, const char *delim, char **saveptr)
#endif
/*
* Find the first occurrence of find in s, ignore case.
*/
char *rarch_strcasestr(const char *s, const char *find)
{
char c, sc;
size_t len;
if ((c = *find++) != 0)
{
c = tolower((unsigned char)c);
len = strlen(find);
do
{
do
{
if ((sc = *s++) == 0)
return (NULL);
}while ((char)tolower((unsigned char)sc) != c);
}while (strncasecmp(s, find, len) != 0);
s--;
}
return ((char *)s);
}

View File

@ -44,6 +44,8 @@ extern "C" {
size_t strlcpy(char *dest, const char *source, size_t size);
size_t strlcat(char *dest, const char *source, size_t size);
char *rarch_strcasestr(const char *s, const char *find);
#ifdef __cplusplus
}
#endif

View File

@ -210,7 +210,7 @@ static int database_info_iterate_crc_lookup(
entry_state_crc, db_info_entry->crc32, db_info_entry->name);
#endif
if (strcasestr(entry_state_crc, db_info_entry->crc32))
if (rarch_strcasestr(entry_state_crc, db_info_entry->crc32))
return database_info_list_iterate_found_match(db_state, db);
}
}