From: Thomas Otto Date: Thu, 19 Mar 2020 21:47:19 +0000 (+0100) Subject: Adapt hash_command_output() to use split_into_strings() X-Git-Tag: v4.0~547^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=800983d94aca077b17d871128c64a2836bcd5f1c;p=thirdparty%2Fccache.git Adapt hash_command_output() to use split_into_strings() --- diff --git a/src/hashutil.cpp b/src/hashutil.cpp index 0e13b00cc..f9c092004 100644 --- a/src/hashutil.cpp +++ b/src/hashutil.cpp @@ -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; }