summaryrefslogtreecommitdiffstats
path: root/src/manifest_parser.cc
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2013-07-11 00:30:16 (GMT)
committerNico Weber <thakis@chromium.org>2013-07-11 00:30:16 (GMT)
commitadaa91a33eb2cf23b88333b5cc2e2e456a5f1803 (patch)
treeff3784aac139353a1ab833e70cbcd9d83a4bca15 /src/manifest_parser.cc
parent699d678774bfae538f3f555abd6ac3d91e968f52 (diff)
downloadNinja-adaa91a33eb2cf23b88333b5cc2e2e456a5f1803.zip
Ninja-adaa91a33eb2cf23b88333b5cc2e2e456a5f1803.tar.gz
Ninja-adaa91a33eb2cf23b88333b5cc2e2e456a5f1803.tar.bz2
Reuse ManifestParser::Load() in ManifestParser::ParseFileInclude().
ParseFileInclude() was doing the work that Load() was doing. Instead, just make it call Load(). Also, remove a FIXME about using ReadPath() in ParseFileInclude() -- it's already being used. (The FIXME was added in the same commit that added the call to ReadPath() -- 8a0c96075786c19 -- it probably should've been deleted before that commit.) Also, remove a `contents.resize(contents.size() + 10);`. It's not clear what it's for, but if it was important then ManifestParser::ParseFileInclude() would have needed that call too, and it didn't have it. No intended behavior change.
Diffstat (limited to 'src/manifest_parser.cc')
-rw-r--r--src/manifest_parser.cc12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/manifest_parser.cc b/src/manifest_parser.cc
index d4f0007..88c16ab 100644
--- a/src/manifest_parser.cc
+++ b/src/manifest_parser.cc
@@ -28,6 +28,7 @@ ManifestParser::ManifestParser(State* state, FileReader* file_reader)
: state_(state), file_reader_(file_reader) {
env_ = &state->bindings_;
}
+
bool ManifestParser::Load(const string& filename, string* err) {
string contents;
string read_err;
@@ -35,7 +36,6 @@ bool ManifestParser::Load(const string& filename, string* err) {
*err = "loading '" + filename + "': " + read_err;
return false;
}
- contents.resize(contents.size() + 10);
return Parse(filename, contents, err);
}
@@ -338,17 +338,11 @@ bool ManifestParser::ParseEdge(string* err) {
}
bool ManifestParser::ParseFileInclude(bool new_scope, string* err) {
- // XXX this should use ReadPath!
EvalString eval;
if (!lexer_.ReadPath(&eval, err))
return false;
string path = eval.Evaluate(env_);
- string contents;
- string read_err;
- if (!file_reader_->ReadFile(path, &contents, &read_err))
- return lexer_.Error("loading '" + path + "': " + read_err, err);
-
ManifestParser subparser(state_, file_reader_);
if (new_scope) {
subparser.env_ = new BindingEnv(env_);
@@ -356,8 +350,8 @@ bool ManifestParser::ParseFileInclude(bool new_scope, string* err) {
subparser.env_ = env_;
}
- if (!subparser.Parse(path, contents, err))
- return false;
+ if (!subparser.Load(path, err))
+ return lexer_.Error(string(*err), err);
if (!ExpectToken(Lexer::NEWLINE, err))
return false;