summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorYan Pashkovsky <yanp.bugz@gmail.com>2018-12-14 15:23:20 (GMT)
committerYan Pashkovsky <yanp.bugz@gmail.com>2018-12-14 15:23:20 (GMT)
commit7583f7490e23e025d9072533990f7cd9fec4b61d (patch)
treeb97124c3f4c02c9e4b0a6200fbf8c3d7aa6f43ea /Source/cmGlobalGenerator.cxx
parent1763f0428193cd6e28af4e49131516299acdf3b7 (diff)
downloadCMake-7583f7490e23e025d9072533990f7cd9fec4b61d.zip
CMake-7583f7490e23e025d9072533990f7cd9fec4b61d.tar.gz
CMake-7583f7490e23e025d9072533990f7cd9fec4b61d.tar.bz2
cmGlobalGenerator: Teach EscapeJSON to escape newlines and tabs
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx18
1 files changed, 15 insertions, 3 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 2805395..9326e5f 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -3014,11 +3014,23 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
std::string cmGlobalGenerator::EscapeJSON(const std::string& s)
{
std::string result;
+ result.reserve(s.size());
for (char i : s) {
- if (i == '"' || i == '\\') {
- result += '\\';
+ switch (i) {
+ case '"':
+ case '\\':
+ result += '\\';
+ result += i;
+ break;
+ case '\n':
+ result += "\\n";
+ break;
+ case '\t':
+ result += "\\t";
+ break;
+ default:
+ result += i;
}
- result += i;
}
return result;
}