From 18ea1ffd900dd81116728c8638d687ec5ca02cc0 Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Tue, 12 Jun 2012 15:11:22 -0700 Subject: allow '(' and ')' in depfile paths Fixes issue #327. --- src/depfile_parser.cc | 16 ++++++++++------ src/depfile_parser.in.cc | 2 +- src/depfile_parser_test.cc | 11 +++++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/depfile_parser.cc b/src/depfile_parser.cc index 261893f..54b934c 100644 --- a/src/depfile_parser.cc +++ b/src/depfile_parser.cc @@ -54,7 +54,7 @@ bool DepfileParser::Parse(string* content, string* err) { 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, 0, 0, 128, 128, 128, 128, 128, + 128, 128, 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, @@ -84,18 +84,21 @@ bool DepfileParser::Parse(string* content, string* err) { }; yych = *in; - if (yych <= '\\') { - if (yych <= ':') { + if (yych <= '[') { + if (yych <= '*') { if (yych <= 0x00) goto yy6; - if (yych <= '*') goto yy8; - goto yy4; + if (yych <= '\'') goto yy8; + if (yych <= ')') goto yy4; + goto yy8; } else { + if (yych <= ':') goto yy4; if (yych <= '@') goto yy8; if (yych <= 'Z') goto yy4; - if (yych <= '[') goto yy8; + goto yy8; } } else { if (yych <= '`') { + if (yych <= '\\') goto yy2; if (yych == '_') goto yy4; goto yy8; } else { @@ -104,6 +107,7 @@ bool DepfileParser::Parse(string* content, string* err) { 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 5e073df..8c415b9 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 736e591..fd76ae7 100644 --- a/src/depfile_parser_test.cc +++ b/src/depfile_parser_test.cc @@ -103,6 +103,17 @@ TEST_F(DepfileParserTest, Escapes) { ASSERT_EQ(0u, parser_.ins_.size()); } +TEST_F(DepfileParserTest, SpecialChars) { + string err; + EXPECT_TRUE(Parse( +"C:/Program\\ Files\\ (x86)/Microsoft\\ crtdefs.h:", + &err)); + ASSERT_EQ("", err); + EXPECT_EQ("C:/Program Files (x86)/Microsoft crtdefs.h", + parser_.out_.AsString()); + ASSERT_EQ(0u, parser_.ins_.size()); +} + TEST_F(DepfileParserTest, UnifyMultipleOutputs) { // check that multiple duplicate targets are properly unified string err; -- cgit v0.12