aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-01-04 00:05:07 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2019-01-04 00:05:07 +0100
commit19c3eb0b049c46d365c89c6ff05295fbae0f40a8 (patch)
tree33675b3302fedec6d96d075643ae944a088320e4
parent96b5ec10fb8abdb8050a6af87330e6cf3d881d5a (diff)
downloadbusybox-w32-19c3eb0b049c46d365c89c6ff05295fbae0f40a8.tar.gz
busybox-w32-19c3eb0b049c46d365c89c6ff05295fbae0f40a8.tar.bz2
busybox-w32-19c3eb0b049c46d365c89c6ff05295fbae0f40a8.zip
bc: remove extra div/0 test, remove test for string function parameter
function old new delta zbc_program_call 354 332 -22 zxc_program_assign 426 385 -41 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-63) Total: -63 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 6d8e2d991..3bcda08a8 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -5793,9 +5793,6 @@ static BC_STATUS zxc_program_assign(char inst)
5793 RETURN_STATUS(bc_error_bad_assignment()); 5793 RETURN_STATUS(bc_error_bad_assignment());
5794 5794
5795#if ENABLE_BC 5795#if ENABLE_BC
5796 if (inst == BC_INST_ASSIGN_DIVIDE && !bc_num_cmp(r, &G.prog.zero))
5797 RETURN_STATUS(bc_error("divide by zero"));
5798
5799 if (assign) 5796 if (assign)
5800 bc_num_copy(l, r); 5797 bc_num_copy(l, r);
5801 else { 5798 else {
@@ -5960,12 +5957,10 @@ static BC_STATUS zbc_program_call(char *code, size_t *idx)
5960{ 5957{
5961 BcInstPtr ip; 5958 BcInstPtr ip;
5962 size_t i, nparams; 5959 size_t i, nparams;
5963 BcFunc *func;
5964 BcId *a; 5960 BcId *a;
5965 BcResult *arg; 5961 BcFunc *func;
5966 5962
5967 nparams = xc_program_index(code, idx); 5963 nparams = xc_program_index(code, idx);
5968 ip.inst_idx = 0;
5969 ip.func = xc_program_index(code, idx); 5964 ip.func = xc_program_index(code, idx);
5970 func = xc_program_func(ip.func); 5965 func = xc_program_func(ip.func);
5971 5966
@@ -5975,17 +5970,21 @@ static BC_STATUS zbc_program_call(char *code, size_t *idx)
5975 if (nparams != func->nparams) { 5970 if (nparams != func->nparams) {
5976 RETURN_STATUS(bc_error_fmt("function has %u parameters, but called with %u", func->nparams, nparams)); 5971 RETURN_STATUS(bc_error_fmt("function has %u parameters, but called with %u", func->nparams, nparams));
5977 } 5972 }
5973 ip.inst_idx = 0;
5978 ip.results_len_before_call = G.prog.results.len - nparams; 5974 ip.results_len_before_call = G.prog.results.len - nparams;
5979 5975
5980 for (i = 0; i < nparams; ++i) { 5976 for (i = 0; i < nparams; ++i) {
5977 BcResult *arg;
5981 BcStatus s; 5978 BcStatus s;
5982 5979
5983 a = bc_vec_item(&func->autos, nparams - 1 - i); 5980 a = bc_vec_item(&func->autos, nparams - 1 - i);
5984 arg = bc_vec_top(&G.prog.results); 5981 arg = bc_vec_top(&G.prog.results);
5985 5982
5986 if ((!a->idx) != (arg->t == XC_RESULT_ARRAY) || arg->t == XC_RESULT_STR) 5983 if ((!a->idx) != (arg->t == XC_RESULT_ARRAY) // array/variable mismatch
5984 // || arg->t == XC_RESULT_STR - impossible, f("str") is not a legal syntax (strings are not bc expressions)
5985 ) {
5987 RETURN_STATUS(bc_error_variable_is_wrong_type()); 5986 RETURN_STATUS(bc_error_variable_is_wrong_type());
5988 5987 }
5989 s = zxc_program_copyToVar(a->name, a->idx); 5988 s = zxc_program_copyToVar(a->name, a->idx);
5990 if (s) RETURN_STATUS(s); 5989 if (s) RETURN_STATUS(s);
5991 } 5990 }