aboutsummaryrefslogtreecommitdiffstats
path: root/src/SongFilter.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-23 19:27:08 +0100
committerMax Kellermann <max@duempel.org>2014-02-24 20:39:37 +0100
commit33fc3af775ca35ae343a4e50de36e8853cabb86d (patch)
treebfa5312e28ae2e62ecb167436ccb62a70250bd0a /src/SongFilter.cxx
parent6d9739165eaf3d81e00f60124cfc48aba509a9a6 (diff)
downloadmpd-33fc3af775ca35ae343a4e50de36e8853cabb86d.tar.gz
mpd-33fc3af775ca35ae343a4e50de36e8853cabb86d.tar.xz
mpd-33fc3af775ca35ae343a4e50de36e8853cabb86d.zip
SongSort, ...: use libicu instead of GLib's g_utf8_*()
Diffstat (limited to 'src/SongFilter.cxx')
-rw-r--r--src/SongFilter.cxx35
1 files changed, 4 insertions, 31 deletions
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 <glib.h>
-#endif
+#include "lib/icu/Collate.hxx"
#include <assert.h>
#include <string.h>
@@ -56,25 +53,10 @@ locate_parse_type(const char *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;
}