diff options
author | Max Kellermann <max@duempel.org> | 2013-10-19 16:34:11 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-10-19 16:34:11 +0200 |
commit | d3f28a1d7f6ccd3274b648001a55d8a327657beb (patch) | |
tree | 3183189644797960a61d66dc58df365e4371243d | |
parent | 03cddd0acf481f34709e7a1b061d4d451b09285a (diff) | |
download | mpd-d3f28a1d7f6ccd3274b648001a55d8a327657beb.tar.gz mpd-d3f28a1d7f6ccd3274b648001a55d8a327657beb.tar.xz mpd-d3f28a1d7f6ccd3274b648001a55d8a327657beb.zip |
FilterConfig: use std::find instead of g_strsplit_set()
-rw-r--r-- | src/FilterConfig.cxx | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/FilterConfig.cxx b/src/FilterConfig.cxx index 0b0509af3..a52cf44b7 100644 --- a/src/FilterConfig.cxx +++ b/src/FilterConfig.cxx @@ -29,7 +29,7 @@ #include "ConfigError.hxx" #include "util/Error.hxx" -#include <glib.h> +#include <algorithm> #include <string.h> @@ -89,22 +89,22 @@ filter_chain_append_new(Filter &chain, const char *template_name, Error &error) bool filter_chain_parse(Filter &chain, const char *spec, Error &error) { - // Split on comma - gchar** tokens = g_strsplit_set(spec, ",", 255); - - // Add each name to the filter chain by instantiating an actual filter - char **template_names = tokens; - while (*template_names != NULL) { - // Squeeze whitespace - g_strstrip(*template_names); + const char *const end = spec + strlen(spec); + + while (true) { + const char *comma = std::find(spec, end, ','); + if (comma > spec) { + const std::string name(spec, comma); + if (!filter_chain_append_new(chain, name.c_str(), + error)) + return false; + } - if (!filter_chain_append_new(chain, *template_names, error)) - return false; + if (comma == end) + break; - ++template_names; + spec = comma + 1; } - g_strfreev(tokens); - return true; } |