allow paths with '!' in depfiles
authorEvan Martin <martine@danga.com>
Sat, 30 Mar 2013 23:36:47 +0000 (16:36 -0700)
committerEvan Martin <martine@danga.com>
Sat, 30 Mar 2013 23:36:47 +0000 (16:36 -0700)
See funny paths in
  https://github.com/google/libcxx/tree/master/test/iterators/stream.iterators/istreambuf.iterator/

src/depfile_parser.cc
src/depfile_parser.in.cc
src/depfile_parser_test.cc

index 6887c91..c8fb92e 100644 (file)
@@ -53,10 +53,10 @@ 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,   0,   0,   0,   0,   0, 
-        128, 128,   0, 128, 128, 128, 128, 128, 
+          0, 128, 128, 128, 128, 128, 128, 128, 
         128, 128, 128, 128, 128, 128, 128, 128, 
-        128, 128, 128,   0,   0, 128,   0,   0, 
+        128, 128, 128, 128, 128, 128, 128, 128, 
+        128, 128, 128, 128, 128, 128,   0,   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, 
@@ -84,38 +84,26 @@ bool DepfileParser::Parse(string* content, string* err) {
       };
 
       yych = *in;
-      if (yych <= 'Z') {
-        if (yych <= '*') {
+      if (yych <= '\\') {
+        if (yych <= '=') {
           if (yych <= 0x00) goto yy6;
-          if (yych <= '\'') goto yy8;
-          if (yych <= ')') goto yy4;
-          goto yy8;
+          if (yych <= ' ') goto yy8;
+          goto yy4;
         } else {
-          if (yych <= '<') {
-            if (yych <= ':') goto yy4;
-            goto yy8;
-          } else {
-            if (yych <= '=') goto yy4;
-            if (yych <= '?') goto yy8;
-            goto yy4;
-          }
+          if (yych <= '?') goto yy8;
+          if (yych <= 'Z') goto yy4;
+          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 <= 'z') {
-            if (yych <= '`') goto yy8;
-            goto yy4;
-          } else {
-            if (yych == '~') goto yy4;
-            goto yy8;
-          }
+          if (yych <= 'z') goto yy4;
+          if (yych == '~') goto yy4;
+          goto yy8;
         }
       }
-yy2:
       ++in;
       if ((yych = *in) <= '$') {
         if (yych <= '\n') {
index 1d4a177..f96cdb3 100644 (file)
@@ -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 = (int)(in - start);
         // Need to shift it over if we're overwriting backslashes.
index 93d42db..552975c 100644 (file)
@@ -104,10 +104,12 @@ TEST_F(DepfileParserTest, Escapes) {
 }
 
 TEST_F(DepfileParserTest, SpecialChars) {
+  // See filenames like istreambuf.iterator_op!= in
+  // https://github.com/google/libcxx/tree/master/test/iterators/stream.iterators/istreambuf.iterator/
   string err;
   EXPECT_TRUE(Parse(
 "C:/Program\\ Files\\ (x86)/Microsoft\\ crtdefs.h: \n"
-" en@quot.header~ t+t-x=1",
+" en@quot.header~ t+t-x!=1",
       &err));
   ASSERT_EQ("", err);
   EXPECT_EQ("C:/Program Files (x86)/Microsoft crtdefs.h",
@@ -115,7 +117,7 @@ TEST_F(DepfileParserTest, SpecialChars) {
   ASSERT_EQ(2u, parser_.ins_.size());
   EXPECT_EQ("en@quot.header~",
             parser_.ins_[0].AsString());
-  EXPECT_EQ("t+t-x=1",
+  EXPECT_EQ("t+t-x!=1",
             parser_.ins_[1].AsString());
 }