diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-01-04 00:21:29 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-01-04 00:21:29 +0100 |
commit | 02c3d7a1c9ea82a8babf49f8a5305ec942b56dfa (patch) | |
tree | 8968ba5e96621f6e0809bd63cd2832e3bd5113a0 /miscutils/bc.c | |
parent | 19c3eb0b049c46d365c89c6ff05295fbae0f40a8 (diff) | |
download | busybox-w32-02c3d7a1c9ea82a8babf49f8a5305ec942b56dfa.tar.gz busybox-w32-02c3d7a1c9ea82a8babf49f8a5305ec942b56dfa.tar.bz2 busybox-w32-02c3d7a1c9ea82a8babf49f8a5305ec942b56dfa.zip |
bc: add a palceholder comment for "void" return
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/bc.c')
-rw-r--r-- | miscutils/bc.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 3bcda08a8..0bbd53a65 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -5720,7 +5720,7 @@ static BC_STATUS zdc_program_assignStr(BcResult *r, BcVec *v, bool push) | |||
5720 | #define zdc_program_assignStr(...) (zdc_program_assignStr(__VA_ARGS__) COMMA_SUCCESS) | 5720 | #define zdc_program_assignStr(...) (zdc_program_assignStr(__VA_ARGS__) COMMA_SUCCESS) |
5721 | #endif // ENABLE_DC | 5721 | #endif // ENABLE_DC |
5722 | 5722 | ||
5723 | static BC_STATUS zxc_program_copyToVar(char *name, bool var) | 5723 | static BC_STATUS zxc_program_popResultAndCopyToVar(char *name, bool var) |
5724 | { | 5724 | { |
5725 | BcStatus s; | 5725 | BcStatus s; |
5726 | BcResult *ptr, r; | 5726 | BcResult *ptr, r; |
@@ -5761,7 +5761,7 @@ static BC_STATUS zxc_program_copyToVar(char *name, bool var) | |||
5761 | 5761 | ||
5762 | RETURN_STATUS(s); | 5762 | RETURN_STATUS(s); |
5763 | } | 5763 | } |
5764 | #define zxc_program_copyToVar(...) (zxc_program_copyToVar(__VA_ARGS__) COMMA_SUCCESS) | 5764 | #define zxc_program_popResultAndCopyToVar(...) (zxc_program_popResultAndCopyToVar(__VA_ARGS__) COMMA_SUCCESS) |
5765 | 5765 | ||
5766 | static BC_STATUS zxc_program_assign(char inst) | 5766 | static BC_STATUS zxc_program_assign(char inst) |
5767 | { | 5767 | { |
@@ -5985,7 +5985,7 @@ static BC_STATUS zbc_program_call(char *code, size_t *idx) | |||
5985 | ) { | 5985 | ) { |
5986 | RETURN_STATUS(bc_error_variable_is_wrong_type()); | 5986 | RETURN_STATUS(bc_error_variable_is_wrong_type()); |
5987 | } | 5987 | } |
5988 | s = zxc_program_copyToVar(a->name, a->idx); | 5988 | s = zxc_program_popResultAndCopyToVar(a->name, a->idx); |
5989 | if (s) RETURN_STATUS(s); | 5989 | if (s) RETURN_STATUS(s); |
5990 | } | 5990 | } |
5991 | 5991 | ||
@@ -6019,11 +6019,10 @@ static BC_STATUS zbc_program_return(char inst) | |||
6019 | size_t i; | 6019 | size_t i; |
6020 | BcInstPtr *ip = bc_vec_top(&G.prog.exestack); | 6020 | BcInstPtr *ip = bc_vec_top(&G.prog.exestack); |
6021 | 6021 | ||
6022 | #if SANITY_CHECKS | ||
6022 | if (!STACK_HAS_EQUAL_OR_MORE_THAN(&G.prog.results, ip->results_len_before_call + (inst == XC_INST_RET))) | 6023 | if (!STACK_HAS_EQUAL_OR_MORE_THAN(&G.prog.results, ip->results_len_before_call + (inst == XC_INST_RET))) |
6023 | RETURN_STATUS(bc_error_stack_has_too_few_elements()); | 6024 | RETURN_STATUS(bc_error_stack_has_too_few_elements()); |
6024 | 6025 | #endif | |
6025 | f = xc_program_func(ip->func); | ||
6026 | res.t = XC_RESULT_TEMP; | ||
6027 | 6026 | ||
6028 | if (inst == XC_INST_RET) { | 6027 | if (inst == XC_INST_RET) { |
6029 | BcStatus s; | 6028 | BcStatus s; |
@@ -6034,12 +6033,21 @@ static BC_STATUS zbc_program_return(char inst) | |||
6034 | if (s) RETURN_STATUS(s); | 6033 | if (s) RETURN_STATUS(s); |
6035 | bc_num_init(&res.d.n, num->len); | 6034 | bc_num_init(&res.d.n, num->len); |
6036 | bc_num_copy(&res.d.n, num); | 6035 | bc_num_copy(&res.d.n, num); |
6036 | //} else if (f->void_func) { | ||
6037 | //prepare "void" result in res | ||
6037 | } else { | 6038 | } else { |
6038 | bc_num_init_DEF_SIZE(&res.d.n); | 6039 | bc_num_init_DEF_SIZE(&res.d.n); |
6039 | //bc_num_zero(&res.d.n); - already is | 6040 | //bc_num_zero(&res.d.n); - already is |
6040 | } | 6041 | } |
6042 | res.t = XC_RESULT_TEMP; | ||
6043 | |||
6044 | bc_vec_npop(&G.prog.results, G.prog.results.len - ip->results_len_before_call); | ||
6045 | bc_vec_push(&G.prog.results, &res); | ||
6046 | |||
6047 | bc_vec_pop(&G.prog.exestack); | ||
6041 | 6048 | ||
6042 | // We need to pop arguments as well, so this takes that into account. | 6049 | // We need to pop arguments as well, so this takes that into account. |
6050 | f = xc_program_func(ip->func); | ||
6043 | a = (void*)f->autos.v; | 6051 | a = (void*)f->autos.v; |
6044 | for (i = 0; i < f->autos.len; i++, a++) { | 6052 | for (i = 0; i < f->autos.len; i++, a++) { |
6045 | BcVec *v; | 6053 | BcVec *v; |
@@ -6047,10 +6055,6 @@ static BC_STATUS zbc_program_return(char inst) | |||
6047 | bc_vec_pop(v); | 6055 | bc_vec_pop(v); |
6048 | } | 6056 | } |
6049 | 6057 | ||
6050 | bc_vec_npop(&G.prog.results, G.prog.results.len - ip->results_len_before_call); | ||
6051 | bc_vec_push(&G.prog.results, &res); | ||
6052 | bc_vec_pop(&G.prog.exestack); | ||
6053 | |||
6054 | RETURN_STATUS(BC_STATUS_SUCCESS); | 6058 | RETURN_STATUS(BC_STATUS_SUCCESS); |
6055 | } | 6059 | } |
6056 | #define zbc_program_return(...) (zbc_program_return(__VA_ARGS__) COMMA_SUCCESS) | 6060 | #define zbc_program_return(...) (zbc_program_return(__VA_ARGS__) COMMA_SUCCESS) |
@@ -6679,7 +6683,7 @@ static BC_STATUS zxc_program_exec(void) | |||
6679 | } | 6683 | } |
6680 | case DC_INST_PUSH_TO_VAR: { | 6684 | case DC_INST_PUSH_TO_VAR: { |
6681 | char *name = xc_program_name(code, &ip->inst_idx); | 6685 | char *name = xc_program_name(code, &ip->inst_idx); |
6682 | s = zxc_program_copyToVar(name, true); | 6686 | s = zxc_program_popResultAndCopyToVar(name, true); |
6683 | free(name); | 6687 | free(name); |
6684 | break; | 6688 | break; |
6685 | } | 6689 | } |