diff options
author | Brian Foley <bpfoley@google.com> | 2019-09-05 10:46:22 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-10-21 16:54:40 +0200 |
commit | 4699b932446f809d747d97f8e24b5d48608f7276 (patch) | |
tree | 5d761ac8e1b891871ddf6d96490e28df541bc945 /miscutils | |
parent | 244c0ebb4f71fb9f400d2242bbdeaca0c138c547 (diff) | |
download | busybox-w32-4699b932446f809d747d97f8e24b5d48608f7276.tar.gz busybox-w32-4699b932446f809d747d97f8e24b5d48608f7276.tar.bz2 busybox-w32-4699b932446f809d747d97f8e24b5d48608f7276.zip |
dc: execute shouldn't pop if stack head is not a string
This matches the behaviour of both GNU dc (as specified in
its man page), and BSD dc (where stack_popstring() pops
only if the head is a string.)
Add a couple of tests to verify this behavior.
function old new delta
zxc_vm_process 6882 6884 +2
Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/bc.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index aba51e5f8..9a9880706 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -6521,7 +6521,7 @@ static BC_STATUS zdc_program_execStr(char *code, size_t *bgn, bool cond) | |||
6521 | if (s || !BC_PROG_STR(n)) goto exit; | 6521 | if (s || !BC_PROG_STR(n)) goto exit; |
6522 | sidx = n->rdx; | 6522 | sidx = n->rdx; |
6523 | } else | 6523 | } else |
6524 | goto exit; | 6524 | goto exit_nopop; |
6525 | } | 6525 | } |
6526 | 6526 | ||
6527 | fidx = sidx + BC_PROG_REQ_FUNCS; | 6527 | fidx = sidx + BC_PROG_REQ_FUNCS; |
@@ -6561,6 +6561,7 @@ static BC_STATUS zdc_program_execStr(char *code, size_t *bgn, bool cond) | |||
6561 | RETURN_STATUS(BC_STATUS_SUCCESS); | 6561 | RETURN_STATUS(BC_STATUS_SUCCESS); |
6562 | exit: | 6562 | exit: |
6563 | bc_vec_pop(&G.prog.results); | 6563 | bc_vec_pop(&G.prog.results); |
6564 | exit_nopop: | ||
6564 | RETURN_STATUS(s); | 6565 | RETURN_STATUS(s); |
6565 | } | 6566 | } |
6566 | #define zdc_program_execStr(...) (zdc_program_execStr(__VA_ARGS__) COMMA_SUCCESS) | 6567 | #define zdc_program_execStr(...) (zdc_program_execStr(__VA_ARGS__) COMMA_SUCCESS) |