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

@@ -39,6 +39,18 @@ StringEndsWith(const wchar_t *haystack, const wchar_t *needle) noexcept
StringIsEqual(haystack + haystack_length - needle_length, needle);
}
bool
StringEndsWithIgnoreCase(const wchar_t *haystack,
const wchar_t *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 wchar_t *
FindStringSuffix(const wchar_t *p, const wchar_t *suffix) noexcept
{