aboutsummaryrefslogtreecommitdiff
path: root/shell/math.h
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-05-19 17:23:31 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2019-05-19 17:23:31 +0200
commit9edd268bad93128bcadfbdde28bb978a4b4c5bab (patch)
tree0163e19dd3fb1dc0b16c3c694f4ba39fee0c5cb8 /shell/math.h
parent30a4c32a4d21728a7e25025f70fcc1d7cd722fe0 (diff)
downloadbusybox-9edd268bad93128bcadfbdde28bb978a4b4c5bab.tar.gz
shell: implement optional "BASE#nnnn" numeric literals
function old new delta evaluate_string 729 851 +122 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/math.h')
-rw-r--r--shell/math.h16
1 files changed, 10 insertions, 6 deletions
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);