From 06d44d7dfb709bfe02e74d187cceb8591bbda3b4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 13 Sep 2010 12:49:03 +0200 Subject: shell/math.c: rename arith_eval_hooks to arith_state, put error code into it function old new delta expand_and_evaluate_arith 79 89 +10 arith 675 674 -1 arith_lookup_val 151 142 -9 ash_arith 135 122 -13 arith_apply 1304 1269 -35 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/4 up/down: 10/-58) Total: -48 bytes Signed-off-by: Denys Vlasenko --- shell/ash.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'shell/ash.c') diff --git a/shell/ash.c b/shell/ash.c index f631e3d..c27ab7d 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -5442,22 +5442,21 @@ redirectsafe(union node *redir, int flags) static arith_t ash_arith(const char *s) { - arith_eval_hooks_t math_hooks; + arith_state_t math_state; arith_t result; - int errcode = 0; - math_hooks.lookupvar = lookupvar; - math_hooks.setvar = setvar2; - //math_hooks.endofname = endofname; + math_state.lookupvar = lookupvar; + math_state.setvar = setvar2; + //math_state.endofname = endofname; INT_OFF; - result = arith(s, &errcode, &math_hooks); - if (errcode < 0) { - if (errcode == -3) + result = arith(&math_state, s); + if (math_state.errcode < 0) { + if (math_state.errcode == -3) ash_msg_and_raise_error("exponent less than 0"); - if (errcode == -2) + if (math_state.errcode == -2) ash_msg_and_raise_error("divide by zero"); - if (errcode == -5) + if (math_state.errcode == -5) ash_msg_and_raise_error("expression recursion loop detected"); raise_error_syntax(s); } -- cgit v1.1