diff options
author | Brad King <brad.king@kitware.com> | 2018-10-08 13:01:59 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-11-19 15:18:24 (GMT) |
commit | 94f4153da9dd2ad0c166568f273e9ba2f4928554 (patch) | |
tree | 9141a1ac19e94c8f37e68aa8884472b8533a692b | |
parent | a02132dac456875f395614bbc4cc2931a9ac409f (diff) | |
download | Ninja-94f4153da9dd2ad0c166568f273e9ba2f4928554.zip Ninja-94f4153da9dd2ad0c166568f273e9ba2f4928554.tar.gz Ninja-94f4153da9dd2ad0c166568f273e9ba2f4928554.tar.bz2 |
Re-arrange depfile parser token processing logic
Re-arrange the existing logic to support later addition of post-token
code even for empty tokens.
-rw-r--r-- | src/depfile_parser.cc | 21 | ||||
-rw-r--r-- | src/depfile_parser.in.cc | 21 |
2 files changed, 20 insertions, 22 deletions
diff --git a/src/depfile_parser.cc b/src/depfile_parser.cc index 24e374f..2ad2a00 100644 --- a/src/depfile_parser.cc +++ b/src/depfile_parser.cc @@ -175,22 +175,21 @@ yy15: } int len = (int)(out - filename); - const bool is_target = parsing_targets; + const bool is_dependency = !parsing_targets; if (len > 0 && filename[len - 1] == ':') { len--; // Strip off trailing colon, if any. parsing_targets = false; } - if (len == 0) - continue; - - if (!is_target) { - ins_.push_back(StringPiece(filename, len)); - } else if (!out_.str_) { - out_ = StringPiece(filename, len); - } else if (out_ != StringPiece(filename, len)) { - *err = "depfile has multiple output paths"; - return false; + if (len > 0) { + if (is_dependency) { + ins_.push_back(StringPiece(filename, len)); + } else if (!out_.str_) { + out_ = StringPiece(filename, len); + } else if (out_ != StringPiece(filename, len)) { + *err = "depfile has multiple output paths"; + return false; + } } } if (parsing_targets) { diff --git a/src/depfile_parser.in.cc b/src/depfile_parser.in.cc index 464efda..4df8ce2 100644 --- a/src/depfile_parser.in.cc +++ b/src/depfile_parser.in.cc @@ -94,22 +94,21 @@ bool DepfileParser::Parse(string* content, string* err) { } int len = (int)(out - filename); - const bool is_target = parsing_targets; + const bool is_dependency = !parsing_targets; if (len > 0 && filename[len - 1] == ':') { len--; // Strip off trailing colon, if any. parsing_targets = false; } - if (len == 0) - continue; - - if (!is_target) { - ins_.push_back(StringPiece(filename, len)); - } else if (!out_.str_) { - out_ = StringPiece(filename, len); - } else if (out_ != StringPiece(filename, len)) { - *err = "depfile has multiple output paths"; - return false; + if (len > 0) { + if (is_dependency) { + ins_.push_back(StringPiece(filename, len)); + } else if (!out_.str_) { + out_ = StringPiece(filename, len); + } else if (out_ != StringPiece(filename, len)) { + *err = "depfile has multiple output paths"; + return false; + } } } if (parsing_targets) { |