diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-06 11:31:14 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-06 11:31:14 +0100 |
commit | 9ca9ef2d5b4eea4ee79784b226c556ab8b0818de (patch) | |
tree | ae1bf5858ed9fc51ed1be42728ba515e9cafe19a /miscutils/bc.c | |
parent | a68a87cd60c2cb0c0e9170317901d8f70923926a (diff) | |
download | busybox-w32-9ca9ef2d5b4eea4ee79784b226c556ab8b0818de.tar.gz busybox-w32-9ca9ef2d5b4eea4ee79784b226c556ab8b0818de.tar.bz2 busybox-w32-9ca9ef2d5b4eea4ee79784b226c556ab8b0818de.zip |
dc: re-enable "tiny dc" implementation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/bc.c')
-rw-r--r-- | miscutils/bc.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 71945ff4a..26044afbc 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -94,17 +94,30 @@ | |||
94 | //config: Also note that, like the FreeBSD dc, extended registers are not | 94 | //config: Also note that, like the FreeBSD dc, extended registers are not |
95 | //config: allowed unless the "-x" option is given. | 95 | //config: allowed unless the "-x" option is given. |
96 | //config: | 96 | //config: |
97 | //config:config FEATURE_DC_SMALL | ||
98 | //config: bool "Minimal dc implementation (4.2 kb), not using bc code base" | ||
99 | //config: depends on DC && !BC | ||
100 | //config: default y | ||
101 | //config: | ||
102 | //config:config FEATURE_DC_LIBM | ||
103 | //config: bool "Enable power and exp functions (requires libm)" | ||
104 | //config: default y | ||
105 | //config: depends on FEATURE_DC_SMALL | ||
106 | //config: help | ||
107 | //config: Enable power and exp functions. | ||
108 | //config: NOTE: This will require libm to be present for linking. | ||
109 | //config: | ||
97 | //config:config FEATURE_BC_SIGNALS | 110 | //config:config FEATURE_BC_SIGNALS |
98 | //config: bool "Enable bc/dc signal handling" | 111 | //config: bool "Enable bc/dc signal handling" |
99 | //config: default y | 112 | //config: default y |
100 | //config: depends on BC || DC | 113 | //config: depends on (BC || DC) && !FEATURE_DC_SMALL |
101 | //config: help | 114 | //config: help |
102 | //config: Enable signal handling for bc and dc. | 115 | //config: Enable signal handling for bc and dc. |
103 | //config: | 116 | //config: |
104 | //config:config FEATURE_BC_LONG_OPTIONS | 117 | //config:config FEATURE_BC_LONG_OPTIONS |
105 | //config: bool "Enable bc/dc long options" | 118 | //config: bool "Enable bc/dc long options" |
106 | //config: default y | 119 | //config: default y |
107 | //config: depends on BC || DC | 120 | //config: depends on (BC || DC) && !FEATURE_DC_SMALL |
108 | //config: help | 121 | //config: help |
109 | //config: Enable long options for bc and dc. | 122 | //config: Enable long options for bc and dc. |
110 | 123 | ||
@@ -143,16 +156,16 @@ | |||
143 | //usage:#define dc_trivial_usage | 156 | //usage:#define dc_trivial_usage |
144 | //usage: "EXPRESSION..." | 157 | //usage: "EXPRESSION..." |
145 | //usage: | 158 | //usage: |
146 | //usage:#define dc_full_usage "\n\n" | 159 | //usage:#define dc_full_usage "\n" |
147 | //usage: "Tiny RPN calculator. Operations:\n" | 160 | //usage: "\nTiny RPN calculator. Operations:" |
148 | //usage: "+, add, -, sub, *, mul, /, div, %, mod, ^, exp, ~, divmod, |, " | 161 | //usage: "\n+, add, -, sub, *, mul, /, div, %, mod, ^, exp, ~, divmod, |, " |
149 | //usage: "modular exponentiation,\n" | 162 | //usage: "modular exponentiation," |
150 | //usage: "p - print top of the stack (without popping),\n" | 163 | //usage: "\np - print top of the stack (without popping)," |
151 | //usage: "f - print entire stack,\n" | 164 | //usage: "\nf - print entire stack," |
152 | //usage: "k - pop the value and set the precision.\n" | 165 | //usage: "\nk - pop the value and set the precision." |
153 | //usage: "i - pop the value and set input radix.\n" | 166 | //usage: "\ni - pop the value and set input radix." |
154 | //usage: "o - pop the value and set output radix.\n" | 167 | //usage: "\no - pop the value and set output radix." |
155 | //usage: "Examples: 'dc 2 2 add p' -> 4, 'dc 8 8 mul 2 2 + / p' -> 16" | 168 | //usage: "\nExamples: 'dc 2 2 add p' -> 4, 'dc 8 8 mul 2 2 + / p' -> 16" |
156 | //usage: | 169 | //usage: |
157 | //usage:#define dc_example_usage | 170 | //usage:#define dc_example_usage |
158 | //usage: "$ dc 2 2 + p\n" | 171 | //usage: "$ dc 2 2 + p\n" |
@@ -169,6 +182,10 @@ | |||
169 | #include "libbb.h" | 182 | #include "libbb.h" |
170 | #include "common_bufsiz.h" | 183 | #include "common_bufsiz.h" |
171 | 184 | ||
185 | #if ENABLE_FEATURE_DC_SMALL | ||
186 | # include "dc.c" | ||
187 | #else | ||
188 | |||
172 | typedef enum BcStatus { | 189 | typedef enum BcStatus { |
173 | BC_STATUS_SUCCESS = 0, | 190 | BC_STATUS_SUCCESS = 0, |
174 | BC_STATUS_FAILURE = 1, | 191 | BC_STATUS_FAILURE = 1, |
@@ -7490,3 +7507,5 @@ int dc_main(int argc UNUSED_PARAM, char **argv) | |||
7490 | return bc_vm_run(argv, "DC_LINE_LENGTH"); | 7507 | return bc_vm_run(argv, "DC_LINE_LENGTH"); |
7491 | } | 7508 | } |
7492 | #endif | 7509 | #endif |
7510 | |||
7511 | #endif // not DC_SMALL | ||