aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-09-24 15:50:33 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:28:02 +0200
commit720f9f6af3915cfa55d07cb3da72e897f46851a5 (patch)
tree9e247f7bf527c1d9f24421ab213f2217c4222b54 /src
parentd45e007aa8aee275904015bee5c114e95209a6db (diff)
Escape special characters ninja way
Diffstat (limited to 'src')
-rw-r--r--src/Ninja.cpp12
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)