From d595ded1a9f0ea29a526f62facb74cf30e8fd3b2 Mon Sep 17 00:00:00 2001 From: Raihaan Shouhell Date: Fri, 23 Dec 2022 17:52:45 +0800 Subject: [PATCH] fix: Do not escape backslashes in MSVC RSP files (#1233) --- src/Args.cpp | 2 +- unittest/test_Args.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Args.cpp b/src/Args.cpp index 50cfa672a..da041bcb8 100644 --- a/src/Args.cpp +++ b/src/Args.cpp @@ -77,7 +77,7 @@ Args::from_atfile(const std::string& filename, AtFileFormat format) } break; case AtFileFormat::msvc: - if (*pos != '"' && *pos != '\\') { + if (*pos != '"') { pos--; } break; diff --git a/unittest/test_Args.cpp b/unittest/test_Args.cpp index 8ae2470c7..f5d9ae7b2 100644 --- a/unittest/test_Args.cpp +++ b/unittest/test_Args.cpp @@ -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") -- 2.47.2