]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
enhance: Add util::Args::parse_response_file_content function
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 15 Mar 2026 09:04:10 +0000 (10:04 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 15 Mar 2026 10:18:53 +0000 (11:18 +0100)
src/ccache/util/args.cpp
src/ccache/util/args.hpp

index a3d081e153ea35a552ca8758ce354fb719dbb530..2dda18d02981033b986e85c64592e58b7c72dfa5 100644 (file)
@@ -66,10 +66,19 @@ Args::from_response_file(const std::string& filename, ResponseFileFormat format)
     return std::nullopt;
   }
 
+  return parse_response_file_content(*argtext, format);
+}
+
+Args
+Args::parse_response_file_content(const std::string& content,
+                                  ResponseFileFormat format)
+{
+  ASSERT(format != ResponseFileFormat::auto_guess);
+
   Args args;
-  auto pos = argtext->c_str();
+  auto pos = content.c_str();
   std::string argbuf;
-  argbuf.resize(argtext->length() + 1);
+  argbuf.resize(content.length() + 1);
   auto argpos = argbuf.data();
 
   // Used to track quoting state; if \0 we are not inside quotes. Otherwise
index 7854942443a26e854b2c1b33389e7048d0af026a..633002a00513db87ed7ccab68ae0b5d866812810 100644 (file)
@@ -47,6 +47,8 @@ public:
 
   static std::optional<Args> from_response_file(const std::string& filename,
                                                 ResponseFileFormat format);
+  static Args parse_response_file_content(const std::string& content,
+                                          ResponseFileFormat format);
 
   Args& operator=(const Args& other) = default;
   Args& operator=(Args&& other) noexcept;