diff options
author | Evan Martin <martine@danga.com> | 2012-09-04 23:00:07 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2012-09-04 23:01:27 (GMT) |
commit | f9d9daded0a351ac4311d57d9e806ae1e4208ce3 (patch) | |
tree | d90fcaa715bf2a035a1325543fcbe99807c1d603 /src/ninja.cc | |
parent | a737983697db99a27b4a2a5d8b25da2d54c03ea2 (diff) | |
download | Ninja-f9d9daded0a351ac4311d57d9e806ae1e4208ce3.zip Ninja-f9d9daded0a351ac4311d57d9e806ae1e4208ce3.tar.gz Ninja-f9d9daded0a351ac4311d57d9e806ae1e4208ce3.tar.bz2 |
reduce indent
Diffstat (limited to 'src/ninja.cc')
-rw-r--r-- | src/ninja.cc | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/src/ninja.cc b/src/ninja.cc index 52a470f..8d1c710 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -145,51 +145,50 @@ bool CollectTargetsFromArgs(State* state, int argc, char* argv[], vector<Node*>* targets, string* err) { if (argc == 0) { *targets = state->DefaultNodes(err); - if (!err->empty()) + return err->empty(); + } + + for (int i = 0; i < argc; ++i) { + string path = argv[i]; + if (!CanonicalizePath(&path, err)) return false; - } else { - for (int i = 0; i < argc; ++i) { - string path = argv[i]; - if (!CanonicalizePath(&path, err)) - return false; - - // Special syntax: "foo.cc^" means "the first output of foo.cc". - bool first_dependent = false; - if (!path.empty() && path[path.size() - 1] == '^') { - path.resize(path.size() - 1); - first_dependent = true; - } - Node* node = state->LookupNode(path); - if (node) { - if (first_dependent) { - if (node->out_edges().empty()) { - *err = "'" + path + "' has no out edge"; - return false; - } - Edge* edge = node->out_edges()[0]; - if (edge->outputs_.empty()) { - edge->Dump(); - Fatal("edge has no outputs"); - } - node = edge->outputs_[0]; + // Special syntax: "foo.cc^" means "the first output of foo.cc". + bool first_dependent = false; + if (!path.empty() && path[path.size() - 1] == '^') { + path.resize(path.size() - 1); + first_dependent = true; + } + + Node* node = state->LookupNode(path); + if (node) { + if (first_dependent) { + if (node->out_edges().empty()) { + *err = "'" + path + "' has no out edge"; + return false; + } + Edge* edge = node->out_edges()[0]; + if (edge->outputs_.empty()) { + edge->Dump(); + Fatal("edge has no outputs"); } - targets->push_back(node); + node = edge->outputs_[0]; + } + targets->push_back(node); + } else { + *err = "unknown target '" + path + "'"; + + if (path == "clean") { + *err += ", did you mean 'ninja -t clean'?"; + } else if (path == "help") { + *err += ", did you mean 'ninja -h'?"; } else { - *err = "unknown target '" + path + "'"; - - if (path == "clean") { - *err += ", did you mean 'ninja -t clean'?"; - } else if (path == "help") { - *err += ", did you mean 'ninja -h'?"; - } else { - Node* suggestion = state->SpellcheckNode(path); - if (suggestion) { - *err += ", did you mean '" + suggestion->path() + "'?"; - } + Node* suggestion = state->SpellcheckNode(path); + if (suggestion) { + *err += ", did you mean '" + suggestion->path() + "'?"; } - return false; } + return false; } } return true; |