diff options
Diffstat (limited to 'src/graph.cc')
-rw-r--r-- | src/graph.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/graph.cc b/src/graph.cc index f381d8a..5418ecf 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -183,20 +183,23 @@ struct EdgeEnv : public Env { /// Given a span of Nodes, construct a list of paths suitable for a command /// line. XXX here is where shell-escaping of e.g spaces should happen. string MakePathList(vector<Node*>::iterator begin, - vector<Node*>::iterator end); + vector<Node*>::iterator end, + char sep); Edge* edge_; }; string EdgeEnv::LookupVariable(const string& var) { - if (var == "in") { + if (var == "in" || var == "in_newline") { int explicit_deps_count = edge_->inputs_.size() - edge_->implicit_deps_ - edge_->order_only_deps_; return MakePathList(edge_->inputs_.begin(), - edge_->inputs_.begin() + explicit_deps_count); + edge_->inputs_.begin() + explicit_deps_count, + var == "in" ? ' ' : '\n'); } else if (var == "out") { return MakePathList(edge_->outputs_.begin(), - edge_->outputs_.end()); + edge_->outputs_.end(), + ' '); } else if (edge_->env_) { return edge_->env_->LookupVariable(var); } else { @@ -206,11 +209,12 @@ string EdgeEnv::LookupVariable(const string& var) { } string EdgeEnv::MakePathList(vector<Node*>::iterator begin, - vector<Node*>::iterator end) { + vector<Node*>::iterator end, + char sep) { string result; for (vector<Node*>::iterator i = begin; i != end; ++i) { if (!result.empty()) - result.push_back(' '); + result.push_back(sep); const string& path = (*i)->path(); if (path.find(" ") != string::npos) { result.append("\""); |