diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-16 11:50:46 +0200 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-16 11:50:46 +0200 |
commit | bed7c81ea24e9e9ba2a897e233de2abefe611e8b (patch) | |
tree | b18a4559e60300fecd7275c0088f8942441072a2 /shell/math.h | |
parent | 063847d6bd23e184c409f37645ba90fa4d039ada (diff) | |
download | busybox-bed7c81ea24e9e9ba2a897e233de2abefe611e8b.tar.gz |
shell/math: deconvolute and explain ?: handling. Give better error message
function old new delta
arith_apply 1271 1283 +12
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'shell/math.h')
-rw-r--r-- | shell/math.h | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/shell/math.h b/shell/math.h index 2dcab130d..2d305eb12 100644 --- a/shell/math.h +++ b/shell/math.h @@ -9,19 +9,13 @@ /* The math library has just one function: * - * arith_t arith(arith_state_t *states, const char *expr); + * arith_t arith(arith_state_t *state, const char *expr); * * The expr argument is the math string to parse. All normal expansions must * be done already. i.e. no dollar symbols should be present. * * The state argument is a pointer to a struct of hooks for your shell (see below), - * and a semi-detailed error code. Currently, those values are (for - * compatibility, you should assume all negative values are errors): - * 0 - no errors (yay!) - * -1 - unspecified problem - * -2 - divide by zero - * -3 - exponent less than 0 - * -5 - expression recursion loop detected + * and an error message string (NULL if no error). * * The function returns the answer to the expression. So if you called it * with the expression: @@ -64,12 +58,6 @@ * the regex (in C locale): ^[a-zA-Z_][a-zA-Z_0-9]* */ -/* To make your life easier when dealing with optional 64bit math support, - * rather than assume that the type is "signed long" and you can always - * use "%ld" to scan/print the value, use the arith_t helper defines. See - * below for the exact things that are available. - */ - #ifndef SHELL_MATH_H #define SHELL_MATH_H 1 @@ -77,11 +65,11 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN #if ENABLE_SH_MATH_SUPPORT_64 typedef long long arith_t; -#define arith_t_fmt "%lld" +#define ARITH_FMT "%lld" #define strto_arith_t strtoull #else typedef long arith_t; -#define arith_t_fmt "%ld" +#define ARITH_FMT "%ld" #define strto_arith_t strtoul #endif |