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

index 1d15bf6354c9b9ac37b17fcee25e80b04e74d60a..29f15a1e23d0bb9fa2c52279011760544bd4101f 100644 (file)
@@ -1625,19 +1625,14 @@ hash_common_info(const Context& ctx,
   }
 
   if (!ctx.config.extra_files_to_hash().empty()) {
-    char* p = x_strdup(ctx.config.extra_files_to_hash().c_str());
-    char* q = p;
-    char* path;
-    char* saveptr = nullptr;
-    while ((path = strtok_r(q, PATH_DELIM, &saveptr))) {
-      cc_log("Hashing extra file %s", path);
+    for (const std::string& path : Util::split_into_strings(
+           ctx.config.extra_files_to_hash(), PATH_DELIM)) {
+      cc_log("Hashing extra file %s", path.c_str());
       hash_delimiter(hash, "extrafile");
-      if (!hash_file(hash, path)) {
+      if (!hash_file(hash, path.c_str())) {
         failed(STATS_BADEXTRAFILE);
       }
-      q = nullptr;
     }
-    free(p);
   }
 
   // Possibly hash GCC_COLORS (for color diagnostics).