From 33fc3af775ca35ae343a4e50de36e8853cabb86d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 23 Feb 2014 19:27:08 +0100 Subject: SongSort, ...: use libicu instead of GLib's g_utf8_*() --- src/SongFilter.cxx | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) (limited to 'src/SongFilter.cxx') diff --git a/src/SongFilter.cxx b/src/SongFilter.cxx index 77fea606e..03ff3991e 100644 --- a/src/SongFilter.cxx +++ b/src/SongFilter.cxx @@ -25,10 +25,7 @@ #include "tag/Tag.hxx" #include "util/ASCII.hxx" #include "util/UriUtil.hxx" - -#ifdef HAVE_GLIB -#include -#endif +#include "lib/icu/Collate.hxx" #include #include @@ -54,27 +51,12 @@ locate_parse_type(const char *str) return tag_name_parse_i(str); } -gcc_pure -static std::string -CaseFold(const char *p) -{ -#ifdef HAVE_GLIB - char *q = g_utf8_casefold(p, -1); - std::string result(q); - g_free(q); - return result; -#else - // TODO: implement without GLib - return p; -#endif -} - gcc_pure static std::string ImportString(const char *p, bool fold_case) { return fold_case - ? CaseFold(p) + ? IcuCaseFold(p) : std::string(p); } @@ -90,17 +72,8 @@ SongFilter::Item::StringMatch(const char *s) const assert(s != nullptr); if (fold_case) { -#ifdef HAVE_GLIB - char *p = g_utf8_casefold(s, -1); -#else - // TODO: implement without GLib - const char *p = s; -#endif - const bool result = strstr(p, value.c_str()) != NULL; -#ifdef HAVE_GLIB - g_free(p); -#endif - return result; + const std::string folded = IcuCaseFold(s); + return folded.find(value) != folded.npos; } else { return s == value; } -- cgit v1.2.3