}
static bool ftepp_preprocess(ftepp_t *ftepp);
-static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *params)
+static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *params, bool resetline)
{
char *old_string = ftepp->output_string;
lex_file *old_lexer = ftepp->lex;
vec_free(ftepp->lex->open_string);
if (has_newlines)
ftepp_recursion_footer(ftepp);
+ if (resetline) {
+ char lineno[128];
+ sprintf(lineno, "\n#pragma line(%lu)\n", old_lexer->sline);
+ ftepp_out(ftepp, lineno, false);
+ }
old_string = ftepp->output_string;
cleanup:
size_t o;
macroparam *params = NULL;
bool retval = true;
+ size_t paramline;
if (!macro->has_params) {
- if (!ftepp_macro_expand(ftepp, macro, NULL))
+ if (!ftepp_macro_expand(ftepp, macro, NULL, false))
return false;
ftepp_next(ftepp);
return true;
}
ftepp_next(ftepp);
+ paramline = ftepp->lex->sline;
if (!ftepp_macro_call_params(ftepp, ¶ms))
return false;
goto cleanup;
}
- if (!ftepp_macro_expand(ftepp, macro, params))
+ if (!ftepp_macro_expand(ftepp, macro, params, (paramline != ftepp->lex->sline)))
retval = false;
ftepp_next(ftepp);