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

index f93bc2f15ec43fcfb7bf279493ee8bad829f7731..530f116d1e97c15ef2a40a24618d2da9da41329f 100644 (file)
@@ -679,17 +679,14 @@ process_preprocessed_file(Context& ctx,
 
   ctx.ignore_headers = nullptr;
   ctx.ignore_headers_len = 0;
+
   if (!ctx.config.ignore_headers_in_manifest().empty()) {
-    char *header, *p, *q, *saveptr = nullptr;
-    p = x_strdup(ctx.config.ignore_headers_in_manifest().c_str());
-    q = p;
-    while ((header = strtok_r(q, PATH_DELIM, &saveptr))) {
+    for (const std::string& header : Util::split_into_strings(
+           ctx.config.ignore_headers_in_manifest(), PATH_DELIM)) {
       ctx.ignore_headers = static_cast<char**>(x_realloc(
         ctx.ignore_headers, (ctx.ignore_headers_len + 1) * sizeof(char*)));
-      ctx.ignore_headers[ctx.ignore_headers_len++] = x_strdup(header);
-      q = nullptr;
+      ctx.ignore_headers[ctx.ignore_headers_len++] = x_strdup(header.c_str());
     }
-    free(p);
   }
 
   // Bytes between p and q are pending to be hashed.