bc: remove "error after expression parsing" check
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 17 Dec 2018 15:54:37 +0000 (16:54 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 17 Dec 2018 16:00:29 +0000 (17:00 +0100)
commit4b72aebe80aaa50a765d5ff61d7d67ed731502d9
treed922437e5da9bf034d78622dc2f5b1e0e0f539db
parentb44a7f1d6642e2da39e9f27e0b504f662ca443a2
bc: remove "error after expression parsing" check

It is misplaced: caller knows better what can or cannot follow the expression.
Sometimes even caller's caller: "if (1) return a+b else..." -
parser of "return" does not know that "else" after it is valid,
parser of stmt does not know it either, - only parser of
"if" knows it!

The removed code balked on e.g. "{ print 1 }" statement.

This does not break any valid programs, but starts accepting some
invalid ones, e.g. "print 1 print 2" would work.

function                                             old     new   delta
zcommon_parse_expr                                    40      32      -8
zbc_parse_name                                       509     494     -15
zbc_parse_stmt_possibly_auto                        1678    1638     -40
bc_parse_expr_empty_ok                              2025    1977     -48
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-111)           Total: -111 bytes
   text    data     bss     dec     hex filename
 981599     485    7296  989380   f18c4 busybox_old
 981488     485    7296  989269   f1855 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/bc.c
testsuite/bc.tests