aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-06-25 23:01:29 +0200
committerMax Kellermann <max@duempel.org>2015-06-25 23:01:29 +0200
commitc7712e2ef0232a39786075dbf6683120cfe5cc0a (patch)
tree4d8b687e83cdf9cc2e7a289214968f60c756e400 /src
parent61fa770644ff980b521e5cf016c969bfa04c9f63 (diff)
downloadmpd-c7712e2ef0232a39786075dbf6683120cfe5cc0a.tar.gz
mpd-c7712e2ef0232a39786075dbf6683120cfe5cc0a.tar.xz
mpd-c7712e2ef0232a39786075dbf6683120cfe5cc0a.zip
lib/icu/Collate: fall back to strxfrm()
Diffstat (limited to '')
-rw-r--r--src/lib/icu/Collate.cxx18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/lib/icu/Collate.cxx b/src/lib/icu/Collate.cxx
index 455f346b7..207252935 100644
--- a/src/lib/icu/Collate.cxx
+++ b/src/lib/icu/Collate.cxx
@@ -180,8 +180,22 @@ IcuCaseFold(const char *src)
std::string result(tmp);
g_free(tmp);
#else
- std::string result(src);
- std::transform(result.begin(), result.end(), result.begin(), tolower);
+ size_t size = strlen(src) + 1;
+ 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
return result;
}