diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-01-04 05:41:47 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-02-14 14:40:57 +0100 |
commit | d2651fb775df3a81058d3b39baf2431083da179f (patch) | |
tree | ff58abe62ba37c34e8ea1e8993f3625a520d0c36 | |
parent | fb001145e1a7363a40a69592e0c1426dd24eb84f (diff) | |
download | busybox-w32-d2651fb775df3a81058d3b39baf2431083da179f.tar.gz busybox-w32-d2651fb775df3a81058d3b39baf2431083da179f.tar.bz2 busybox-w32-d2651fb775df3a81058d3b39baf2431083da179f.zip |
dc: fix '?'
function old new delta
zdc_parse_expr 470 479 +9
zxc_vm_process 839 814 -25
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 9/-25) Total: -16 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/bc.c | 13 | ||||
-rwxr-xr-x | testsuite/dc.tests | 5 |
2 files changed, 9 insertions, 9 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index ec3560c2b..1e8056c01 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -5054,6 +5054,9 @@ static BC_STATUS zdc_parse_expr(void) | |||
5054 | BcParse *p = &G.prs; | 5054 | BcParse *p = &G.prs; |
5055 | int i; | 5055 | int i; |
5056 | 5056 | ||
5057 | if (p->lex == XC_LEX_NLINE) | ||
5058 | RETURN_STATUS(zxc_lex_next()); | ||
5059 | |||
5057 | i = (int)p->lex - (int)XC_LEX_OP_POWER; | 5060 | i = (int)p->lex - (int)XC_LEX_OP_POWER; |
5058 | if (i >= 0) { | 5061 | if (i >= 0) { |
5059 | BcInst inst = dc_LEX_to_INST[i]; | 5062 | BcInst inst = dc_LEX_to_INST[i]; |
@@ -6766,14 +6769,6 @@ static BC_STATUS zxc_vm_process(const char *text) | |||
6766 | #endif | 6769 | #endif |
6767 | } else { | 6770 | } else { |
6768 | #if ENABLE_DC | 6771 | #if ENABLE_DC |
6769 | // Most of dc parsing assumes all whitespace, | ||
6770 | // including '\n', is eaten. | ||
6771 | while (G.prs.lex == XC_LEX_NLINE) { | ||
6772 | s = zxc_lex_next(); | ||
6773 | if (s) goto err; | ||
6774 | if (G.prs.lex == XC_LEX_EOF) | ||
6775 | goto done; | ||
6776 | } | ||
6777 | s = zdc_parse_expr(); | 6772 | s = zdc_parse_expr(); |
6778 | #endif | 6773 | #endif |
6779 | } | 6774 | } |
@@ -6836,7 +6831,7 @@ static BC_STATUS zxc_vm_process(const char *text) | |||
6836 | bc_vec_pop_all(&f->code); | 6831 | bc_vec_pop_all(&f->code); |
6837 | ip->inst_idx = 0; | 6832 | ip->inst_idx = 0; |
6838 | } | 6833 | } |
6839 | IF_DC(done:) | 6834 | |
6840 | dbg_lex_done("%s:%d done", __func__, __LINE__); | 6835 | dbg_lex_done("%s:%d done", __func__, __LINE__); |
6841 | RETURN_STATUS(s); | 6836 | RETURN_STATUS(s); |
6842 | } | 6837 | } |
diff --git a/testsuite/dc.tests b/testsuite/dc.tests index 29b413cad..87b1e71c3 100755 --- a/testsuite/dc.tests +++ b/testsuite/dc.tests | |||
@@ -41,6 +41,11 @@ testing "dc complex without spaces (multiple args)" \ | |||
41 | "16\n" \ | 41 | "16\n" \ |
42 | "" "" | 42 | "" "" |
43 | 43 | ||
44 | testing "dc read" \ | ||
45 | "dc -finput" \ | ||
46 | "2\n9\n1\n" \ | ||
47 | "1?2\nf" "9\n" | ||
48 | |||
44 | optional FEATURE_DC_BIG | 49 | optional FEATURE_DC_BIG |
45 | # All tests below depend on FEATURE_DC_BIG | 50 | # All tests below depend on FEATURE_DC_BIG |
46 | 51 | ||