diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-05-19 17:23:31 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-05-19 17:23:31 +0200 |
commit | 9edd268bad93128bcadfbdde28bb978a4b4c5bab (patch) | |
tree | 0163e19dd3fb1dc0b16c3c694f4ba39fee0c5cb8 /shell/math.h | |
parent | 30a4c32a4d21728a7e25025f70fcc1d7cd722fe0 (diff) | |
download | busybox-w32-9edd268bad93128bcadfbdde28bb978a4b4c5bab.tar.gz busybox-w32-9edd268bad93128bcadfbdde28bb978a4b4c5bab.tar.bz2 busybox-w32-9edd268bad93128bcadfbdde28bb978a4b4c5bab.zip |
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 '')
-rw-r--r-- | shell/math.h | 16 |
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 | |||
65 | 65 | ||
66 | #if ENABLE_FEATURE_SH_MATH_64 | 66 | #if ENABLE_FEATURE_SH_MATH_64 |
67 | typedef long long arith_t; | 67 | typedef long long arith_t; |
68 | #define ARITH_FMT "%lld" | 68 | # define ARITH_FMT "%lld" |
69 | #define strto_arith_t strtoull | ||
70 | #else | 69 | #else |
71 | typedef long arith_t; | 70 | typedef long arith_t; |
72 | #define ARITH_FMT "%ld" | 71 | # define ARITH_FMT "%ld" |
73 | #define strto_arith_t strtoul | 72 | #endif |
73 | |||
74 | #if !ENABLE_FEATURE_SH_MATH_BASE | ||
75 | # if ENABLE_FEATURE_SH_MATH_64 | ||
76 | # define strto_arith_t strtoull | ||
77 | # else | ||
78 | # define strto_arith_t strtoul | ||
79 | # endif | ||
74 | #endif | 80 | #endif |
75 | //TODO: bash supports "BASE#nnnnn" numeric literals, e.g. 2#1111 = 15. | ||
76 | //Make strto_arith_t() support that? | ||
77 | 81 | ||
78 | typedef const char* FAST_FUNC (*arith_var_lookup_t)(const char *name); | 82 | typedef const char* FAST_FUNC (*arith_var_lookup_t)(const char *name); |
79 | typedef void FAST_FUNC (*arith_var_set_t)(const char *name, const char *val); | 83 | typedef void FAST_FUNC (*arith_var_set_t)(const char *name, const char *val); |