diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-13 01:09:11 +0200 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-13 01:09:11 +0200 |
commit | 51850c818cf909cde0e07091a8015532cc645b7a (patch) | |
tree | 2f7da57ee250bb92d2a57ed6ff38fc3ca5fc7436 | |
parent | b771c654cab511b172484479cafd006d52588103 (diff) | |
download | busybox-w32-51850c818cf909cde0e07091a8015532cc645b7a.tar.gz busybox-w32-51850c818cf909cde0e07091a8015532cc645b7a.tar.bz2 busybox-w32-51850c818cf909cde0e07091a8015532cc645b7a.zip |
shell: small code shrink
function old new delta
arith 680 675 -5
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r-- | shell/math.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/shell/math.c b/shell/math.c index 2f093391f..c698a442b 100644 --- a/shell/math.c +++ b/shell/math.c | |||
@@ -635,28 +635,29 @@ arith(const char *expr, int *perrcode, a_e_h_t *math_hooks) | |||
635 | goto err; | 635 | goto err; |
636 | } | 636 | } |
637 | while (stackptr != stack) { | 637 | while (stackptr != stack) { |
638 | operator prev_op = *--stackptr; | ||
638 | if (op == TOK_RPAREN) { | 639 | if (op == TOK_RPAREN) { |
639 | /* The algorithm employed here is simple: while we don't | 640 | /* The algorithm employed here is simple: while we don't |
640 | * hit an open paren nor the bottom of the stack, pop | 641 | * hit an open paren nor the bottom of the stack, pop |
641 | * tokens and apply them */ | 642 | * tokens and apply them */ |
642 | if (stackptr[-1] == TOK_LPAREN) { | 643 | if (prev_op == TOK_LPAREN) { |
643 | --stackptr; | ||
644 | /* Any operator directly after a */ | 644 | /* Any operator directly after a */ |
645 | lasttok = TOK_NUM; | 645 | lasttok = TOK_NUM; |
646 | /* close paren should consider itself binary */ | 646 | /* close paren should consider itself binary */ |
647 | goto next; | 647 | goto next; |
648 | } | 648 | } |
649 | } else { | 649 | } else { |
650 | operator prev_prec = PREC(stackptr[-1]); | 650 | operator prev_prec = PREC(prev_op); |
651 | convert_prec_is_assign(prec); | 651 | convert_prec_is_assign(prec); |
652 | convert_prec_is_assign(prev_prec); | 652 | convert_prec_is_assign(prev_prec); |
653 | if (prev_prec < prec) | 653 | if (prev_prec < prec |
654 | break; | 654 | || (prev_prec == prec && is_right_associativity(prec)) |
655 | /* check right assoc */ | 655 | ) { |
656 | if (prev_prec == prec && is_right_associativity(prec)) | 656 | stackptr++; |
657 | break; | 657 | break; |
658 | } | ||
658 | } | 659 | } |
659 | errcode = arith_apply(*--stackptr, numstack, &numstackptr, math_hooks); | 660 | errcode = arith_apply(prev_op, numstack, &numstackptr, math_hooks); |
660 | if (errcode) | 661 | if (errcode) |
661 | goto ret; | 662 | goto ret; |
662 | } | 663 | } |