LibC: add strcasestr to string.h

This commit is contained in:
DcraftBg
2026-04-17 21:04:31 +03:00
committed by Bananymous
parent 5fce3b64cc
commit f527aca9d0
2 changed files with 12 additions and 0 deletions

View File

@@ -304,6 +304,17 @@ char* strstr(const char* haystack, const char* needle)
return nullptr;
}
char* strcasestr(const char* haystack, const char* needle)
{
const size_t needle_len = strlen(needle);
if (needle_len == 0)
return const_cast<char*>(haystack);
for (size_t i = 0; haystack[i]; i++)
if (strncasecmp(haystack + i, needle, needle_len) == 0)
return const_cast<char*>(haystack + i);
return nullptr;
}
#define CHAR_UCHAR(ch) \
static_cast<unsigned char>(ch)