From: Wolfgang Bumiller Date: Tue, 15 Jan 2013 21:03:16 +0000 (+0100) Subject: call ftepp_recursion_header/footer only when there are newlines in the expanded macro X-Git-Tag: before-library~250 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=dfa6d0c9adb4f941853863bea4c6d4fa22f3a704;p=xonotic%2Fgmqcc.git call ftepp_recursion_header/footer only when there are newlines in the expanded macro --- diff --git a/ftepp.c b/ftepp.c index d867d79..86bd741 100644 --- a/ftepp.c +++ b/ftepp.c @@ -640,6 +640,7 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param lex_file *old_lexer = ftepp->lex; size_t vararg_start = vec_size(macro->params); bool retval = true; + bool has_newlines; size_t varargs; size_t o, pi; @@ -712,6 +713,7 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param } } vec_push(ftepp->output_string, 0); + has_newlines = (strchr(ftepp->output_string, '\n') != NULL); /* Now run the preprocessor recursively on this string buffer */ /* printf("__________\n%s\n=========\n", ftepp->output_string); @@ -726,7 +728,8 @@ 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; - ftepp_recursion_header(ftepp); + if (has_newlines) + ftepp_recursion_header(ftepp); if (!ftepp_preprocess(ftepp)) { vec_free(ftepp->lex->open_string); old_string = ftepp->output_string; @@ -735,7 +738,8 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param goto cleanup; } vec_free(ftepp->lex->open_string); - ftepp_recursion_footer(ftepp); + if (has_newlines) + ftepp_recursion_footer(ftepp); old_string = ftepp->output_string; cleanup: