Commit 3a818b6d authored by Max Kellermann's avatar Max Kellermann

SongFilter: disable g_utf8_casefold() without GLib

Temporary hack for the experimental no-GLib build.
parent 1709ab68
...@@ -26,7 +26,9 @@ ...@@ -26,7 +26,9 @@
#include "util/ASCII.hxx" #include "util/ASCII.hxx"
#include "util/UriUtil.hxx" #include "util/UriUtil.hxx"
#ifdef HAVE_GLIB
#include <glib.h> #include <glib.h>
#endif
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
...@@ -56,10 +58,15 @@ gcc_pure ...@@ -56,10 +58,15 @@ gcc_pure
static std::string static std::string
CaseFold(const char *p) CaseFold(const char *p)
{ {
#ifdef HAVE_GLIB
char *q = g_utf8_casefold(p, -1); char *q = g_utf8_casefold(p, -1);
std::string result(q); std::string result(q);
g_free(q); g_free(q);
return result; return result;
#else
// TODO: implement without GLib
return p;
#endif
} }
gcc_pure gcc_pure
...@@ -83,9 +90,16 @@ SongFilter::Item::StringMatch(const char *s) const ...@@ -83,9 +90,16 @@ SongFilter::Item::StringMatch(const char *s) const
assert(s != nullptr); assert(s != nullptr);
if (fold_case) { if (fold_case) {
#ifdef HAVE_GLIB
char *p = g_utf8_casefold(s, -1); 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; const bool result = strstr(p, value.c_str()) != NULL;
#ifdef HAVE_GLIB
g_free(p); g_free(p);
#endif
return result; return result;
} else { } else {
return s == value; return s == value;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment