From 8bab23be060ef6c79e35daa8e6deca18d00341f6 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 12 Mar 2015 11:59:45 -0400 Subject: Reject depfiles that don't contain a : after the target name. This is a prerequisite for fixing #417. --- src/build_test.cc | 3 +-- src/depfile_parser.cc | 4 ++++ src/depfile_parser.in.cc | 4 ++++ src/depfile_parser_test.cc | 2 +- 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("\\!\\@#$\\%\\^\\&\\", -- cgit v0.12