mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-18 14:21:36 +00:00
We can now reintroduce the 'preprocessor-directives only after newlines' rule correctly
This commit is contained in:
parent
f1a36ca647
commit
44cbf40553
1 changed files with 16 additions and 11 deletions
27
ftepp.c
27
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
|
||||
|
|
Loading…
Reference in a new issue