Unified · Split
| @@ -681,8 +681,8 @@ void vswap(void); · 680 unmodified lines | ||
| 681 | 681 | void vdup(void); |
| 682 | 682 | int get_reg(int rc); |
| 683 | 683 | |
| 684 | −static void macro_subst(TokenString *tok_str, | |
| 685 | − Sym **nested_list, const int *macro_str); | |
| 684 | +static void macro_subst(TokenString *tok_str, Sym **nested_list, | |
| 685 | + const int *macro_str, int can_read_stream); | |
| 686 | 686 | int save_reg_forced(int r); |
| 687 | 687 | void gen_op(int op); |
| 688 | 688 | void force_charshort_cast(int t); |
| @@ -3711,7 +3711,9 @@ static int *macro_arg_subst(Sym **nested_list, int *macro_str, Sym *args) · 3022 unmodified lines | ||
| 3711 | 3711 | } |
| 3712 | 3712 | } |
| 3713 | 3713 | } else { |
| 3714 | − macro_subst(&str, nested_list, st); | |
| 3714 | + /* NOTE: the stream cannot be read when macro | |
| 3715 | + substituing an argument */ | |
| 3716 | + macro_subst(&str, nested_list, st, 0); | |
| 3715 | 3717 | } |
| 3716 | 3718 | } else { |
| 3717 | 3719 | tok_str_add(&str, t); |
| @@ -3736,7 +3738,7 @@ static char const ab_month_name[12][4] = · 18 unmodified lines | ||
| 3736 | 3738 | macros we got inside to avoid recursing. Return non zero if no |
| 3737 | 3739 | substitution needs to be done */ |
| 3738 | 3740 | static int macro_subst_tok(TokenString *tok_str, |
| 3739 | − Sym **nested_list, Sym *s) | |
| 3741 | + Sym **nested_list, Sym *s, int can_read_stream) | |
| 3740 | 3742 | { |
| 3741 | 3743 | Sym *args, *sa, *sa1; |
| 3742 | 3744 | int mstr_allocated, parlevel, *mstr, t; |
| @@ -3785,7 +3787,7 @@ static int macro_subst_tok(TokenString *tok_str, · 42 unmodified lines | ||
| 3785 | 3787 | next token. XXX: find better solution */ |
| 3786 | 3788 | if (macro_ptr) { |
| 3787 | 3789 | t = *macro_ptr; |
| 3788 | − if (t == 0) { | |
| 3790 | + if (t == 0 && can_read_stream) { | |
| 3789 | 3791 | /* end of macro stream: we must look at the token |
| 3790 | 3792 | after in the file */ |
| 3791 | 3793 | macro_ptr = NULL; |
| @@ -3862,7 +3864,7 @@ static int macro_subst_tok(TokenString *tok_str, · 70 unmodified lines | ||
| 3862 | 3864 | mstr_allocated = 1; |
| 3863 | 3865 | } |
| 3864 | 3866 | sym_push2(nested_list, s->v, 0, 0); |
| 3865 | − macro_subst(tok_str, nested_list, mstr); | |
| 3867 | + macro_subst(tok_str, nested_list, mstr, 1); | |
| 3866 | 3868 | /* pop nested defined symbol */ |
| 3867 | 3869 | sa1 = *nested_list; |
| 3868 | 3870 | *nested_list = sa1->prev; |
| @@ -4009,8 +4011,8 @@ static inline int *macro_twosharps(const int *macro_str) · 140 unmodified lines | ||
| 4009 | 4011 | /* do macro substitution of macro_str and add result to |
| 4010 | 4012 | (tok_str,tok_len). 'nested_list' is the list of all macros we got |
| 4011 | 4013 | inside to avoid recursing. */ |
| 4012 | −static void macro_subst(TokenString *tok_str, | |
| 4013 | − Sym **nested_list, const int *macro_str) | |
| 4014 | +static void macro_subst(TokenString *tok_str, Sym **nested_list, | |
| 4015 | + const int *macro_str, int can_read_stream) | |
| 4014 | 4016 | { |
| 4015 | 4017 | Sym *s; |
| 4016 | 4018 | int *saved_macro_ptr, *macro_str1; |
| @@ -4039,7 +4041,7 @@ static void macro_subst(TokenString *tok_str, · 22 unmodified lines | ||
| 4039 | 4041 | saved_macro_ptr = macro_ptr; |
| 4040 | 4042 | macro_ptr = (int *)ptr; |
| 4041 | 4043 | tok = t; |
| 4042 | − ret = macro_subst_tok(tok_str, nested_list, s); | |
| 4044 | + ret = macro_subst_tok(tok_str, nested_list, s, can_read_stream); | |
| 4043 | 4045 | ptr = (int *)macro_ptr; |
| 4044 | 4046 | macro_ptr = saved_macro_ptr; |
| 4045 | 4047 | if (ret != 0) |
| @@ -4071,7 +4073,7 @@ static void next(void) · 25 unmodified lines | ||
| 4071 | 4073 | /* we have a macro: we try to substitute */ |
| 4072 | 4074 | tok_str_new(&str); |
| 4073 | 4075 | nested_list = NULL; |
| 4074 | − if (macro_subst_tok(&str, &nested_list, s) == 0) { | |
| 4076 | + if (macro_subst_tok(&str, &nested_list, s, 1) == 0) { | |
| 4075 | 4077 | /* substitution done, NOTE: maybe empty */ |
| 4076 | 4078 | tok_str_add(&str, 0); |
| 4077 | 4079 | macro_ptr = str.str; |