summaryrefslogtreecommitdiffhomepage
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-24 01:53:55 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-24 02:01:32 +0100
commit81293c8af04913a632c32a305e505dcbf059d9d5 (patch)
tree4ec3eeb4b815ad84018cbafa4c0e227d8abc2e8b /miscutils
parent73b2c6082574aff51e5bb6560449c5fc746cf7bf (diff)
dc: without -x, do not parse extended regs: 's p' means: store to ' ' reg, print
function old new delta zbc_lex_next 2240 2233 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-7) Total: -7 bytes text data bss dec hex filename 981437 485 7296 989218 f1822 busybox_old 981412 485 7296 989193 f1809 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index d2583313c..ac3eaff96 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -3352,16 +3352,13 @@ static BC_STATUS zbc_lex_token(BcLex *l)
#if ENABLE_DC
static BC_STATUS zdc_lex_register(BcLex *l)
{
- if (isspace(l->buf[l->i - 1])) {
- bc_lex_whitespace(l);
- ++l->i;
- if (!G_exreg)
- RETURN_STATUS(bc_error("extended register"));
+ if (G_exreg && isspace(l->buf[l->i])) {
+ bc_lex_whitespace(l); // eats whitespace (but not newline)
+ l->i++; // bc_lex_name() expects this
bc_lex_name(l);
- }
- else {
+ } else {
bc_vec_pop_all(&l->t.v);
- bc_vec_push(&l->t.v, &l->buf[l->i - 1]);
+ bc_vec_push(&l->t.v, &l->buf[l->i++]);
bc_vec_pushZeroByte(&l->t.v);
l->t.t = BC_LEX_NAME;
}
@@ -3425,8 +3422,8 @@ static BC_STATUS zdc_lex_token(BcLex *l)
BC_LEX_STORE_PUSH,
};
- BcStatus s = BC_STATUS_SUCCESS;
- char c = l->buf[l->i++], c2;
+ BcStatus s;
+ char c, c2;
size_t i;
for (i = 0; i < ARRAY_SIZE(dc_lex_regs); ++i) {
@@ -3434,6 +3431,8 @@ static BC_STATUS zdc_lex_token(BcLex *l)
RETURN_STATUS(zdc_lex_register(l));
}
+ s = BC_STATUS_SUCCESS;
+ c = l->buf[l->i++];
if (c >= '%' && c <= '~'
&& (l->t.t = dc_char_to_LEX[c - '%']) != BC_LEX_INVALID
) {
@@ -3462,7 +3461,7 @@ static BC_STATUS zdc_lex_token(BcLex *l)
case '\f':
case '\r':
case ' ':
- l->newline = (c == '\n');
+ l->newline = 0; // was (c == '\n')
bc_lex_whitespace(l);
break;
case '!':