From: Thomas Otto Date: Tue, 3 Mar 2020 22:19:44 +0000 (+0100) Subject: Adapt args_init_from_string() to use split_into_strings() X-Git-Tag: v4.0~547^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=34e520ec5325561df95ea605cbe4060974a951a5;p=thirdparty%2Fccache.git Adapt args_init_from_string() to use split_into_strings() --- diff --git a/src/Args.cpp b/src/Args.cpp index 639c143b6..dc0b19bfd 100644 --- a/src/Args.cpp +++ b/src/Args.cpp @@ -18,6 +18,8 @@ #include "Args.hpp" +#include "Util.hpp" + Args::Args() : argv(m_args) { } @@ -41,17 +43,10 @@ Args::from_argv(int argc, const char* const* argv) Args Args::from_string(const std::string& command) { - char* p = x_strdup(command.c_str()); - char* q = p; - char* word; - char* saveptr = NULL; Args args; - while ((word = strtok_r(q, " \t\r\n", &saveptr))) { + for (const std::string& word : Util::split_into_strings(command, " \t\r\n")) { args.push_back(word); - q = NULL; } - - free(p); return args; }