summaryrefslogtreecommitdiffhomepage
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-16 21:08:30 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-16 21:08:30 +0100
commit5d18f6be90a940f80c3b7238dc7a8b42a41f55bd (patch)
tree9e1bb7f45a3ba0aa834d4a27e62cf5ab0a3d55ff /miscutils
parentcb18b546f7ee9d1c9315c7357ab620e55f0fa8f3 (diff)
bc: fix "print 1,2,3" parsing
function old new delta zbc_parse_stmt_possibly_auto 2245 2180 -65 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-65) Total: -65 bytes text data bss dec hex filename 982237 485 7296 990018 f1b42 busybox_old 982152 485 7296 989933 f1aed busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 2dc64dbc6..9f40a551e 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -4048,38 +4048,23 @@ static BC_STATUS zbc_parse_print(BcParse *p)
{
BcStatus s;
BcLexType type;
- bool comma;
- s = zbc_lex_next(&p->l);
- if (s) RETURN_STATUS(s);
-
- type = p->l.t.t;
-
- if (type == BC_LEX_SCOLON || type == BC_LEX_NLINE)
- RETURN_STATUS(bc_error("bad print statement"));
-
- comma = false;
- while (type != BC_LEX_SCOLON && type != BC_LEX_NLINE) {
+ for (;;) {
+ s = zbc_lex_next(&p->l);
+ if (s) RETURN_STATUS(s);
+ type = p->l.t.t;
if (type == BC_LEX_STR) {
s = zbc_parse_string(p, BC_INST_PRINT_POP);
- if (s) RETURN_STATUS(s);
} else {
s = zbc_parse_expr(p, 0, bc_parse_next_print);
- if (s) RETURN_STATUS(s);
bc_parse_push(p, BC_INST_PRINT_POP);
}
-
- comma = p->l.t.t == BC_LEX_COMMA;
- if (comma) {
- s = zbc_lex_next(&p->l);
- if (s) RETURN_STATUS(s);
- }
- type = p->l.t.t;
+ if (s) RETURN_STATUS(s);
+ if (p->l.t.t != BC_LEX_COMMA)
+ break;
}
- if (comma) RETURN_STATUS(bc_error_bad_token());
-
- RETURN_STATUS(zbc_lex_next(&p->l));
+ RETURN_STATUS(s);
}
#if ERRORS_ARE_FATAL
# define zbc_parse_print(...) (zbc_parse_print(__VA_ARGS__), BC_STATUS_SUCCESS)