Added SDL_strcasestr() for a case insensitive version of SDL_strstr()

This commit is contained in:
Sam Lantinga 2022-11-05 15:58:30 -07:00
parent a4626dea8d
commit 297ecb706d
5 changed files with 21 additions and 0 deletions

View file

@ -761,6 +761,23 @@ SDL_strstr(const char *haystack, const char *needle)
#endif /* HAVE_STRSTR */
}
char *
SDL_strcasestr(const char *haystack, const char *needle)
{
#if defined(HAVE_STRCASESTR)
return SDL_const_cast(char*,strcasestr(haystack, needle));
#else
size_t length = SDL_strlen(needle);
while (*haystack) {
if (SDL_strncasecmp(haystack, needle, length) == 0) {
return (char *) haystack;
}
++haystack;
}
return NULL;
#endif /* HAVE_STRCASESTR */
}
#if !defined(HAVE__LTOA) || !defined(HAVE__I64TOA) || \
!defined(HAVE__ULTOA) || !defined(HAVE__UI64TOA)
static const char ntoa_table[] = {