From 720f9f6af3915cfa55d07cb3da72e897f46851a5 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 24 Sep 2018 15:50:33 +0200 Subject: Escape special characters ninja way --- src/Ninja.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Ninja.cpp b/src/Ninja.cpp index 778e701..70b0b57 100644 --- a/src/Ninja.cpp +++ b/src/Ninja.cpp @@ -78,12 +78,18 @@ namespace ninja result.reserve(str.size()); for(char c : str) { - if(c == '"') - result += "\\\""; + if(c == '\n') + result += "$\n"; + else if(c == '$') + result += "$$"; + else if(c == ' ') + result += "$ "; + else if(c == ':') + result += "$:"; else result += c; } - return '"' + result + '"'; + return result; } static std::string combine_escape(const std::vector &strs) -- cgit v1.2.3