From 828f5f83844b072f43417066c36d7d257d63db1a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 20 Sep 2017 23:53:03 +0200 Subject: [PATCH] lib/icu/CaseFold: disable broken strxfrm() callback --- src/lib/icu/CaseFold.cxx | 21 ++++++--------------- src/lib/icu/CaseFold.hxx | 6 ++++-- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/lib/icu/CaseFold.cxx b/src/lib/icu/CaseFold.cxx index d34b1737b..ccdf998d5 100644 --- a/src/lib/icu/CaseFold.cxx +++ b/src/lib/icu/CaseFold.cxx @@ -19,6 +19,9 @@ #include "config.h" #include "CaseFold.hxx" + +#ifdef HAVE_ICU_CASE_FOLD + #include "util/AllocatedString.hxx" #ifdef HAVE_ICU @@ -90,22 +93,10 @@ try { return WideCharToMultiByte(CP_UTF8, buffer.get()); #else - size_t size = strlen(src) + 1; - std::unique_ptr buffer(new char[size]); - size_t nbytes = strxfrm(buffer.get(), src, size); - if (nbytes >= size) { - /* buffer too small - reallocate and try again */ - buffer.reset(); - size = nbytes + 1; - buffer.reset(new char[size]); - nbytes = strxfrm(buffer.get(), src, size); - } - - assert(nbytes < size); - assert(buffer[nbytes] == 0); - - return AllocatedString<>::Donate(buffer.release()); +#error not implemented #endif } catch (const std::runtime_error &) { return AllocatedString<>::Duplicate(src); } + +#endif /* HAVE_ICU_CASE_FOLD */ diff --git a/src/lib/icu/CaseFold.hxx b/src/lib/icu/CaseFold.hxx index 5b9fa6064..eaeaf5689 100644 --- a/src/lib/icu/CaseFold.hxx +++ b/src/lib/icu/CaseFold.hxx @@ -21,11 +21,11 @@ #define MPD_ICU_CASE_FOLD_HXX #include "check.h" -#include "Compiler.h" #if defined(HAVE_ICU) || defined(_WIN32) #define HAVE_ICU_CASE_FOLD -#endif + +#include "Compiler.h" template class AllocatedString; @@ -34,3 +34,5 @@ AllocatedString IcuCaseFold(const char *src) noexcept; #endif + +#endif