From 9edd268bad93128bcadfbdde28bb978a4b4c5bab Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 19 May 2019 17:23:31 +0200 Subject: shell: implement optional "BASE#nnnn" numeric literals function old new delta evaluate_string 729 851 +122 Signed-off-by: Denys Vlasenko --- shell/math.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'shell/math.h') diff --git a/shell/math.h b/shell/math.h index 2c5ae9b44..ec9decb1f 100644 --- a/shell/math.h +++ b/shell/math.h @@ -65,15 +65,19 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN #if ENABLE_FEATURE_SH_MATH_64 typedef long long arith_t; -#define ARITH_FMT "%lld" -#define strto_arith_t strtoull +# define ARITH_FMT "%lld" #else typedef long arith_t; -#define ARITH_FMT "%ld" -#define strto_arith_t strtoul +# define ARITH_FMT "%ld" +#endif + +#if !ENABLE_FEATURE_SH_MATH_BASE +# if ENABLE_FEATURE_SH_MATH_64 +# define strto_arith_t strtoull +# else +# define strto_arith_t strtoul +# endif #endif -//TODO: bash supports "BASE#nnnnn" numeric literals, e.g. 2#1111 = 15. -//Make strto_arith_t() support that? typedef const char* FAST_FUNC (*arith_var_lookup_t)(const char *name); typedef void FAST_FUNC (*arith_var_set_t)(const char *name, const char *val); -- cgit v1.2.3