lib/icu/Collate: fall back to strxfrm()
This commit is contained in:
parent
61fa770644
commit
c7712e2ef0
@ -180,8 +180,22 @@ IcuCaseFold(const char *src)
|
|||||||
std::string result(tmp);
|
std::string result(tmp);
|
||||||
g_free(tmp);
|
g_free(tmp);
|
||||||
#else
|
#else
|
||||||
std::string result(src);
|
size_t size = strlen(src) + 1;
|
||||||
std::transform(result.begin(), result.end(), result.begin(), tolower);
|
auto buffer = new char[size];
|
||||||
|
size_t nbytes = strxfrm(buffer, src, size);
|
||||||
|
if (nbytes >= size) {
|
||||||
|
/* buffer too small - reallocate and try again */
|
||||||
|
delete[] buffer;
|
||||||
|
size = nbytes + 1;
|
||||||
|
buffer = new char[size];
|
||||||
|
nbytes = strxfrm(buffer, src, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(nbytes < size);
|
||||||
|
assert(buffer[nbytes] == 0);
|
||||||
|
|
||||||
|
std::string result(buffer, nbytes);
|
||||||
|
delete[] buffer;
|
||||||
#endif
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user