Replace strcasestr() with String::Contains()

This commit is contained in:
Gymnasiast 2023-01-07 15:45:03 +01:00
parent aa01e21a55
commit 2f097e99c9
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
3 changed files with 1 additions and 43 deletions

View File

@ -785,7 +785,7 @@ private:
Formatter ft;
peep.FormatNameTo(ft);
format_string(name, sizeof(name), STR_STRINGID, ft.Data());
if (strcasestr(name, _filterName.c_str()) == nullptr)
if (!String::Contains(name, _filterName.c_str(), true))
{
return false;
}

View File

@ -336,45 +336,6 @@ char* safe_strcat(char* destination, const char* source, size_t size)
return result;
}
#if defined(_WIN32)
char* strcasestr(const char* haystack, const char* needle)
{
const char* p1 = haystack;
const char* p2 = needle;
const char* r = *p2 == 0 ? haystack : nullptr;
while (*p1 != 0 && *p2 != 0)
{
if (tolower(static_cast<unsigned char>(*p1)) == tolower(static_cast<unsigned char>(*p2)))
{
if (r == nullptr)
r = p1;
p2++;
}
else
{
p2 = needle;
if (r != nullptr)
p1 = r + 1;
if (tolower(static_cast<unsigned char>(*p1)) == tolower(static_cast<unsigned char>(*p2)))
{
r = p1;
p2++;
}
else
{
r = nullptr;
}
}
p1++;
}
return *p2 == 0 ? const_cast<char*>(r) : nullptr;
}
#endif
bool str_is_null_or_empty(const char* str)
{
return str == nullptr || str[0] == 0;

View File

@ -33,9 +33,6 @@ int32_t bitcount(uint32_t source);
int32_t strlogicalcmp(char const* a, char const* b);
char* safe_strcpy(char* destination, const char* source, size_t num);
char* safe_strcat(char* destination, const char* source, size_t size);
#if defined(_WIN32)
char* strcasestr(const char* haystack, const char* needle);
#endif
bool str_is_null_or_empty(const char* str);