src/graph.cc: fix EdgeEnv::LookupVariable
authorQingning Huo <qingninghuo@gmail.com>
Fri, 10 Jun 2011 23:13:33 +0000 (00:13 +0100)
committerQingning Huo <qingninghuo@gmail.com>
Fri, 10 Jun 2011 23:13:33 +0000 (00:13 +0100)
Make it return the correct value for "out" when there are multiple outputs.
It used to return only the first target file.

src/graph.cc

index 8abaa2a..13927fe 100644 (file)
@@ -105,7 +105,12 @@ struct EdgeEnv : public Env {
         result.append((*i)->file_->path_);
       }
     } else if (var == "out") {
-      result = edge_->outputs_[0]->file_->path_;
+      for (vector<Node*>::iterator i = edge_->outputs_.begin();
+           i != edge_->outputs_.end(); ++i) {
+        if (!result.empty())
+          result.push_back(' ');
+        result.append((*i)->file_->path_);
+      }
     } else if (edge_->env_) {
       return edge_->env_->LookupVariable(var);
     }