FilterConfig: use std::find instead of g_strsplit_set()

This commit is contained in:
Max Kellermann 2013-10-19 16:34:11 +02:00
parent 03cddd0acf
commit d3f28a1d7f

View File

@ -29,7 +29,7 @@
#include "ConfigError.hxx" #include "ConfigError.hxx"
#include "util/Error.hxx" #include "util/Error.hxx"
#include <glib.h> #include <algorithm>
#include <string.h> #include <string.h>
@ -89,22 +89,22 @@ filter_chain_append_new(Filter &chain, const char *template_name, Error &error)
bool bool
filter_chain_parse(Filter &chain, const char *spec, Error &error) filter_chain_parse(Filter &chain, const char *spec, Error &error)
{ {
// Split on comma const char *const end = spec + strlen(spec);
gchar** tokens = g_strsplit_set(spec, ",", 255);
// Add each name to the filter chain by instantiating an actual filter while (true) {
char **template_names = tokens; const char *comma = std::find(spec, end, ',');
while (*template_names != NULL) { if (comma > spec) {
// Squeeze whitespace const std::string name(spec, comma);
g_strstrip(*template_names); if (!filter_chain_append_new(chain, name.c_str(),
error))
if (!filter_chain_append_new(chain, *template_names, error))
return false; return false;
++template_names;
} }
g_strfreev(tokens); if (comma == end)
break;
spec = comma + 1;
}
return true; return true;
} }