diff options
author | dec05eba <0xdec05eba@gmail.com> | 2018-09-24 15:50:33 +0200 |
---|---|---|
committer | dec05eba <0xdec05eba@gmail.com> | 2018-09-24 15:50:34 +0200 |
commit | f414fe587cef52cb8ff2b73a320ee0ce481170b6 (patch) | |
tree | 3cc7477e00a049998aab4eb98998b441564a9db4 | |
parent | 0ebcfc62e435d352b4a2035ac1791b867228194d (diff) |
Escape special characters ninja way
-rw-r--r-- | src/Ninja.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
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<std::string> &strs) |