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
This commit is contained in:
Craig Scott
2019-01-07 20:26:44 +00:00
committed by Kitware Robot
2 changed files with 26 additions and 3 deletions
+15 -3
View File
@@ -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;
}