diff options
-rw-r--r-- | miscutils/bc.c | 27 |
1 files 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, | |||
6505 | BcParse prs; | 6505 | BcParse prs; |
6506 | BcInstPtr ip; | 6506 | BcInstPtr ip; |
6507 | size_t fidx, sidx; | 6507 | size_t fidx, sidx; |
6508 | BcNum *n; | ||
6509 | bool exec; | ||
6510 | 6508 | ||
6511 | if (!BC_PROG_STACK(&G.prog.results, 1)) | 6509 | if (!BC_PROG_STACK(&G.prog.results, 1)) |
6512 | return bc_error_stack_has_too_few_elements(); | 6510 | return bc_error_stack_has_too_few_elements(); |
@@ -6514,8 +6512,11 @@ static BcStatus bc_program_execStr(char *code, size_t *bgn, | |||
6514 | r = bc_vec_top(&G.prog.results); | 6512 | r = bc_vec_top(&G.prog.results); |
6515 | 6513 | ||
6516 | if (cond) { | 6514 | if (cond) { |
6517 | 6515 | BcNum *n = n; // for compiler | |
6518 | char *name, *then_name = bc_program_name(code, bgn), *else_name = NULL; | 6516 | bool exec; |
6517 | char *name; | ||
6518 | char *then_name = bc_program_name(code, bgn); | ||
6519 | char *else_name = NULL; | ||
6519 | 6520 | ||
6520 | if (code[*bgn] == BC_PARSE_STREND) | 6521 | if (code[*bgn] == BC_PARSE_STREND) |
6521 | (*bgn) += 1; | 6522 | (*bgn) += 1; |
@@ -6523,10 +6524,8 @@ static BcStatus bc_program_execStr(char *code, size_t *bgn, | |||
6523 | else_name = bc_program_name(code, bgn); | 6524 | else_name = bc_program_name(code, bgn); |
6524 | 6525 | ||
6525 | exec = r->d.n.len != 0; | 6526 | exec = r->d.n.len != 0; |
6526 | 6527 | name = then_name; | |
6527 | if (exec) | 6528 | if (!exec && else_name != NULL) { |
6528 | name = then_name; | ||
6529 | else if (else_name != NULL) { | ||
6530 | exec = true; | 6529 | exec = true; |
6531 | name = else_name; | 6530 | name = else_name; |
6532 | } | 6531 | } |
@@ -6547,17 +6546,15 @@ static BcStatus bc_program_execStr(char *code, size_t *bgn, | |||
6547 | } | 6546 | } |
6548 | 6547 | ||
6549 | sidx = n->rdx; | 6548 | sidx = n->rdx; |
6550 | } | 6549 | } else { |
6551 | else { | 6550 | if (r->t == BC_RESULT_STR) { |
6552 | |||
6553 | if (r->t == BC_RESULT_STR) | ||
6554 | sidx = r->d.id.idx; | 6551 | sidx = r->d.id.idx; |
6555 | else if (r->t == BC_RESULT_VAR) { | 6552 | } else if (r->t == BC_RESULT_VAR) { |
6553 | BcNum *n; | ||
6556 | s = bc_program_num(r, &n, false); | 6554 | s = bc_program_num(r, &n, false); |
6557 | if (s || !BC_PROG_STR(n)) goto exit; | 6555 | if (s || !BC_PROG_STR(n)) goto exit; |
6558 | sidx = n->rdx; | 6556 | sidx = n->rdx; |
6559 | } | 6557 | } else |
6560 | else | ||
6561 | goto exit; | 6558 | goto exit; |
6562 | } | 6559 | } |
6563 | 6560 | ||