From: Wolfgang Bumiller Date: Wed, 16 Jan 2013 21:58:43 +0000 (+0100) Subject: more linenumber madness X-Git-Tag: before-library~242 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7d2b0e9638c08ba7e4cbe3ec88f841a22e5e9a54;p=xonotic%2Fgmqcc.git more linenumber madness --- diff --git a/ftepp.c b/ftepp.c index 77818f8..15e9da3 100644 --- a/ftepp.c +++ b/ftepp.c @@ -68,6 +68,7 @@ typedef struct { char *itemname; char *includename; + bool in_macro; } ftepp_t; /* @@ -646,6 +647,8 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param size_t o, pi; lex_file *inlex; + bool old_inmacro; + int nextok; if (vararg_start < vec_size(params)) @@ -728,21 +731,25 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param inlex->line = ftepp->lex->line; inlex->sline = ftepp->lex->sline; ftepp->lex = inlex; - if (has_newlines) + if (has_newlines && !ftepp->in_macro) ftepp_recursion_header(ftepp); + old_inmacro = ftepp->in_macro; + ftepp->in_macro = true; if (!ftepp_preprocess(ftepp)) { + ftepp->in_macro = old_inmacro; vec_free(ftepp->lex->open_string); old_string = ftepp->output_string; lex_close(ftepp->lex); retval = false; goto cleanup; } + ftepp->in_macro = old_inmacro; vec_free(ftepp->lex->open_string); - if (has_newlines) + if (has_newlines && !ftepp->in_macro) ftepp_recursion_footer(ftepp); - if (resetline) { + if (resetline && !ftepp->in_macro) { char lineno[128]; - sprintf(lineno, "\n#pragma line(%lu)\n", old_lexer->sline); + sprintf(lineno, "\n#pragma line(%lu)\n", (unsigned long)(old_lexer->sline)); ftepp_out(ftepp, lineno, false); } old_string = ftepp->output_string; @@ -1550,7 +1557,7 @@ static bool ftepp_preprocess(ftepp_t *ftepp) break; case TOKEN_WHITE: /* same as default but don't set newline=false */ - ftepp_out(ftepp, ftepp_tokval(ftepp), false); + ftepp_out(ftepp, ftepp_tokval(ftepp), true); ftepp_next(ftepp); break; default: