Skip to content

Commit

Permalink
Merge pull request ninja-build#251 from polrop/depfile-parser-accept-…
Browse files Browse the repository at this point in the history
…tilde

Depfile parser accept tilde.
  • Loading branch information
evmar committed Mar 18, 2012
2 parents fdec96f + 6a09b96 commit abd33d5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
16 changes: 7 additions & 9 deletions src/depfile_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -84,28 +84,26 @@ bool DepfileParser::Parse(string* content, string* err) {
};

yych = *in;
if (yych <= '[') {
if (yych <= '\\') {
if (yych <= ':') {
if (yych <= 0x00) goto yy6;
if (yych <= '*') goto yy8;
goto yy4;
} 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') {
Expand Down
2 changes: 1 addition & 1 deletion src/depfile_parser.in.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions src/depfile_parser_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

0 comments on commit abd33d5

Please sign in to comment.