diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-01-04 06:18:00 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-01-04 06:18:00 +0100 |
| commit | 1db367a8e65a74277360a89885ff7d377b5feb8b (patch) | |
| tree | e911cbe5e1b234e38cd68e63f4a4afea1495e980 /miscutils | |
| parent | 6842c6062a201cc34a262b4c450cf8e1374e9e3a (diff) | |
| download | busybox-w32-1db367a8e65a74277360a89885ff7d377b5feb8b.tar.gz busybox-w32-1db367a8e65a74277360a89885ff7d377b5feb8b.tar.bz2 busybox-w32-1db367a8e65a74277360a89885ff7d377b5feb8b.zip | |
dc: fit returning of string
function old new delta
zxc_program_exec 4087 4098 +11
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/bc.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 1e8056c01..e497b0d02 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
| @@ -6020,6 +6020,9 @@ static BC_STATUS zbc_program_return(char inst) | |||
| 6020 | BcInstPtr *ip = bc_vec_top(&G.prog.exestack); | 6020 | BcInstPtr *ip = bc_vec_top(&G.prog.exestack); |
| 6021 | 6021 | ||
| 6022 | if (inst == XC_INST_RET) { | 6022 | if (inst == XC_INST_RET) { |
| 6023 | // bc needs this for e.g. RESULT_CONSTANT ("return 5") | ||
| 6024 | // because bc constants are per-function. | ||
| 6025 | // TODO: maybe avoid if value is already RESULT_TEMP? | ||
| 6023 | BcStatus s; | 6026 | BcStatus s; |
| 6024 | BcNum *num; | 6027 | BcNum *num; |
| 6025 | BcResult *operand = bc_vec_top(&G.prog.results); | 6028 | BcResult *operand = bc_vec_top(&G.prog.results); |
| @@ -6458,7 +6461,17 @@ static BC_STATUS zxc_program_exec(void) | |||
| 6458 | 6461 | ||
| 6459 | dbg_exec("inst at %zd:%d results.len:%d", ip->inst_idx - 1, inst, G.prog.results.len); | 6462 | dbg_exec("inst at %zd:%d results.len:%d", ip->inst_idx - 1, inst, G.prog.results.len); |
| 6460 | switch (inst) { | 6463 | switch (inst) { |
| 6464 | case XC_INST_RET: | ||
| 6465 | if (IS_DC) { // end of '?' reached | ||
| 6466 | bc_vec_pop(&G.prog.exestack); | ||
| 6467 | goto read_updated_ip; | ||
| 6468 | } | ||
| 6469 | // bc: fall through | ||
| 6461 | #if ENABLE_BC | 6470 | #if ENABLE_BC |
| 6471 | case BC_INST_RET0: | ||
| 6472 | dbg_exec("BC_INST_RET[0]:"); | ||
| 6473 | s = zbc_program_return(inst); | ||
| 6474 | goto read_updated_ip; | ||
| 6462 | case BC_INST_JUMP_ZERO: { | 6475 | case BC_INST_JUMP_ZERO: { |
| 6463 | BcNum *num; | 6476 | BcNum *num; |
| 6464 | bool zero; | 6477 | bool zero; |
| @@ -6495,11 +6508,6 @@ static BC_STATUS zxc_program_exec(void) | |||
| 6495 | dbg_exec("BC_INST_HALT:"); | 6508 | dbg_exec("BC_INST_HALT:"); |
| 6496 | QUIT_OR_RETURN_TO_MAIN; | 6509 | QUIT_OR_RETURN_TO_MAIN; |
| 6497 | break; | 6510 | break; |
| 6498 | case XC_INST_RET: | ||
| 6499 | case BC_INST_RET0: | ||
| 6500 | dbg_exec("BC_INST_RET[0]:"); | ||
| 6501 | s = zbc_program_return(inst); | ||
| 6502 | goto read_updated_ip; | ||
| 6503 | case XC_INST_BOOL_OR: | 6511 | case XC_INST_BOOL_OR: |
| 6504 | case XC_INST_BOOL_AND: | 6512 | case XC_INST_BOOL_AND: |
| 6505 | #endif // ENABLE_BC | 6513 | #endif // ENABLE_BC |
