From 185fba418978aabef36765fdfaf24d516f1a9f33 Mon Sep 17 00:00:00 2001 From: Changming Xu Date: Sun, 27 Feb 2011 10:15:15 +0800 Subject: [PATCH] tcc -E: append a ' ' after subst We need a ' ' after subst of m in the following case #define m(name,r) name ## r #define m0(a,b,c) int m(a,b) c #define m1(a,b,c) int m(a,b)c m0(a, b, c); m1(a, b, c); --- tccpp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tccpp.c b/tccpp.c index 88e6c79..e4bc0d0 100644 --- a/tccpp.c +++ b/tccpp.c @@ -2851,6 +2851,9 @@ static void macro_subst(TokenString *tok_str, Sym **nested_list, /* first scan for '##' operator handling */ ptr = macro_str; macro_str1 = macro_twosharps(ptr); + + /* a ' ' after subst */ + int append_space = 0; if (macro_str1) ptr = macro_str1; spc = 0; @@ -2888,8 +2891,15 @@ static void macro_subst(TokenString *tok_str, Sym **nested_list, *can_read_stream = ml.prev; if (ret != 0) goto no_subst; + if (parse_flags & PARSE_FLAG_SPACES) + append_space = 1; } else { no_subst: + if (append_space) { + tok_str_add(tok_str, ' '); + spc = 1; + append_space = 0; + } if (!check_space(t, &spc)) tok_str_add2(tok_str, t, &cval); }