COMMON: Added scumm_strcasestr()

This commit is contained in:
Eugene Sandulenko 2020-06-18 14:38:12 +02:00
parent 1ca0510284
commit 6059566777
2 changed files with 21 additions and 0 deletions

View File

@ -1323,3 +1323,22 @@ char *scumm_strdup(const char *in) {
}
return out;
}
// Portable implementation of strcasestr.
const char *scumm_strcasestr(const char *s, const char *find) {
char c, sc;
size_t len;
if ((c = *find++) != 0) {
c = (char)tolower((unsigned char)c);
len = strlen(find);
do {
do {
if ((sc = *s++) == 0)
return (NULL);
} while ((char)tolower((unsigned char)sc) != c);
} while (scumm_strnicmp(s, find, len) != 0);
s--;
}
return s;
}

View File

@ -568,4 +568,6 @@ extern char *scumm_strdup(const char *in);
extern int scumm_compareDictionary(const char *s1, const char *s2);
extern const char *scumm_skipArticle(const char *s1);
extern const char *scumm_strcasestr(const char *s, const char *find);
#endif