From 7583f7490e23e025d9072533990f7cd9fec4b61d Mon Sep 17 00:00:00 2001 From: Yan Pashkovsky Date: Fri, 14 Dec 2018 18:23:20 +0300 Subject: cmGlobalGenerator: Teach EscapeJSON to escape newlines and tabs --- Source/cmGlobalGenerator.cxx | 18 +++++++++++++++--- 1 file 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; } -- cgit v0.12 From 37c6a02dc27154881c8b6b03beb7a17528ed5907 Mon Sep 17 00:00:00 2001 From: Yan Pashkovsky Date: Fri, 14 Dec 2018 18:23:53 +0300 Subject: CMake: fix nmake compile_commands generation --- Source/cmMakefileTargetGenerator.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 9acae49..0ea9724 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -687,6 +687,17 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( std::string langIncludes = std::string("$(") + lang + "_INCLUDES)"; compileCommand.replace(compileCommand.find(langIncludes), langIncludes.size(), this->GetIncludes(lang)); + + const char* eliminate[] = { + this->Makefile->GetDefinition("CMAKE_START_TEMP_FILE"), + this->Makefile->GetDefinition("CMAKE_END_TEMP_FILE") + }; + for (const char* el : eliminate) { + if (el) { + cmSystemTools::ReplaceString(compileCommand, el, ""); + } + } + this->GlobalGenerator->AddCXXCompileCommand( source.GetFullPath(), workingDirectory, compileCommand); } -- cgit v0.12