bc: handle BIN_FILE and LEX_BAD_CHAR errors at the site of detection
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 3 Dec 2018 15:06:02 +0000 (16:06 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 5 Dec 2018 14:43:35 +0000 (15:43 +0100)
commitc1c2470f843c0b8218dd3611330a941b00d0cc34
tree59dd8c0a1b3c31954bb699513e098b28f7e90798
parentd4744adf35c678554e609a74eeebc7b7603ee25d
bc: handle BIN_FILE and LEX_BAD_CHAR errors at the site of detection

The most informative message can be generated at the location
where error is detected. The "error codes" are stupid:
print error meesage immediately, then just return "there was an error"
indicator.

All error codes will be converted. For now, converting these two.

For now, this and following changes will degrade error messages
quality. For example, file name and line number printouts may be lost.
This will be re-added later.

This change anlso fixes handling of invalid stdin input:
this used to cause interactive bc to exit:

....
>>> ς
bc: illegal character 0xcf
bc: illegal character 0x82
>>> _

function                                             old     new   delta
bc_error                                               -      42     +42
bc_lex_token                                        1333    1369     +36
dc_lex_token                                         675     695     +20
bc_read_line                                         311     325     +14
bc_num_a                                             456     454      -2
bc_err_msgs                                          188     184      -4
bc_num_ulong                                          95      85     -10
bc_vm_run                                           1984    1955     -29
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/4 up/down: 112/-45)            Total: 67 bytes
   text    data     bss     dec     hex filename
 987828     485    7296  995609   f3119 busybox_old
 987929     485    7296  995710   f317e busybox_unstripped

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