diff options
author | Nico Weber <nicolasweber@gmx.de> | 2014-05-01 15:50:21 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2014-05-01 15:50:21 (GMT) |
commit | 9b156e4e026bfad25bb2684d2f4fb8862ec19752 (patch) | |
tree | a2d62cf1a328ad9beb4d2ead48cb90d83014d627 | |
parent | 6c9a54649d4eec45f58e117612a34a2c214a0214 (diff) | |
parent | c2b7e472ee5db11a65d113a2d7e11668b9e4608f (diff) | |
download | Ninja-9b156e4e026bfad25bb2684d2f4fb8862ec19752.zip Ninja-9b156e4e026bfad25bb2684d2f4fb8862ec19752.tar.gz Ninja-9b156e4e026bfad25bb2684d2f4fb8862ec19752.tar.bz2 |
Merge pull request #753 from nico/nlacc
Accept \r\n line endings in depfiles.
-rw-r--r-- | src/depfile_parser.cc | 13 | ||||
-rw-r--r-- | src/depfile_parser.in.cc | 4 | ||||
-rw-r--r-- | src/depfile_parser_test.cc | 12 |
3 files changed, 21 insertions, 8 deletions
diff --git a/src/depfile_parser.cc b/src/depfile_parser.cc index 49c7d7b..d052a4b 100644 --- a/src/depfile_parser.cc +++ b/src/depfile_parser.cc @@ -124,17 +124,18 @@ bool DepfileParser::Parse(string* content, string* err) { } } ++in; - if ((yych = *in) <= '#') { - if (yych <= '\n') { + if ((yych = *in) <= '"') { + if (yych <= '\f') { if (yych <= 0x00) goto yy3; - if (yych <= '\t') goto yy14; + if (yych != '\n') goto yy14; } else { + if (yych <= '\r') goto yy3; if (yych == ' ') goto yy16; - if (yych <= '"') goto yy14; - goto yy16; + goto yy14; } } else { if (yych <= 'Z') { + if (yych <= '#') goto yy16; if (yych == '*') goto yy16; goto yy14; } else { @@ -224,7 +225,7 @@ yy16: } else if (!out_.str_) { out_ = StringPiece(filename, len); } else if (out_ != StringPiece(filename, len)) { - *err = "depfile has multiple output paths."; + *err = "depfile has multiple output paths"; return false; } } diff --git a/src/depfile_parser.in.cc b/src/depfile_parser.in.cc index 8bb6d84..ba77079 100644 --- a/src/depfile_parser.in.cc +++ b/src/depfile_parser.in.cc @@ -67,7 +67,7 @@ bool DepfileParser::Parse(string* content, string* err) { *out++ = '$'; continue; } - '\\' [^\000\n] { + '\\' [^\000\r\n] { // Let backslash before other characters through verbatim. *out++ = '\\'; *out++ = yych; @@ -108,7 +108,7 @@ bool DepfileParser::Parse(string* content, string* err) { } else if (!out_.str_) { out_ = StringPiece(filename, len); } else if (out_ != StringPiece(filename, len)) { - *err = "depfile has multiple output paths."; + *err = "depfile has multiple output paths"; return false; } } diff --git a/src/depfile_parser_test.cc b/src/depfile_parser_test.cc index 0f6771a..581f3a2 100644 --- a/src/depfile_parser_test.cc +++ b/src/depfile_parser_test.cc @@ -58,6 +58,17 @@ TEST_F(DepfileParserTest, Continuation) { EXPECT_EQ(2u, parser_.ins_.size()); } +TEST_F(DepfileParserTest, CarriageReturnContinuation) { + string err; + EXPECT_TRUE(Parse( +"foo.o: \\\r\n" +" bar.h baz.h\r\n", + &err)); + ASSERT_EQ("", err); + EXPECT_EQ("foo.o", parser_.out_.AsString()); + EXPECT_EQ(2u, parser_.ins_.size()); +} + TEST_F(DepfileParserTest, BackSlashes) { string err; EXPECT_TRUE(Parse( @@ -136,4 +147,5 @@ TEST_F(DepfileParserTest, RejectMultipleDifferentOutputs) { // check that multiple different outputs are rejected by the parser string err; EXPECT_FALSE(Parse("foo bar: x y z", &err)); + ASSERT_EQ("depfile has multiple output paths", err); } |