From 684723488d09f129f0e945ba860dc477c0068305 Mon Sep 17 00:00:00 2001 From: Changming Xu Date: Tue, 1 Mar 2011 09:19:43 +0800 Subject: [PATCH] Replace comment by a blank - fix my prev commit: put declaration above statements to stay c89 compatible - replace commit by a blank #define con(a, b) a/**/b this should yield a b, not ab --- tccpp.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tccpp.c b/tccpp.c index e4bc0d0..3afee3f 100644 --- a/tccpp.c +++ b/tccpp.c @@ -2448,10 +2448,13 @@ maybe_newline: PEEKC(c, p); if (c == '*') { p = parse_comment(p); - goto redo_no_start; + /* comments replaced by a blank */ + tok = ' '; + goto keep_tok_flags; } else if (c == '/') { p = parse_line_comment(p); - goto redo_no_start; + tok = ' '; + goto keep_tok_flags; } else if (c == '=') { p++; tok = TOK_A_DIV; @@ -2847,16 +2850,17 @@ static void macro_subst(TokenString *tok_str, Sym **nested_list, int t, ret, spc; CValue cval; struct macro_level ml; + int force_blank; /* 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; + force_blank = 0; + while (1) { /* NOTE: ptr == NULL can only happen if tokens are read from file stream due to a macro function call */ @@ -2892,13 +2896,13 @@ static void macro_subst(TokenString *tok_str, Sym **nested_list, if (ret != 0) goto no_subst; if (parse_flags & PARSE_FLAG_SPACES) - append_space = 1; + force_blank = 1; } else { no_subst: - if (append_space) { + if (force_blank) { tok_str_add(tok_str, ' '); spc = 1; - append_space = 0; + force_blank = 0; } if (!check_space(t, &spc)) tok_str_add2(tok_str, t, &cval);