summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2018-12-09 02:54:06 +0100
committerDenys Vlasenko2018-12-09 02:54:06 +0100
commit5ec4b491258be628734f5c8fa315a1df55bffcf7 (patch)
tree376fe5a49e8f0212bd3fee1a0e25b12372a99eb2
parent927a7d6853da2f528ae13db57fc23c6527549782 (diff)
downloadbusybox-5ec4b491258be628734f5c8fa315a1df55bffcf7.zip
busybox-5ec4b491258be628734f5c8fa315a1df55bffcf7.tar.gz
bc: in bc_program_execStr(), push two variables into inner scope
function old new delta bc_program_execStr 502 496 -6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 9f44f83..0dc3f84 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;
}