util/StringCompare: add StringEndsWithIgnoreCase(), StringStartsWithIgnoreCase()

This commit is contained in:
Max Kellermann
2018-09-06 19:29:25 +02:00
parent 2d6f9f9a9c
commit 728e4e9a38
4 changed files with 47 additions and 0 deletions

View File

@@ -40,6 +40,17 @@ StringEndsWith(const char *haystack, const char *needle) noexcept
needle, needle_length) == 0;
}
bool
StringEndsWithIgnoreCase(const char *haystack, const char *needle) noexcept
{
const size_t haystack_length = StringLength(haystack);
const size_t needle_length = StringLength(needle);
return haystack_length >= needle_length &&
StringIsEqualIgnoreCase(haystack + haystack_length - needle_length,
needle);
}
const char *
FindStringSuffix(const char *p, const char *suffix) noexcept
{