From 8275db66871e4d5ef58a3e9b4ab1fad52cab840b Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 22 May 2019 15:13:10 +0200 Subject: [PATCH] Remove leading and trailing spaces from tags. --- src/parse_options.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/parse_options.cpp b/src/parse_options.cpp index f860b0f..66005ea 100644 --- a/src/parse_options.cpp +++ b/src/parse_options.cpp @@ -99,8 +99,16 @@ const options parse_options(const int argc, const char *argv[]) while (pos_end != std::string::npos) { pos_end = tags.find(',', pos_start); - opts.tags.push_back - (tags.substr(pos_start, pos_end - pos_start)); + string buffer = tags.substr(pos_start, pos_end - pos_start); + while (*buffer.begin() == ' ') // Remove leading spaces. + { + buffer.erase(buffer.begin()); + } + while (*buffer.rbegin() == ' ') // Remove trailing spaces. + { + buffer.erase(buffer.end() - 1); + } + opts.tags.push_back(buffer); pos_start = pos_end + 1; } }