diff options
author | Craig Scott <craig.scott@crascit.com> | 2019-01-07 20:26:44 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-01-07 20:26:55 (GMT) |
commit | 6f904d01009bf26d129b2a2f0335e99bf30732ac (patch) | |
tree | 30ce374928957ab17d5ed1bc7ba89fad25c0e78c /Source/cmGlobalGenerator.cxx | |
parent | c1e9b1c283caccd468adfafd0496edd63964b899 (diff) | |
parent | 37c6a02dc27154881c8b6b03beb7a17528ed5907 (diff) | |
download | CMake-6f904d01009bf26d129b2a2f0335e99bf30732ac.zip CMake-6f904d01009bf26d129b2a2f0335e99bf30732ac.tar.gz CMake-6f904d01009bf26d129b2a2f0335e99bf30732ac.tar.bz2 |
Merge topic 'nmake-compile-commands'
37c6a02dc2 CMake: fix nmake compile_commands generation
7583f7490e cmGlobalGenerator: Teach EscapeJSON to escape newlines and tabs
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2648
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 35d716c..47c53e7 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -3023,11 +3023,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; } |