lib/icu/Compare: use StringStartsWith() for improved code clarity
Also fixes the inverted strncmp() call.
This commit is contained in:
parent
cd253e470a
commit
2c11095eed
@ -20,6 +20,7 @@
|
|||||||
#include "Compare.hxx"
|
#include "Compare.hxx"
|
||||||
#include "CaseFold.hxx"
|
#include "CaseFold.hxx"
|
||||||
#include "util/StringAPI.hxx"
|
#include "util/StringAPI.hxx"
|
||||||
|
#include "util/StringCompare.hxx"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -117,8 +118,7 @@ bool
|
|||||||
IcuCompare::StartsWith(const char *haystack) const noexcept
|
IcuCompare::StartsWith(const char *haystack) const noexcept
|
||||||
{
|
{
|
||||||
#ifdef HAVE_ICU_CASE_FOLD
|
#ifdef HAVE_ICU_CASE_FOLD
|
||||||
return StringIsEqual(IcuCaseFold(haystack).c_str(),
|
return StringStartsWith(IcuCaseFold(haystack).c_str(), needle);
|
||||||
needle.c_str(), strlen(needle.c_str()));
|
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
if (needle == nullptr)
|
if (needle == nullptr)
|
||||||
/* the MultiByteToWideChar() call in the constructor
|
/* the MultiByteToWideChar() call in the constructor
|
||||||
@ -138,6 +138,6 @@ IcuCompare::StartsWith(const char *haystack) const noexcept
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return strncmp(haystack, needle.c_str(), strlen(needle.c_str()));
|
return StringStartsWith(haystack, needle);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user