diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-18 14:37:16 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-18 14:39:33 +0100 |
commit | 55f3cab7e9f61c1e9fc342f2d245d6b055a08b84 (patch) | |
tree | 3ebd6f171988f9ce3d006947301b3dccb594ad01 /miscutils | |
parent | a199cc95b726df7023c19fa5130a3b55287e43a2 (diff) | |
download | busybox-55f3cab7e9f61c1e9fc342f2d245d6b055a08b84.tar.gz |
bc: fix "echo -n '#foo' | bc" not eating last 'o'
function old new delta
zdc_parse_expr 656 653 -3
bc_lex_lineComment 39 36 -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6) Total: -6 bytes
text data bss dec hex filename
981424 485 7296 989205 f1815 busybox_old
981418 485 7296 989199 f180f busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/bc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index a5fcaf3bc..eaa28a94a 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -2655,9 +2655,13 @@ static FAST_FUNC void bc_result_free(void *result) static void bc_lex_lineComment(BcLex *l) { + // Try: echo -n '#foo' | bc + size_t i; l->t.t = BC_LEX_WHITESPACE; - while (l->i < l->len && l->buf[l->i++] != '\n'); - --l->i; + i = l->i; + while (i < l->len && l->buf[i] != '\n') + i++; + l->i = i; } static void bc_lex_whitespace(BcLex *l) @@ -2889,8 +2893,8 @@ static BC_STATUS zbc_lex_next(BcLex *l) // Comments are also BC_LEX_WHITESPACE tokens and eaten here. s = BC_STATUS_SUCCESS; do { - l->t.t = BC_LEX_EOF; if (l->i == l->len) { + l->t.t = BC_LEX_EOF; if (!G.input_fp) RETURN_STATUS(BC_STATUS_SUCCESS); if (!bc_lex_more_input(l)) { |