From ae4fd576bfafca362c35b944cd6fde1d0360dcb2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 3 Apr 2020 16:46:48 +0200 Subject: [PATCH] output/ao: use IterableSplitString() instead of SplitString() --- src/output/plugins/AoOutputPlugin.cxx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/output/plugins/AoOutputPlugin.cxx b/src/output/plugins/AoOutputPlugin.cxx index f6561be2c..0fad45e88 100644 --- a/src/output/plugins/AoOutputPlugin.cxx +++ b/src/output/plugins/AoOutputPlugin.cxx @@ -22,7 +22,7 @@ #include "thread/SafeSingleton.hxx" #include "system/Error.hxx" #include "util/DivideString.hxx" -#include "util/SplitString.hxx" +#include "util/IterableSplitString.hxx" #include "util/RuntimeError.hxx" #include "util/Domain.hxx" #include "util/StringAPI.hxx" @@ -122,14 +122,16 @@ AoOutput::AoOutput(const ConfigBlock &block) value = block.GetBlockValue("options", nullptr); if (value != nullptr) { - for (const auto &i : SplitString(value, ';')) { - const DivideString ss(i.c_str(), '=', true); + for (StringView i : IterableSplitString(value, ';')) { + i.Strip(); - if (!ss.IsDefined()) - throw FormatRuntimeError("problems parsing options \"%s\"", - i.c_str()); + auto s = i.Split('='); + if (s.first.empty() || s.second.IsNull()) + throw FormatRuntimeError("problems parsing option \"%.*s\"", + int(i.size), i.data); - ao_append_option(&options, ss.GetFirst(), ss.GetSecond()); + const std::string n(s.first), v(s.second); + ao_append_option(&options, n.c_str(), v.c_str()); } } }