[git commit] bc: in bc_program_execStr(), push two variables into inner scope

Denys Vlasenko vda.linux at googlemail.com
Sun Dec 9 01:54:06 UTC 2018


commit: https://git.busybox.net/busybox/commit/?id=5ec4b491258be628734f5c8fa315a1df55bffcf7
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
bc_program_execStr                                   502     496      -6

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 miscutils/bc.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/miscutils/bc.c b/miscutils/bc.c
index 9f44f83f5..0dc3f843c 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -6505,8 +6505,6 @@ static BcStatus bc_program_execStr(char *code, size_t *bgn,
 	BcParse prs;
 	BcInstPtr ip;
 	size_t fidx, sidx;
-	BcNum *n;
-	bool exec;
 
 	if (!BC_PROG_STACK(&G.prog.results, 1))
 		return bc_error_stack_has_too_few_elements();
@@ -6514,8 +6512,11 @@ static BcStatus bc_program_execStr(char *code, size_t *bgn,
 	r = bc_vec_top(&G.prog.results);
 
 	if (cond) {
-
-		char *name, *then_name = bc_program_name(code, bgn), *else_name = NULL;
+		BcNum *n = n; // for compiler
+		bool exec;
+		char *name;
+		char *then_name = bc_program_name(code, bgn);
+		char *else_name = NULL;
 
 		if (code[*bgn] == BC_PARSE_STREND)
 			(*bgn) += 1;
@@ -6523,10 +6524,8 @@ static BcStatus bc_program_execStr(char *code, size_t *bgn,
 			else_name = bc_program_name(code, bgn);
 
 		exec = r->d.n.len != 0;
-
-		if (exec)
-			name = then_name;
-		else if (else_name != NULL) {
+		name = then_name;
+		if (!exec && else_name != NULL) {
 			exec = true;
 			name = else_name;
 		}
@@ -6547,17 +6546,15 @@ static BcStatus bc_program_execStr(char *code, size_t *bgn,
 		}
 
 		sidx = n->rdx;
-	}
-	else {
-
-		if (r->t == BC_RESULT_STR)
+	} else {
+		if (r->t == BC_RESULT_STR) {
 			sidx = r->d.id.idx;
-		else if (r->t == BC_RESULT_VAR) {
+		} else if (r->t == BC_RESULT_VAR) {
+			BcNum *n;
 			s = bc_program_num(r, &n, false);
 			if (s || !BC_PROG_STR(n)) goto exit;
 			sidx = n->rdx;
-		}
-		else
+		} else
 			goto exit;
 	}
 


More information about the busybox-cvs mailing list