[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox-cvs
Subject:    [git commit branch/1_30_stable] bc: remove extra div/0 test, remove test for string function paramet
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2019-02-14 13:40:57
Message-ID: 20190214134247.B046C8A34D () busybox ! osuosl ! org
[Download RAW message or body]

commit: https://git.busybox.net/busybox/commit/?id=f40467d3693e29d1830507bbeae442af2063dcb3
                
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/1_30_stable

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>
---
 miscutils/bc.c | 15 +++++++--------
 1 file 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)
 		RETURN_STATUS(bc_error_bad_assignment());
 
 #if ENABLE_BC
-	if (inst == BC_INST_ASSIGN_DIVIDE && !bc_num_cmp(r, &G.prog.zero))
-		RETURN_STATUS(bc_error("divide by zero"));
-
 	if (assign)
 		bc_num_copy(l, r);
 	else {
@@ -5960,12 +5957,10 @@ static BC_STATUS zbc_program_call(char *code, size_t *idx)
 {
 	BcInstPtr ip;
 	size_t i, nparams;
-	BcFunc *func;
 	BcId *a;
-	BcResult *arg;
+	BcFunc *func;
 
 	nparams = xc_program_index(code, idx);
-	ip.inst_idx = 0;
 	ip.func = xc_program_index(code, idx);
 	func = xc_program_func(ip.func);
 
@@ -5975,17 +5970,21 @@ static BC_STATUS zbc_program_call(char *code, size_t *idx)
 	if (nparams != func->nparams) {
 		RETURN_STATUS(bc_error_fmt("function has %u parameters, but called with %u", \
func->nparams, nparams));  }
+	ip.inst_idx = 0;
 	ip.results_len_before_call = G.prog.results.len - nparams;
 
 	for (i = 0; i < nparams; ++i) {
+		BcResult *arg;
 		BcStatus s;
 
 		a = bc_vec_item(&func->autos, nparams - 1 - i);
 		arg = bc_vec_top(&G.prog.results);
 
-		if ((!a->idx) != (arg->t == XC_RESULT_ARRAY) || arg->t == XC_RESULT_STR)
+		if ((!a->idx) != (arg->t == XC_RESULT_ARRAY) // array/variable mismatch
+		// || arg->t == XC_RESULT_STR - impossible, f("str") is not a legal syntax \
(strings are not bc expressions) +		) {
 			RETURN_STATUS(bc_error_variable_is_wrong_type());
-
+		}
 		s = zxc_program_copyToVar(a->name, a->idx);
 		if (s) RETURN_STATUS(s);
 	}
_______________________________________________
busybox-cvs mailing list
busybox-cvs@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic