From ad7d9f43f1bd8e04321d8fdb07ebf7b96ab525a1 Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Thu, 29 Dec 2011 12:48:25 -0800 Subject: [PATCH] minor re2c cleanups --- src/depfile_parser.cc | 5 +++-- src/depfile_parser.in.cc | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/depfile_parser.cc b/src/depfile_parser.cc index 4e842f8..8f8f9fe 100644 --- a/src/depfile_parser.cc +++ b/src/depfile_parser.cc @@ -43,9 +43,9 @@ bool DepfileParser::Parse(string* content, string* err) { for (;;) { // start: beginning of the current parsed span. const char* start = in; - char yych; { + char yych; static const unsigned char yybm[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -136,8 +136,9 @@ yy4: goto yy10; yy5: { - // Got a span of plain text. Copy it to out if necessary. + // Got a span of plain text. int len = in - start; + // Need to shift it over if we're overwriting backslashes. if (out < start) memmove(out, start, len); out += len; diff --git a/src/depfile_parser.in.cc b/src/depfile_parser.in.cc index b310c58..de1c38f 100644 --- a/src/depfile_parser.in.cc +++ b/src/depfile_parser.in.cc @@ -42,7 +42,6 @@ bool DepfileParser::Parse(string* content, string* err) { for (;;) { // start: beginning of the current parsed span. const char* start = in; - char yych; /*!re2c re2c:define:YYCTYPE = "char"; re2c:define:YYCURSOR = in; @@ -53,8 +52,6 @@ bool DepfileParser::Parse(string* content, string* err) { re2c:indent:top = 2; re2c:indent:string = " "; - re2c:yych:emit = 0; - nul = "\000"; escape = [ \\#*$[|]; @@ -63,15 +60,16 @@ bool DepfileParser::Parse(string* content, string* err) { *out++ = yych; continue; } - '\\'[^\000\n] { + '\\' [^\000\n] { // Let backslash before other characters through verbatim. *out++ = '\\'; *out++ = yych; continue; } [a-zA-Z0-9+,/_:.-]+ { - // Got a span of plain text. Copy it to out if necessary. + // Got a span of plain text. int len = in - start; + // Need to shift it over if we're overwriting backslashes. if (out < start) memmove(out, start, len); out += len; -- 2.7.4