summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-03-12 15:59:45 (GMT)
committerNico Weber <nicolasweber@gmx.de>2015-03-12 15:59:45 (GMT)
commit8bab23be060ef6c79e35daa8e6deca18d00341f6 (patch)
tree0a9ab77f777f8acaddb8cb20a71e89e563135320
parent51f06facf46e7a1a5338a4ca2ec9b8441c44c405 (diff)
downloadNinja-8bab23be060ef6c79e35daa8e6deca18d00341f6.zip
Ninja-8bab23be060ef6c79e35daa8e6deca18d00341f6.tar.gz
Ninja-8bab23be060ef6c79e35daa8e6deca18d00341f6.tar.bz2
Reject depfiles that don't contain a : after the target name.
This is a prerequisite for fixing #417.
-rw-r--r--src/build_test.cc3
-rw-r--r--src/depfile_parser.cc4
-rw-r--r--src/depfile_parser.in.cc4
-rw-r--r--src/depfile_parser_test.cc2
4 files changed, 10 insertions, 3 deletions
diff --git a/src/build_test.cc b/src/build_test.cc
index bd1cd30..82da57b 100644
--- a/src/build_test.cc
+++ b/src/build_test.cc
@@ -816,8 +816,7 @@ TEST_F(BuildTest, DepFileParseError) {
fs_.Create("foo.c", "");
fs_.Create("foo.o.d", "randomtext\n");
EXPECT_FALSE(builder_.AddTarget("foo.o", &err));
- EXPECT_EQ("expected depfile 'foo.o.d' to mention 'foo.o', got 'randomtext'",
- err);
+ EXPECT_EQ("foo.o.d: expected ':' in depfile", err);
}
TEST_F(BuildTest, OrderOnlyDeps) {
diff --git a/src/depfile_parser.cc b/src/depfile_parser.cc
index 4ca3943..7268f31 100644
--- a/src/depfile_parser.cc
+++ b/src/depfile_parser.cc
@@ -230,5 +230,9 @@ yy16:
return false;
}
}
+ if (parsing_targets) {
+ *err = "expected ':' in depfile";
+ return false;
+ }
return true;
}
diff --git a/src/depfile_parser.in.cc b/src/depfile_parser.in.cc
index b59baf0..deaee5b 100644
--- a/src/depfile_parser.in.cc
+++ b/src/depfile_parser.in.cc
@@ -112,5 +112,9 @@ bool DepfileParser::Parse(string* content, string* err) {
return false;
}
}
+ if (parsing_targets) {
+ *err = "expected ':' in depfile";
+ return false;
+ }
return true;
}
diff --git a/src/depfile_parser_test.cc b/src/depfile_parser_test.cc
index e67ef79..8b57a1e 100644
--- a/src/depfile_parser_test.cc
+++ b/src/depfile_parser_test.cc
@@ -106,7 +106,7 @@ TEST_F(DepfileParserTest, Escapes) {
// it through.
string err;
EXPECT_TRUE(Parse(
-"\\!\\@\\#$$\\%\\^\\&\\\\",
+"\\!\\@\\#$$\\%\\^\\&\\\\:",
&err));
ASSERT_EQ("", err);
EXPECT_EQ("\\!\\@#$\\%\\^\\&\\",