From: Wolfgang (Blub) Bumiller Date: Fri, 30 Nov 2012 14:53:53 +0000 (+0100) Subject: We can now reintroduce the 'preprocessor-directives only after newlines' rule correctly X-Git-Tag: 0.1.9~170 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=44cbf40553bd52fc12f15d2ada8580b0f2710a4a;p=xonotic%2Fgmqcc.git We can now reintroduce the 'preprocessor-directives only after newlines' rule correctly --- diff --git a/ftepp.c b/ftepp.c index 449dcd5..0a7ba6b 100644 --- a/ftepp.c +++ b/ftepp.c @@ -55,7 +55,6 @@ typedef struct { typedef struct { lex_file *lex; int token; - bool newline; unsigned int errors; bool output_on; @@ -1214,8 +1213,13 @@ static bool ftepp_hash(ftepp_t *ftepp) break; } else { - ftepp_error(ftepp, "unrecognized preprocessor directive: `%s`", ftepp_tokval(ftepp)); - return false; + if (ftepp->output_on) { + ftepp_error(ftepp, "unrecognized preprocessor directive: `%s`", ftepp_tokval(ftepp)); + return false; + } else { + ftepp_next(ftepp); + break; + } } /* break; never reached */ default: @@ -1254,11 +1258,7 @@ static bool ftepp_preprocess(ftepp_t *ftepp) if (ftepp->token >= TOKEN_EOF) break; #if 0 - ftepp->newline = newline; - newline = false; -#else - /* For the sake of FTE compatibility... FU, really */ - ftepp->newline = newline = true; + newline = true; #endif switch (ftepp->token) { @@ -1278,7 +1278,7 @@ static bool ftepp_preprocess(ftepp_t *ftepp) ftepp->token = TOKEN_ERROR; break; case '#': - if (!ftepp->newline) { + if (!newline) { ftepp_out(ftepp, ftepp_tokval(ftepp), false); ftepp_next(ftepp); break; @@ -1298,7 +1298,13 @@ static bool ftepp_preprocess(ftepp_t *ftepp) ftepp_out(ftepp, "\n", true); ftepp_next(ftepp); break; + case TOKEN_WHITE: + /* same as default but don't set newline=false */ + ftepp_out(ftepp, ftepp_tokval(ftepp), false); + ftepp_next(ftepp); + break; default: + newline = false; ftepp_out(ftepp, ftepp_tokval(ftepp), false); ftepp_next(ftepp); break; @@ -1309,8 +1315,7 @@ static bool ftepp_preprocess(ftepp_t *ftepp) vec_push(ftepp->output_string, 0); vec_shrinkby(ftepp->output_string, 1); - newline = ftepp->token == TOKEN_EOF; - return newline; + return (ftepp->token == TOKEN_EOF); } /* Like in parser.c - files keep the previous state so we have one global