From 6a09b9653e5c6698dd687c6e9deb0b51eac39dca Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Wed, 14 Mar 2012 20:33:32 +0100 Subject: [PATCH] Depfile parser accept tilde. --- src/depfile_parser.cc | 16 +++++++--------- src/depfile_parser.in.cc | 2 +- src/depfile_parser_test.cc | 13 +++++++++++++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/depfile_parser.cc b/src/depfile_parser.cc index 7219eb0e18..261893f40c 100644 --- a/src/depfile_parser.cc +++ b/src/depfile_parser.cc @@ -64,7 +64,7 @@ bool DepfileParser::Parse(string* content, string* err) { 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 0, 0, 0, 0, 0, + 128, 128, 128, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -84,7 +84,7 @@ bool DepfileParser::Parse(string* content, string* err) { }; yych = *in; - if (yych <= '[') { + if (yych <= '\\') { if (yych <= ':') { if (yych <= 0x00) goto yy6; if (yych <= '*') goto yy8; @@ -92,20 +92,18 @@ bool DepfileParser::Parse(string* content, string* err) { } else { if (yych <= '@') goto yy8; if (yych <= 'Z') goto yy4; - goto yy8; + if (yych <= '[') goto yy8; } } else { - if (yych <= '_') { - if (yych <= '\\') goto yy2; - if (yych <= '^') goto yy8; - goto yy4; + if (yych <= '`') { + if (yych == '_') goto yy4; + goto yy8; } else { - if (yych <= '`') goto yy8; if (yych <= 'z') goto yy4; + if (yych == '~') goto yy4; goto yy8; } } -yy2: ++in; if ((yych = *in) <= '$') { if (yych <= '\n') { diff --git a/src/depfile_parser.in.cc b/src/depfile_parser.in.cc index 419ed8daaa..5e073dfde3 100644 --- a/src/depfile_parser.in.cc +++ b/src/depfile_parser.in.cc @@ -68,7 +68,7 @@ bool DepfileParser::Parse(string* content, string* err) { *out++ = yych; continue; } - [a-zA-Z0-9+,/_:.-]+ { + [a-zA-Z0-9+,/_:.~-]+ { // Got a span of plain text. int len = in - start; // Need to shift it over if we're overwriting backslashes. diff --git a/src/depfile_parser_test.cc b/src/depfile_parser_test.cc index 883926a8e4..ce122cf2a4 100644 --- a/src/depfile_parser_test.cc +++ b/src/depfile_parser_test.cc @@ -119,3 +119,16 @@ TEST_F(DepfileParserTest, RejectMultipleDifferentOutputs) { string err; EXPECT_FALSE(Parse("foo bar: x y z", &err)); } + +TEST_F(DepfileParserTest, Tilde) { + string err; + EXPECT_TRUE(Parse( +"foo~.o: foo~.c", + &err)); + ASSERT_EQ("", err); + EXPECT_EQ("foo~.o", + parser_.out_.AsString()); + ASSERT_EQ(1u, parser_.ins_.size()); + EXPECT_EQ("foo~.c", + parser_.ins_[0].AsString()); +}