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>
This commit is contained in:
Denys Vlasenko
2010-09-13 12:49:03 +02:00
parent bd14770b0c
commit 06d44d7dfb
4 changed files with 78 additions and 81 deletions

View File

@ -4463,15 +4463,16 @@ static char *encode_then_expand_string(const char *str, int process_bkslash, int
#if ENABLE_SH_MATH_SUPPORT
static arith_t expand_and_evaluate_arith(const char *arg, int *errcode_p)
{
arith_eval_hooks_t hooks;
arith_state_t math_state;
arith_t res;
char *exp_str;
hooks.lookupvar = get_local_var_value;
hooks.setvar = set_local_var_from_halves;
//hooks.endofname = endofname;
math_state.lookupvar = get_local_var_value;
math_state.setvar = set_local_var_from_halves;
//math_state.endofname = endofname;
exp_str = encode_then_expand_string(arg, /*process_bkslash:*/ 1, /*unbackslash:*/ 1);
res = arith(exp_str ? exp_str : arg, errcode_p, &hooks);
res = arith(&math_state, exp_str ? exp_str : arg);
*errcode_p = math_state.errcode;
free(exp_str);
return res;
}