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