]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Adapt args_init_from_string() to use split_into_strings()
authorThomas Otto <thomas.otto@pdv-fs.de>
Tue, 3 Mar 2020 22:19:44 +0000 (23:19 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 16 Apr 2020 20:33:39 +0000 (22:33 +0200)
src/Args.cpp

index 639c143b68445b8c331afd9c282cfc92d94b8fce..dc0b19bfddc367184b46206f63e531aa58cc883a 100644 (file)
@@ -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;
 }