aboutsummaryrefslogtreecommitdiffstats
path: root/src/tag
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-17 22:33:10 +0100
committerMax Kellermann <max@duempel.org>2014-02-17 22:33:10 +0100
commit6a08f2281a66b3d41a02350d2ba75f453976faac (patch)
tree96b135bab1ef45c1aede1c477dbf1bc15497f74e /src/tag
parent91729437a0c24c5aad8f223f64ee63e918fe8b91 (diff)
downloadmpd-6a08f2281a66b3d41a02350d2ba75f453976faac.tar.gz
mpd-6a08f2281a66b3d41a02350d2ba75f453976faac.tar.xz
mpd-6a08f2281a66b3d41a02350d2ba75f453976faac.zip
TagString: disable UTF-8 validation if GLib is disabled
Diffstat (limited to 'src/tag')
-rw-r--r--src/tag/TagString.cxx16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/tag/TagString.cxx b/src/tag/TagString.cxx
index a519080b4..0c3868eb5 100644
--- a/src/tag/TagString.cxx
+++ b/src/tag/TagString.cxx
@@ -21,12 +21,16 @@
#include "TagString.hxx"
#include "util/Alloc.hxx"
+#ifdef HAVE_GLIB
#include <glib.h>
+#endif
#include <assert.h>
#include <string.h>
#include <stdlib.h>
+#ifdef HAVE_GLIB
+
/**
* Replace invalid sequences with the question mark.
*/
@@ -72,6 +76,8 @@ fix_utf8(const char *str, size_t length)
return patch_utf8(str, length, end);
}
+#endif
+
static bool
char_is_non_printable(unsigned char ch)
{
@@ -113,19 +119,23 @@ clear_non_printable(const char *p, size_t length)
char *
FixTagString(const char *p, size_t length)
{
- char *utf8, *cleared;
+#ifdef HAVE_GLIB
+ // TODO: implement without GLib
- utf8 = fix_utf8(p, length);
+ char *utf8 = fix_utf8(p, length);
if (utf8 != nullptr) {
p = utf8;
length = strlen(p);
}
+#endif
- cleared = clear_non_printable(p, length);
+ char *cleared = clear_non_printable(p, length);
+#ifdef HAVE_GLIB
if (cleared == nullptr)
cleared = utf8;
else
free(utf8);
+#endif
return cleared;
}