summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-11-10 14:15:19 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-11-10 14:15:38 (GMT)
commit19b51730b7bd9b1325f4f124dcda90effaf4a221 (patch)
tree261b168c5da5f896baed88cd1ccacb9b04c14b0b
parent54682983cbcf0257f76273ce3fa9600caa8c0e94 (diff)
parent144e8dcf404893f10febf97744cbbcab96b88586 (diff)
downloadCMake-19b51730b7bd9b1325f4f124dcda90effaf4a221.zip
CMake-19b51730b7bd9b1325f4f124dcda90effaf4a221.tar.gz
CMake-19b51730b7bd9b1325f4f124dcda90effaf4a221.tar.bz2
Merge topic 'quote-hyphen-in-rsp'
144e8dcf40 cmOutputConverter: Quote hyphens in response files Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !6714
-rw-r--r--Source/cmOutputConverter.cxx20
-rw-r--r--Source/cmOutputConverter.h5
2 files changed, 20 insertions, 5 deletions
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index 02b4821..4503038 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -143,7 +143,7 @@ std::string cmOutputConverter::ConvertToOutputFormat(cm::string_view source,
result = this->EscapeForShell(result, true, false, output == WATCOMQUOTE,
output == NINJAMULTI);
} else if (output == RESPONSE) {
- result = this->EscapeForShell(result, false, false, false);
+ result = this->EscapeForShell(result, false, false, false, false, true);
}
return result;
}
@@ -175,9 +175,11 @@ static bool cmOutputConverterIsShellOperator(cm::string_view str)
return (shellOperators.count(str) != 0);
}
-std::string cmOutputConverter::EscapeForShell(
- cm::string_view str, bool makeVars, bool forEcho, bool useWatcomQuote,
- bool unescapeNinjaConfiguration) const
+std::string cmOutputConverter::EscapeForShell(cm::string_view str,
+ bool makeVars, bool forEcho,
+ bool useWatcomQuote,
+ bool unescapeNinjaConfiguration,
+ bool forResponse) const
{
// Do not escape shell operators.
if (cmOutputConverterIsShellOperator(str)) {
@@ -203,6 +205,9 @@ std::string cmOutputConverter::EscapeForShell(
if (useWatcomQuote) {
flags |= Shell_Flag_WatcomQuote;
}
+ if (forResponse) {
+ flags |= Shell_Flag_IsResponse;
+ }
if (this->GetState()->UseWatcomWMake()) {
flags |= Shell_Flag_WatcomWMake;
}
@@ -360,6 +365,13 @@ bool cmOutputConverter::Shell_CharNeedsQuotes(char c, int flags)
return true;
}
+ /* Quote hyphens in response files */
+ if (flags & Shell_Flag_IsResponse) {
+ if (c == '-') {
+ return true;
+ }
+ }
+
if (flags & Shell_Flag_IsUnix) {
/* On UNIX several special characters need quotes to preserve them. */
if (Shell_CharNeedsQuotesOnUnix(c)) {
diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h
index 53ec247..335442d 100644
--- a/Source/cmOutputConverter.h
+++ b/Source/cmOutputConverter.h
@@ -88,11 +88,14 @@ public:
Shell_Flag_IsUnix = (1 << 8),
Shell_Flag_UnescapeNinjaConfiguration = (1 << 9),
+
+ Shell_Flag_IsResponse = (1 << 10)
};
std::string EscapeForShell(cm::string_view str, bool makeVars = false,
bool forEcho = false, bool useWatcomQuote = false,
- bool unescapeNinjaConfiguration = false) const;
+ bool unescapeNinjaConfiguration = false,
+ bool forResponse = false) const;
enum class WrapQuotes
{