support more filename chars
authorEvan Martin <martine@danga.com>
Sat, 16 Oct 2010 17:16:30 +0000 (10:16 -0700)
committerEvan Martin <martine@danga.com>
Sat, 16 Oct 2010 17:16:30 +0000 (10:16 -0700)
ninja.h
ninja_test.cc

diff --git a/ninja.h b/ninja.h
index e6d4570..d10a5b3 100644 (file)
--- a/ninja.h
+++ b/ninja.h
@@ -340,7 +340,7 @@ bool ManifestParser::Parse(const string& input, string* err) {
 
 bool ManifestParser::Error(const string& message, string* err) {
   char buf[1024];
-  sprintf(buf, "line %d, col %d: %s", line_ + 1, col_ + 1, message.c_str());
+  sprintf(buf, "line %d, col %d: %s", line_ + 1, col_, message.c_str());
   err->assign(buf);
   return false;
 }
@@ -419,14 +419,19 @@ bool ManifestParser::Newline(string* err) {
     ++cur_; ++line_; col_ = 0;
     return true;
   } else {
-    return Error("expected newline", err);
+    if (cur_ >= end_)
+      return Error("expected newline, got eof", err);
+    else
+      return Error(string("expected newline, got '") + *cur_ + string("'"), err);
   }
 }
 
 static bool IsIdentChar(char c) {
   return
     ('a' <= c && c <= 'z') ||
-    ('0' <= c && c <= '9');
+    ('+' <= c && c <= '9') ||  // +,-./ and numbers
+    ('A' <= c && c <= 'Z') ||
+    (c == '_');
 }
 
 bool ManifestParser::NextToken() {
index f633cd4..06f55df 100644 (file)
@@ -70,13 +70,13 @@ TEST(Parser, Rules) {
   ManifestParser parser(&state);
   string err;
   EXPECT_TRUE(parser.Parse(
-      "rule cat\n"
-      "command cat @in > $out\n"
-      "\n"
-      "rule date\n"
-      "command date > $out\n"
-      "\n"
-      "build result: cat in1 in2\n",
+"rule cat\n"
+"command cat @in > $out\n"
+"\n"
+"rule date\n"
+"command date > $out\n"
+"\n"
+"build result: cat in_1.cc in-2.O\n",
       &err));
   EXPECT_EQ("", err);