aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-25 01:21:16 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-25 01:21:16 +0100
commitd0238d83f0311cfab52897acc739148879598621 (patch)
tree71bf3d58d7f6d2d3679cd77ce9b6c5e972b0090f
parentbb116031a038237ecc82896fb6b12b89b72f8d91 (diff)
downloadbusybox-w32-d0238d83f0311cfab52897acc739148879598621.tar.gz
busybox-w32-d0238d83f0311cfab52897acc739148879598621.tar.bz2
busybox-w32-d0238d83f0311cfab52897acc739148879598621.zip
bc: simplify bc_parse_expr_empty_ok()
function old new delta bc_parse_expr_empty_ok 1819 1810 -9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 5d9bae47e..a57de97a5 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -591,7 +591,7 @@ enum {
591 + (EXBITS(0,1,1,0,0,0,0,0) << (7*8)) // 56: return scale sqrt while 591 + (EXBITS(0,1,1,0,0,0,0,0) << (7*8)) // 56: return scale sqrt while
592#undef EXBITS 592#undef EXBITS
593}; 593};
594static ALWAYS_INLINE long bc_parse_exprs(unsigned i) 594static ALWAYS_INLINE long lex_allowed_in_bc_expr(unsigned i)
595{ 595{
596#if ULONG_MAX > 0xffffffff 596#if ULONG_MAX > 0xffffffff
597 // 64-bit version (will not work correctly for 32-bit longs!) 597 // 64-bit version (will not work correctly for 32-bit longs!)
@@ -4662,7 +4662,6 @@ static BC_STATUS zbc_parse_stmt_or_funcdef(BcParse *p)
4662static BcStatus bc_parse_expr_empty_ok(BcParse *p, uint8_t flags) 4662static BcStatus bc_parse_expr_empty_ok(BcParse *p, uint8_t flags)
4663{ 4663{
4664 BcInst prev = XC_INST_PRINT; 4664 BcInst prev = XC_INST_PRINT;
4665 BcLexType top, t = p->l.lex;
4666 size_t nexprs = 0, ops_bgn = p->ops.len; 4665 size_t nexprs = 0, ops_bgn = p->ops.len;
4667 unsigned nparens, nrelops; 4666 unsigned nparens, nrelops;
4668 bool paren_first, paren_expr, rprn, get_token, assign, bin_last; 4667 bool paren_first, paren_expr, rprn, get_token, assign, bin_last;
@@ -4673,10 +4672,15 @@ static BcStatus bc_parse_expr_empty_ok(BcParse *p, uint8_t flags)
4673 paren_expr = rprn = get_token = assign = false; 4672 paren_expr = rprn = get_token = assign = false;
4674 bin_last = true; 4673 bin_last = true;
4675 4674
4676 for (; bc_parse_exprs(t); t = p->l.lex) { 4675 for (;;) {
4677 BcStatus s = BC_STATUS_SUCCESS; 4676 BcStatus s;
4677 BcLexType t = p->l.lex;
4678
4679 if (!lex_allowed_in_bc_expr(t))
4680 break;
4678 4681
4679 dbg_lex("%s:%d t:%d", __func__, __LINE__, t); 4682 dbg_lex("%s:%d t:%d", __func__, __LINE__, t);
4683 s = BC_STATUS_SUCCESS;
4680 switch (t) { 4684 switch (t) {
4681 case BC_LEX_OP_INC: 4685 case BC_LEX_OP_INC:
4682 case BC_LEX_OP_DEC: 4686 case BC_LEX_OP_DEC:
@@ -4825,7 +4829,7 @@ static BcStatus bc_parse_expr_empty_ok(BcParse *p, uint8_t flags)
4825 exit_loop: 4829 exit_loop:
4826 4830
4827 while (p->ops.len > ops_bgn) { 4831 while (p->ops.len > ops_bgn) {
4828 top = BC_PARSE_TOP_OP(p); 4832 BcLexType top = BC_PARSE_TOP_OP(p);
4829 assign = (top >= BC_LEX_OP_ASSIGN_POWER && top <= BC_LEX_OP_ASSIGN); 4833 assign = (top >= BC_LEX_OP_ASSIGN_POWER && top <= BC_LEX_OP_ASSIGN);
4830 4834
4831 if (top == BC_LEX_LPAREN || top == BC_LEX_RPAREN) 4835 if (top == BC_LEX_LPAREN || top == BC_LEX_RPAREN)