summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-01-04 23:06:18 (GMT)
committerEvan Martin <martine@danga.com>2012-01-04 23:06:18 (GMT)
commita0c058f792c9b2d8f2e86bcdee718410b008e29c (patch)
tree4635b57369d593b1525a0b1ed7ac437be219d625 /src
parent30b144cb5ea67dac3248291293cd6197cd6e7f4f (diff)
parentc74e70c2d865be8fc19affb390ea0704fa3eea50 (diff)
downloadNinja-a0c058f792c9b2d8f2e86bcdee718410b008e29c.zip
Ninja-a0c058f792c9b2d8f2e86bcdee718410b008e29c.tar.gz
Ninja-a0c058f792c9b2d8f2e86bcdee718410b008e29c.tar.bz2
Merge pull request #175 from nornagon/escape-in-out
When expanding $in and $out, wrap with quotes if the filename has a space.
Diffstat (limited to 'src')
-rw-r--r--src/graph.cc9
-rw-r--r--src/graph_test.cc9
2 files changed, 17 insertions, 1 deletions
diff --git a/src/graph.cc b/src/graph.cc
index 9f7fc76..ed7097b 100644
--- a/src/graph.cc
+++ b/src/graph.cc
@@ -189,7 +189,14 @@ string EdgeEnv::MakePathList(vector<Node*>::iterator begin,
for (vector<Node*>::iterator i = begin; i != end; ++i) {
if (!result.empty())
result.push_back(' ');
- result.append((*i)->path());
+ const string& path = (*i)->path();
+ if (path.find(" ") != string::npos) {
+ result.append("\"");
+ result.append(path);
+ result.append("\"");
+ } else {
+ result.append(path);
+ }
}
return result;
}
diff --git a/src/graph_test.cc b/src/graph_test.cc
index c1a0f93..07a1936 100644
--- a/src/graph_test.cc
+++ b/src/graph_test.cc
@@ -131,3 +131,12 @@ TEST_F(GraphTest, RootNodes) {
EXPECT_EQ("out", name.substr(0, 3));
}
}
+
+TEST_F(GraphTest, VarInOutQuoteSpaces) {
+ ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
+"build a$ b: cat nospace with$ space nospace2\n"));
+
+ Edge* edge = GetNode("a b")->in_edge();
+ EXPECT_EQ("cat nospace \"with space\" nospace2 > \"a b\"",
+ edge->EvaluateCommand());
+}