summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2013-07-19 00:54:33 (GMT)
committerNico Weber <nicolasweber@gmx.de>2013-07-19 00:54:33 (GMT)
commit9bb715e1496572681815fad0142b32236cf6e987 (patch)
tree9eac6d5cdfea335060872251949384662a12b388
parent2430e5502b677e7b20135a133876265a0635a1bb (diff)
parenta2df2c7d491ca530e16c90d8f9f7012f08c2e0ae (diff)
downloadNinja-9bb715e1496572681815fad0142b32236cf6e987.zip
Ninja-9bb715e1496572681815fad0142b32236cf6e987.tar.gz
Ninja-9bb715e1496572681815fad0142b32236cf6e987.tar.bz2
Merge pull request #623 from nico/fix
Fix diagnostic formatting regression caused by adaa91a33eb2cf23b88.
-rw-r--r--src/manifest_parser.cc8
-rw-r--r--src/manifest_parser.h2
-rw-r--r--src/manifest_parser_test.cc11
3 files changed, 17 insertions, 4 deletions
diff --git a/src/manifest_parser.cc b/src/manifest_parser.cc
index a1bb904..20be7f3 100644
--- a/src/manifest_parser.cc
+++ b/src/manifest_parser.cc
@@ -29,12 +29,14 @@ ManifestParser::ManifestParser(State* state, FileReader* file_reader)
env_ = &state->bindings_;
}
-bool ManifestParser::Load(const string& filename, string* err) {
+bool ManifestParser::Load(const string& filename, string* err, Lexer* parent) {
METRIC_RECORD(".ninja parse");
string contents;
string read_err;
if (!file_reader_->ReadFile(filename, &contents, &read_err)) {
*err = "loading '" + filename + "': " + read_err;
+ if (parent)
+ parent->Error(string(*err), err);
return false;
}
@@ -358,8 +360,8 @@ bool ManifestParser::ParseFileInclude(bool new_scope, string* err) {
subparser.env_ = env_;
}
- if (!subparser.Load(path, err))
- return lexer_.Error(string(*err), err);
+ if (!subparser.Load(path, err, &lexer_))
+ return false;
if (!ExpectToken(Lexer::NEWLINE, err))
return false;
diff --git a/src/manifest_parser.h b/src/manifest_parser.h
index 967dfdd..5212f72 100644
--- a/src/manifest_parser.h
+++ b/src/manifest_parser.h
@@ -35,7 +35,7 @@ struct ManifestParser {
ManifestParser(State* state, FileReader* file_reader);
/// Load and parse a file.
- bool Load(const string& filename, string* err);
+ bool Load(const string& filename, string* err, Lexer* parent=NULL);
/// Parse a text string of input. Used by tests.
bool ParseTest(const string& input, string* err) {
diff --git a/src/manifest_parser_test.cc b/src/manifest_parser_test.cc
index be63e52..5ed1584 100644
--- a/src/manifest_parser_test.cc
+++ b/src/manifest_parser_test.cc
@@ -773,6 +773,17 @@ TEST_F(ParserTest, Include) {
EXPECT_EQ("inner", state.bindings_.LookupVariable("var"));
}
+TEST_F(ParserTest, BrokenInclude) {
+ files_["include.ninja"] = "build\n";
+ ManifestParser parser(&state, this);
+ string err;
+ EXPECT_FALSE(parser.ParseTest("include include.ninja\n", &err));
+ EXPECT_EQ("include.ninja:1: expected path\n"
+ "build\n"
+ " ^ near here"
+ , err);
+}
+
TEST_F(ParserTest, Implicit) {
ASSERT_NO_FATAL_FAILURE(AssertParse(
"rule cat\n"