From b4d5a02e0e54c048dc158a593b89d5240fe77eeb Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Sat, 16 Oct 2010 10:16:30 -0700 Subject: [PATCH] support more filename chars --- ninja.h | 11 ++++++++--- ninja_test.cc | 14 +++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ninja.h b/ninja.h index e6d4570..d10a5b3 100644 --- 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() { diff --git a/ninja_test.cc b/ninja_test.cc index f633cd4..06f55df 100644 --- a/ninja_test.cc +++ b/ninja_test.cc @@ -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); -- 2.7.4