update old_string after a recursive preprocess call so we don't reset to a free'd vector; add recursion header/footer pragmas

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-11-18 14:39:24 +01:00
parent 441a224435
commit 4c2e5d7ebf

13
ftepp.c
View file

@ -483,6 +483,16 @@ static void ftepp_stringify(ftepp_t *ftepp, macroparam *param)
ftepp_out(ftepp, "\"", false); ftepp_out(ftepp, "\"", false);
} }
static void ftepp_recursion_header(ftepp_t *ftepp)
{
ftepp_out(ftepp, "\n#pragma push(line)\n", false);
}
static void ftepp_recursion_footer(ftepp_t *ftepp)
{
ftepp_out(ftepp, "\n#pragma pop(line)\n", false);
}
static bool ftepp_preprocess(ftepp_t *ftepp); 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)
{ {
@ -560,11 +570,14 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param
} }
ftepp->output_string = old_string; ftepp->output_string = old_string;
ftepp->lex = inlex; ftepp->lex = inlex;
ftepp_recursion_header(ftepp);
if (!ftepp_preprocess(ftepp)) { if (!ftepp_preprocess(ftepp)) {
lex_close(ftepp->lex); lex_close(ftepp->lex);
retval = false; retval = false;
goto cleanup; goto cleanup;
} }
ftepp_recursion_footer(ftepp);
old_string = ftepp->output_string;
cleanup: cleanup:
ftepp->lex = old_lexer; ftepp->lex = old_lexer;