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

index 0e13b00ccf9dc7c711132e6c43266d7c84d1c155..f9c0920043b8ca4ad1d0c26fc04ab09cb8c95e63 100644 (file)
@@ -433,17 +433,11 @@ hash_multicommand_output(struct hash* hash,
                          const char* commands,
                          const char* compiler)
 {
-  char* command_string = x_strdup(commands);
-  char* p = command_string;
-  char* command;
-  char* saveptr = nullptr;
   bool ok = true;
-  while ((command = strtok_r(p, ";", &saveptr))) {
-    if (!hash_command_output(hash, command, compiler)) {
+  for (const std::string& cmd : Util::split_into_strings(commands, ";")) {
+    if (!hash_command_output(hash, cmd.c_str(), compiler)) {
       ok = false;
     }
-    p = nullptr;
   }
-  free(command_string);
   return ok;
 }