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
master
Changming Xu 2011-03-01 09:19:43 +08:00
parent 185fba4189
commit 684723488d
1 changed files with 11 additions and 7 deletions

18
tccpp.c
View File

@ -2448,10 +2448,13 @@ maybe_newline:
PEEKC(c, p); PEEKC(c, p);
if (c == '*') { if (c == '*') {
p = parse_comment(p); p = parse_comment(p);
goto redo_no_start; /* comments replaced by a blank */
tok = ' ';
goto keep_tok_flags;
} else if (c == '/') { } else if (c == '/') {
p = parse_line_comment(p); p = parse_line_comment(p);
goto redo_no_start; tok = ' ';
goto keep_tok_flags;
} else if (c == '=') { } else if (c == '=') {
p++; p++;
tok = TOK_A_DIV; tok = TOK_A_DIV;
@ -2847,16 +2850,17 @@ static void macro_subst(TokenString *tok_str, Sym **nested_list,
int t, ret, spc; int t, ret, spc;
CValue cval; CValue cval;
struct macro_level ml; struct macro_level ml;
int force_blank;
/* first scan for '##' operator handling */ /* first scan for '##' operator handling */
ptr = macro_str; ptr = macro_str;
macro_str1 = macro_twosharps(ptr); macro_str1 = macro_twosharps(ptr);
/* a ' ' after subst */
int append_space = 0;
if (macro_str1) if (macro_str1)
ptr = macro_str1; ptr = macro_str1;
spc = 0; spc = 0;
force_blank = 0;
while (1) { while (1) {
/* NOTE: ptr == NULL can only happen if tokens are read from /* NOTE: ptr == NULL can only happen if tokens are read from
file stream due to a macro function call */ 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) if (ret != 0)
goto no_subst; goto no_subst;
if (parse_flags & PARSE_FLAG_SPACES) if (parse_flags & PARSE_FLAG_SPACES)
append_space = 1; force_blank = 1;
} else { } else {
no_subst: no_subst:
if (append_space) { if (force_blank) {
tok_str_add(tok_str, ' '); tok_str_add(tok_str, ' ');
spc = 1; spc = 1;
append_space = 0; force_blank = 0;
} }
if (!check_space(t, &spc)) if (!check_space(t, &spc))
tok_str_add2(tok_str, t, &cval); tok_str_add2(tok_str, t, &cval);