From cee9fc7c2fc56c99d69078f0be956935b9b8d695 Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Fri, 22 Oct 2010 09:58:42 -0700 Subject: [PATCH] allow underscores in variable names --- Makefile | 4 ++-- eval_env.h | 3 ++- ninja_test.cc | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 550c581..3571752 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ tags: ninja_test: LDFLAGS = -lgtest -lgtest_main -lpthread ninja_test: ninja_test.o -ninja_test.o: ninja_test.cc ninja.h manifest_parser.h +ninja_test.o: ninja_test.cc ninja.h eval_env.h manifest_parser.h ninja: ninja.o -ninja.o: ninja.cc ninja.h manifest_parser.h +ninja.o: ninja.cc ninja.h eval_env.h manifest_parser.h diff --git a/eval_env.h b/eval_env.h index 695c28c..dfd091e 100644 --- a/eval_env.h +++ b/eval_env.h @@ -29,7 +29,8 @@ bool EvalString::Parse(const string& input) { parsed_.push_back(make_pair(input.substr(start, end - start), RAW)); start = end; for (end = start + 1; end < input.size(); ++end) { - if (!('a' <= input[end] && input[end] <= 'z')) + char c = input[end]; + if (!(('a' <= c && c <= 'z') || c == '_')) break; } if (end == start + 1) { diff --git a/ninja_test.cc b/ninja_test.cc index bdba975..2544347 100644 --- a/ninja_test.cc +++ b/ninja_test.cc @@ -39,14 +39,15 @@ TEST(Parser, Variables) { State state; ASSERT_NO_FATAL_FAILURE(AssertParse(&state, "rule link\n" -"command ld $extra -o $out @in\n" +"command ld $extra $with_under -o $out @in\n" "\n" "extra = -pthread\n" +"with_under = -under\n" "build a: link b c\n")); ASSERT_EQ(1, state.edges_.size()); Edge* edge = state.edges_[0]; - EXPECT_EQ("ld -pthread -o a b c", edge->EvaluateCommand()); + EXPECT_EQ("ld -pthread -under -o a b c", edge->EvaluateCommand()); } TEST(Parser, Continuation) { -- 2.7.4