diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-14 23:12:48 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-14 23:12:48 +0100 |
commit | 7b1df3db975c97799a23cf0699d8f0fd1d046f22 (patch) | |
tree | 5b01268b7145a8bb6c9d33f42e9638034eb1efc2 | |
parent | 17df882a575d4cba216abdfabefbebea66907b10 (diff) | |
download | busybox-7b1df3db975c97799a23cf0699d8f0fd1d046f22.tar.gz |
bc: pull zbc_lex_next() call out of zbc_parse_operator() into one caller that uses it
function old new delta
bc_parse_operator - 144 +144
bc_parse_expr_empty_ok 1788 1792 +4
zbc_parse_operator 170 - -170
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/0 up/down: 148/-170) Total: -22 bytes
text data bss dec hex filename
979938 485 7296 987719 f1247 busybox_old
979916 485 7296 987697 f1231 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/bc.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index b3ffe7bfd..e1a4b8f52 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -3611,7 +3611,7 @@ static void bc_parse_create(BcParse *p, size_t func) // We can calculate the conversion between tokens and exprs by subtracting the // position of the first operator in the lex enum and adding the position of the // first in the expr enum. Note: This only works for binary operators. -#define BC_PARSE_TOKEN_INST(t) ((char) ((t) -BC_LEX_NEG + BC_INST_NEG)) +#define BC_PARSE_TOKEN_INST(t) ((char) ((t) - BC_LEX_NEG + BC_INST_NEG)) static BC_STATUS zbc_parse_else(BcParse *p); static BC_STATUS zbc_parse_stmt(BcParse *p); @@ -3623,17 +3623,14 @@ static BcStatus bc_parse_expr_empty_ok(BcParse *p, uint8_t flags, BcParseNext ne # define zbc_parse_expr(...) (zbc_parse_expr(__VA_ARGS__), BC_STATUS_SUCCESS) #endif -static BC_STATUS zbc_parse_operator(BcParse *p, BcLexType type, size_t start, - size_t *nexprs, bool next) +static void bc_parse_operator(BcParse *p, BcLexType type, size_t start, + size_t *nexprs) { - BcStatus s = BC_STATUS_SUCCESS; - BcLexType t; char l, r = bc_parse_op_PREC(type - BC_LEX_OP_INC); bool left = bc_parse_op_LEFT(type - BC_LEX_OP_INC); while (p->ops.len > start) { - - t = BC_PARSE_TOP_OP(p); + BcLexType t = BC_PARSE_TOP_OP(p); if (t == BC_LEX_LPAREN) break; l = bc_parse_op_PREC(t - BC_LEX_OP_INC); @@ -3641,17 +3638,11 @@ static BC_STATUS zbc_parse_operator(BcParse *p, BcLexType type, size_t start, bc_parse_push(p, BC_PARSE_TOKEN_INST(t)); bc_vec_pop(&p->ops); - *nexprs -= t != BC_LEX_OP_BOOL_NOT && t != BC_LEX_NEG; + *nexprs -= (t != BC_LEX_OP_BOOL_NOT && t != BC_LEX_NEG); } bc_vec_push(&p->ops, &type); - if (next) s = zbc_lex_next(&p->l); - - RETURN_STATUS(s); } -#if ERRORS_ARE_FATAL -# define zbc_parse_operator(...) (zbc_parse_operator(__VA_ARGS__), BC_STATUS_SUCCESS) -#endif static BC_STATUS zbc_parse_rightParen(BcParse *p, size_t ops_bgn, size_t *nexs) { @@ -3964,7 +3955,7 @@ static BC_STATUS zbc_parse_minus(BcParse *p, BcInst *prev, size_t ops_bgn, if (type != BC_LEX_OP_MINUS) bc_vec_push(&p->ops, &type); else - s = zbc_parse_operator(p, type, ops_bgn, nexprs, false); + bc_parse_operator(p, type, ops_bgn, nexprs); RETURN_STATUS(s); } @@ -4787,7 +4778,8 @@ static BcStatus bc_parse_expr_empty_ok(BcParse *p, uint8_t flags, BcParseNext ne nrelops += t >= BC_LEX_OP_REL_EQ && t <= BC_LEX_OP_REL_GT; prev = BC_PARSE_TOKEN_INST(t); - s = zbc_parse_operator(p, t, ops_bgn, &nexprs, true); + bc_parse_operator(p, t, ops_bgn, &nexprs); + s = zbc_lex_next(&p->l); rprn = get_token = false; bin_last = t != BC_LEX_OP_BOOL_NOT; |