If a function macro name is separated from the parentheses in an macro invocation the substitution doesn't take place. Fix this by handling comments.
Unified · Split
| @@ -2697,10 +2697,25 @@ static int macro_subst_tok(TokenString *tok_str, · 2696 unmodified lines | |||
| 2697 | goto redo; | 2697 | goto redo; |
| 2698 | } | 2698 | } |
| 2699 | } else { | 2699 | } else { |
| 2700 | /* XXX: incorrect with comments */ | ||
| 2701 | ch = file->buf_ptr[0]; | 2700 | ch = file->buf_ptr[0]; |
| 2702 | while (is_space(ch) || ch == '\n') | 2701 | while (is_space(ch) || ch == '\n' || ch == '/') |
| 2703 | cinp(); | 2702 | { |
| 2703 | if (ch == '/') | ||
| 2704 | { | ||
| 2705 | int c; | ||
| 2706 | uint8_t *p = file->buf_ptr; | ||
| 2707 | PEEKC(c, p); | ||
| 2708 | if (c == '*') { | ||
| 2709 | p = parse_comment(p); | ||
| 2710 | file->buf_ptr = p - 1; | ||
| 2711 | } else if (c == '/') { | ||
| 2712 | p = parse_line_comment(p); | ||
| 2713 | file->buf_ptr = p - 1; | ||
| 2714 | } else | ||
| 2715 | break; | ||
| 2716 | } | ||
| 2717 | cinp(); | ||
| 2718 | } | ||
| 2704 | t = ch; | 2719 | t = ch; |
| 2705 | } | 2720 | } |
| 2706 | if (t != '(') /* no macro subst */ | 2721 | if (t != '(') /* no macro subst */ |
| @@ -288,6 +288,10 @@ comment · 287 unmodified lines | |||
| 288 | /* test function macro substitution when the function name is | 288 | /* test function macro substitution when the function name is |
| 289 | substituted */ | 289 | substituted */ |
| 290 | TEST2(); | 290 | TEST2(); |
| 291 | |||
| 292 | /* And again when the name and parenthes are separated by a | ||
| 293 | comment. */ | ||
| 294 | TEST2 /* the comment */ (); | ||
| 291 | } | 295 | } |
| 292 | 296 | ||
| 293 | 297 | ||