History

fixed macro function bug

bellard committed 23 years ago

Commit f46a02a1 parent 34b7d962 files · +12 −0Browse files

Unified · Split

2 files
  1. Changelog +1 −0
  2. tcc.c +11 −0
Changelog+1−0
@@ -7,6 +7,7 @@ version 0.9.17: · 6 unmodified lines
77 - function parameters must be converted to pointers (signaled by Neil Brown)
88 - sanitized string and character constant parsing
99 - fixed comment parse (signaled by Damian M Gryski)
10+- fixed macro function bug (signaled by Philippe Ribet)
1011
1112 version 0.9.16:
1213
tcc.c+11−0
@@ -3749,7 +3749,14 @@ static int macro_subst_tok(TokenString *tok_str, · 3748 unmodified lines
37493749 next token. XXX: find better solution */
37503750 if (macro_ptr) {
37513751 t = *macro_ptr;
3752+ if (t == 0) {
3753+ /* end of macro stream: we must look at the token
3754+ after in the file */
3755+ macro_ptr = NULL;
3756+ goto parse_stream;
3757+ }
37523758 } else {
3759+ parse_stream:
37533760 /* XXX: incorrect with comments */
37543761 ch = file->buf_ptr[0];
37553762 while (is_space(ch) || ch == '\n')
@@ -3981,6 +3988,10 @@ static void macro_subst(TokenString *tok_str, · 225 unmodified lines
39813988 if (macro_str1)
39823989 ptr = macro_str1;
39833990 while (1) {
3991+ /* NOTE: ptr == NULL can only happen if tokens are read from
3992+ file stream due to a macro function call */
3993+ if (ptr == NULL)
3994+ break;
39843995 TOK_GET(t, ptr, cval);
39853996 if (t == 0)
39863997 break;