aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-23 00:13:15 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-23 00:13:15 +0100
commit9471bd46603d9f61c76d672b0a679c2b9446c3cf (patch)
tree1bde732177168db887f4c87b2f2ac663f67955ff
parent01eb5e9da1546f5410831d3a5a8d268d630d2653 (diff)
downloadbusybox-w32-9471bd46603d9f61c76d672b0a679c2b9446c3cf.tar.gz
busybox-w32-9471bd46603d9f61c76d672b0a679c2b9446c3cf.tar.bz2
busybox-w32-9471bd46603d9f61c76d672b0a679c2b9446c3cf.zip
bc: fix empty lines in dc generating "bad token" message
function old new delta zdc_program_asciify - 370 +370 zbc_program_pushArray - 147 +147 zbc_vm_process 824 828 +4 zbc_program_exec 4182 4046 -136 zdc_program_printStream 146 - -146 zbc_program_read 268 - -268 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 1/1 up/down: 521/-550) Total: -29 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 25150a9eb..a7b8aa4bb 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -6695,9 +6695,18 @@ static BC_STATUS zbc_vm_process(const char *text)
6695// "print 1" part. 6695// "print 1" part.
6696 IF_BC(s = zbc_parse_stmt_or_funcdef(&G.prs)); 6696 IF_BC(s = zbc_parse_stmt_or_funcdef(&G.prs));
6697 } else { 6697 } else {
6698 // Most of dc parsing assumes all whitespace,
6699 // including '\n', is eaten.
6700 while (G.prs.l.t.t == BC_LEX_NLINE) {
6701 s = zbc_lex_next(&G.prs.l);
6702 if (s) goto err;
6703 if (G.prs.l.t.t == BC_LEX_EOF)
6704 goto done;
6705 }
6698 IF_DC(s = zdc_parse_expr(&G.prs)); 6706 IF_DC(s = zdc_parse_expr(&G.prs));
6699 } 6707 }
6700 if (s || G_interrupt) { 6708 if (s || G_interrupt) {
6709 err:
6701 bc_parse_reset(&G.prs); // includes bc_program_reset() 6710 bc_parse_reset(&G.prs); // includes bc_program_reset()
6702 RETURN_STATUS(BC_STATUS_FAILURE); 6711 RETURN_STATUS(BC_STATUS_FAILURE);
6703 } 6712 }
@@ -6735,13 +6744,6 @@ static BC_STATUS zbc_vm_process(const char *text)
6735 IF_BC(bc_vec_pop_all(&f->strs);) 6744 IF_BC(bc_vec_pop_all(&f->strs);)
6736 IF_BC(bc_vec_pop_all(&f->consts);) 6745 IF_BC(bc_vec_pop_all(&f->consts);)
6737 } else { 6746 } else {
6738 // Most of dc parsing assumes all whitespace,
6739 // including '\n', is eaten.
6740 if (G.prs.l.t.t == BC_LEX_NLINE) {
6741 s = zbc_lex_next(&G.prs.l);
6742 if (s) RETURN_STATUS(s);
6743 }
6744
6745 if (G.prog.results.len == 0 6747 if (G.prog.results.len == 0
6746 && G.prog.vars.len == 0 6748 && G.prog.vars.len == 0
6747 ) { 6749 ) {
@@ -6762,7 +6764,7 @@ static BC_STATUS zbc_vm_process(const char *text)
6762 bc_vec_pop_all(&f->code); 6764 bc_vec_pop_all(&f->code);
6763 ip->inst_idx = 0; 6765 ip->inst_idx = 0;
6764 } 6766 }
6765 6767 done:
6766 dbg_lex_done("%s:%d done", __func__, __LINE__); 6768 dbg_lex_done("%s:%d done", __func__, __LINE__);
6767 RETURN_STATUS(s); 6769 RETURN_STATUS(s);
6768} 6770}