diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-07-28 12:39:03 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-07-28 15:47:26 (GMT) |
commit | 6675f785bec2d777720abbdc062f514bd838b879 (patch) | |
tree | 15fbabf02891fb27aee22ad032ef9238f369f3f4 /Source/cmOutputConverter.cxx | |
parent | 09977c181641dd4feea8fc13bf718f0f9cfe05bb (diff) | |
download | CMake-6675f785bec2d777720abbdc062f514bd838b879.zip CMake-6675f785bec2d777720abbdc062f514bd838b879.tar.gz CMake-6675f785bec2d777720abbdc062f514bd838b879.tar.bz2 |
cmOutputConverter: Let EscapeForCMake accept a cm::string_view
Diffstat (limited to 'Source/cmOutputConverter.cxx')
-rw-r--r-- | Source/cmOutputConverter.cxx | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index d7bcf7e..55d9bd6 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -120,23 +120,23 @@ std::string cmOutputConverter::EscapeForShell(const std::string& str, return Shell__GetArgument(str.c_str(), flags); } -std::string cmOutputConverter::EscapeForCMake(const std::string& str) +std::string cmOutputConverter::EscapeForCMake(cm::string_view str) { // Always double-quote the argument to take care of most escapes. std::string result = "\""; - for (const char* c = str.c_str(); *c; ++c) { - if (*c == '"') { + for (const char c : str) { + if (c == '"') { // Escape the double quote to avoid ending the argument. result += "\\\""; - } else if (*c == '$') { + } else if (c == '$') { // Escape the dollar to avoid expanding variables. result += "\\$"; - } else if (*c == '\\') { + } else if (c == '\\') { // Escape the backslash to avoid other escapes. result += "\\\\"; } else { // Other characters will be parsed correctly. - result += *c; + result += c; } } result += "\""; |