summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-01-27 16:11:03 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-01-27 16:11:11 (GMT)
commitb41b841cc6370a548bf193711a9b37e24b509605 (patch)
tree46746872152c1e9c069e350cadfd1ae0bd99338f /Source
parent6a9a0d98e27babd4301ff783fa9457f4f398ea69 (diff)
parent5c3f188beffb972571a011478ad5a28e89a186a3 (diff)
downloadCMake-b41b841cc6370a548bf193711a9b37e24b509605.zip
CMake-b41b841cc6370a548bf193711a9b37e24b509605.tar.gz
CMake-b41b841cc6370a548bf193711a9b37e24b509605.tar.bz2
Merge topic 'encode-literal-inplace'
5c3f188bef GlobalNinjaGenerator: Add EncodeLiteralInplace which doesn't copy Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6904
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx16
-rw-r--r--Source/cmGlobalNinjaGenerator.h1
2 files changed, 11 insertions, 6 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 5b85179..982b6af 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -166,14 +166,18 @@ std::string cmGlobalNinjaGenerator::EncodeRuleName(std::string const& name)
std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string& lit)
{
std::string result = lit;
- cmSystemTools::ReplaceString(result, "$", "$$");
- cmSystemTools::ReplaceString(result, "\n", "$\n");
+ EncodeLiteralInplace(result);
+ return result;
+}
+
+void cmGlobalNinjaGenerator::EncodeLiteralInplace(std::string& lit)
+{
+ cmSystemTools::ReplaceString(lit, "$", "$$");
+ cmSystemTools::ReplaceString(lit, "\n", "$\n");
if (this->IsMultiConfig()) {
- cmSystemTools::ReplaceString(result,
- cmStrCat('$', this->GetCMakeCFGIntDir()),
+ cmSystemTools::ReplaceString(lit, cmStrCat('$', this->GetCMakeCFGIntDir()),
this->GetCMakeCFGIntDir());
}
- return result;
}
std::string cmGlobalNinjaGenerator::EncodePath(const std::string& path)
@@ -185,7 +189,7 @@ std::string cmGlobalNinjaGenerator::EncodePath(const std::string& path)
else
std::replace(result.begin(), result.end(), '/', '\\');
#endif
- result = this->EncodeLiteral(result);
+ this->EncodeLiteralInplace(result);
cmSystemTools::ReplaceString(result, " ", "$ ");
cmSystemTools::ReplaceString(result, ":", "$:");
return result;
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index c619b2e..03387a8 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -78,6 +78,7 @@ public:
static std::string EncodeRuleName(std::string const& name);
std::string EncodeLiteral(const std::string& lit);
+ void EncodeLiteralInplace(std::string& lit);
std::string EncodePath(const std::string& path);
std::unique_ptr<cmLinkLineComputer> CreateLinkLineComputer(