aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-09-13 12:49:03 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-09-13 12:49:03 +0200
commit06d44d7dfb709bfe02e74d187cceb8591bbda3b4 (patch)
tree9a2a8e8381cecae29a5c02ed10995d0a0ad9d412 /shell/ash.c
parentbd14770b0c8594ce5b0ab9b0b1249b72fc781dd3 (diff)
downloadbusybox-w32-06d44d7dfb709bfe02e74d187cceb8591bbda3b4.tar.gz
busybox-w32-06d44d7dfb709bfe02e74d187cceb8591bbda3b4.tar.bz2
busybox-w32-06d44d7dfb709bfe02e74d187cceb8591bbda3b4.zip
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 <dvlasenk@redhat.com>
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/shell/ash.c b/shell/ash.c
index f631e3d25..c27ab7de2 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -5442,22 +5442,21 @@ redirectsafe(union node *redir, int flags)
5442static arith_t 5442static arith_t
5443ash_arith(const char *s) 5443ash_arith(const char *s)
5444{ 5444{
5445 arith_eval_hooks_t math_hooks; 5445 arith_state_t math_state;
5446 arith_t result; 5446 arith_t result;
5447 int errcode = 0;
5448 5447
5449 math_hooks.lookupvar = lookupvar; 5448 math_state.lookupvar = lookupvar;
5450 math_hooks.setvar = setvar2; 5449 math_state.setvar = setvar2;
5451 //math_hooks.endofname = endofname; 5450 //math_state.endofname = endofname;
5452 5451
5453 INT_OFF; 5452 INT_OFF;
5454 result = arith(s, &errcode, &math_hooks); 5453 result = arith(&math_state, s);
5455 if (errcode < 0) { 5454 if (math_state.errcode < 0) {
5456 if (errcode == -3) 5455 if (math_state.errcode == -3)
5457 ash_msg_and_raise_error("exponent less than 0"); 5456 ash_msg_and_raise_error("exponent less than 0");
5458 if (errcode == -2) 5457 if (math_state.errcode == -2)
5459 ash_msg_and_raise_error("divide by zero"); 5458 ash_msg_and_raise_error("divide by zero");
5460 if (errcode == -5) 5459 if (math_state.errcode == -5)
5461 ash_msg_and_raise_error("expression recursion loop detected"); 5460 ash_msg_and_raise_error("expression recursion loop detected");
5462 raise_error_syntax(s); 5461 raise_error_syntax(s);
5463 } 5462 }