]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Do not escape backslashes in MSVC RSP files (#1233)
authorRaihaan Shouhell <raihaanhimself@gmail.com>
Fri, 23 Dec 2022 09:52:45 +0000 (17:52 +0800)
committerGitHub <noreply@github.com>
Fri, 23 Dec 2022 09:52:45 +0000 (10:52 +0100)
src/Args.cpp
unittest/test_Args.cpp

index 50cfa672a82fb24de15a4af54b277c790fbe42fa..da041bcb850c574b3babb99a34129efb46bc9719 100644 (file)
@@ -77,7 +77,7 @@ Args::from_atfile(const std::string& filename, AtFileFormat format)
         }
         break;
       case AtFileFormat::msvc:
-        if (*pos != '"' && *pos != '\\') {
+        if (*pos != '"') {
           pos--;
         }
         break;
index 8ae2470c7199be4f1559d2fea546572da477fb6e..f5d9ae7b2dfd60bfe2b39f575f9d8468fd4cafbe 100644 (file)
@@ -139,12 +139,12 @@ TEST_CASE("Args::from_atfile")
     CHECK(args[6] == "seve\nth");
   }
 
-  SUBCASE("Only escape double quote and backslash in alternate format")
+  SUBCASE("Only escape double quote in alternate format")
   {
-    util::write_file("at_file", "\"\\\"\\a\\ \\\\\\ \\b\\\"\"\\");
+    util::write_file("at_file", "\"\\\"\\a\\ \\b\\\"\"\\");
     args = *Args::from_atfile("at_file", Args::AtFileFormat::msvc);
     CHECK(args.size() == 1);
-    CHECK(args[0] == "\"\\a\\ \\\\ \\b\"\\");
+    CHECK(args[0] == "\"\\a\\ \\b\"\\");
   }
 
   SUBCASE("Ignore single quote in alternate format")
@@ -155,6 +155,14 @@ TEST_CASE("Args::from_atfile")
     CHECK(args[0] == "'a");
     CHECK(args[1] == "b'");
   }
+
+  SUBCASE("Do not escape backslash in alternate format")
+  {
+    util::write_file("at_file", "\"-DDIRSEP='\\\\'\"");
+    args = *Args::from_atfile("at_file", Args::AtFileFormat::msvc);
+    CHECK(args.size() == 1);
+    CHECK(args[0] == "-DDIRSEP='\\\\'");
+  }
 }
 
 TEST_CASE("Args copy assignment operator")