diff options
author | Max Kellermann <max@musicpd.org> | 2018-08-10 18:22:59 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-08-10 18:46:16 +0200 |
commit | 0f19108ce34ba523b2a652c10879c9e312155426 (patch) | |
tree | 65743074c988b7ca79652e174a6596e16d60b626 | |
parent | 4208fe29b540651c11b4812eedcc747df9d4f699 (diff) |
tag/Config: use SplitString()
-rw-r--r-- | src/tag/Config.cxx | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/src/tag/Config.cxx b/src/tag/Config.cxx index 07232f3f3..94899df14 100644 --- a/src/tag/Config.cxx +++ b/src/tag/Config.cxx @@ -23,12 +23,9 @@ #include "ParseName.hxx" #include "config/Data.hxx" #include "config/Option.hxx" -#include "util/Alloc.hxx" #include "util/ASCII.hxx" -#include "util/StringStrip.hxx" #include "util/RuntimeError.hxx" - -#include <stdlib.h> +#include "util/SplitString.hxx" void TagLoadConfig(const ConfigData &config) @@ -42,31 +39,14 @@ TagLoadConfig(const ConfigData &config) if (StringEqualsCaseASCII(value, "none")) return; - bool quit = false; - char *temp, *c, *s; - temp = c = s = xstrdup(value); - do { - if (*s == ',' || *s == '\0') { - if (*s == '\0') - quit = true; - *s = '\0'; - - c = Strip(c); - if (*c == 0) - continue; - - const auto type = tag_name_parse_i(c); - if (type == TAG_NUM_OF_ITEM_TYPES) - throw FormatRuntimeError("error parsing metadata item \"%s\"", - c); - - global_tag_mask |= type; + for (const auto &i : SplitString(value, ',')) { + const char *name = i.c_str(); - s++; - c = s; - } - s++; - } while (!quit); + const auto type = tag_name_parse_i(name); + if (type == TAG_NUM_OF_ITEM_TYPES) + throw FormatRuntimeError("error parsing metadata item \"%s\"", + name); - free(temp); + global_tag_mask |= type; + } } |