aboutsummaryrefslogtreecommitdiffstats
path: root/src/path.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-10 18:06:21 +0100
committerMax Kellermann <max@duempel.org>2013-01-10 18:06:21 +0100
commitc02cc199bc75bf2a2f66c9535b31913c5c97fc1d (patch)
tree9c5636be967003c2754612fcf6abaf29ad352165 /src/path.c
parentdd6c21e0922f76b3ae821263677f1f3c559d1ed9 (diff)
downloadmpd-c02cc199bc75bf2a2f66c9535b31913c5c97fc1d.tar.gz
mpd-c02cc199bc75bf2a2f66c9535b31913c5c97fc1d.tar.xz
mpd-c02cc199bc75bf2a2f66c9535b31913c5c97fc1d.zip
path: move code to IsSupportedCharset()
Diffstat (limited to 'src/path.c')
-rw-r--r--src/path.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/path.c b/src/path.c
index 15277a40b..21a4dd41e 100644
--- a/src/path.c
+++ b/src/path.c
@@ -21,6 +21,7 @@
#include "path.h"
#include "conf.h"
#include "mpd_error.h"
+#include "gcc.h"
#include <glib.h>
@@ -60,18 +61,26 @@ utf8_to_fs_charset(const char *path_utf8)
return p;
}
+gcc_pure
+static bool
+IsSupportedCharset(const char *charset)
+{
+ /* convert a space to check if the charset is valid */
+ char *test = g_convert(" ", 1, charset, "UTF-8", NULL, NULL, NULL);
+ if (test == NULL)
+ return false;
+
+ g_free(test);
+ return true;
+}
+
static void
path_set_fs_charset(const char *charset)
{
- char *test;
-
assert(charset != NULL);
- /* convert a space to ensure that the charset is valid */
- test = g_convert(" ", 1, charset, "UTF-8", NULL, NULL, NULL);
- if (test == NULL)
+ if (!IsSupportedCharset(charset))
MPD_ERROR("invalid filesystem charset: %s", charset);
- g_free(test);
g_free(fs_charset);
fs_charset = g_strdup(charset);