summaryrefslogtreecommitdiff
path: root/miscutils/dc.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-06 11:31:14 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-06 11:31:14 +0100
commit9ca9ef2d5b4eea4ee79784b226c556ab8b0818de (patch)
treeae1bf5858ed9fc51ed1be42728ba515e9cafe19a /miscutils/dc.c
parenta68a87cd60c2cb0c0e9170317901d8f70923926a (diff)
downloadbusybox-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/dc.c')
-rw-r--r--miscutils/dc.c51
1 files changed, 5 insertions, 46 deletions
diff --git a/miscutils/dc.c b/miscutils/dc.c
index d58f97e91..22890147d 100644
--- a/miscutils/dc.c
+++ b/miscutils/dc.c
@@ -1,52 +1,12 @@
1#if 0 //TODO: use if bc is not selected
2/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
3/* 2/*
4 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 3 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
5 */ 4 */
6 //config:config DC 5
7 //config: bool "dc (4.2 kb)" 6/* config/applet/usage bits are in bc.c */
8 //config: default y 7
9 //config: help 8//#include "libbb.h"
10 //config: Dc is a reverse-polish desk calculator which supports unlimited 9//#include "common_bufsiz.h"
11 //config: precision arithmetic.
12 //config:
13 //config:config FEATURE_DC_LIBM
14 //config: bool "Enable power and exp functions (requires libm)"
15 //config: default y
16 //config: depends on DC
17 //config: help
18 //config: Enable power and exp functions.
19 //config: NOTE: This will require libm to be present for linking.
20
21 //applet:IF_DC(APPLET(dc, BB_DIR_USR_BIN, BB_SUID_DROP))
22
23 //kbuild:lib-$(CONFIG_DC) += dc.o
24
25 //usage:#define dc_trivial_usage
26 //usage: "EXPRESSION..."
27 //usage:
28 //usage:#define dc_full_usage "\n\n"
29 //usage: "Tiny RPN calculator. Operations:\n"
30 //usage: "+, add, -, sub, *, mul, /, div, %, mod, "IF_FEATURE_DC_LIBM("**, exp, ")"and, or, not, xor,\n"
31 //usage: "p - print top of the stack (without popping),\n"
32 //usage: "f - print entire stack,\n"
33 //usage: "o - pop the value and set output radix (must be 10, 16, 8 or 2).\n"
34 //usage: "Examples: 'dc 2 2 add p' -> 4, 'dc 8 8 mul 2 2 + / p' -> 16"
35 //usage:
36 //usage:#define dc_example_usage
37 //usage: "$ dc 2 2 + p\n"
38 //usage: "4\n"
39 //usage: "$ dc 8 8 \\* 2 2 + / p\n"
40 //usage: "16\n"
41 //usage: "$ dc 0 1 and p\n"
42 //usage: "0\n"
43 //usage: "$ dc 0 1 or p\n"
44 //usage: "1\n"
45 //usage: "$ echo 72 9 div 8 mul p | dc\n"
46 //usage: "64\n"
47
48#include "libbb.h"
49#include "common_bufsiz.h"
50#include <math.h> 10#include <math.h>
51 11
52#if 0 12#if 0
@@ -303,4 +263,3 @@ int dc_main(int argc UNUSED_PARAM, char **argv)
303 } 263 }
304 return EXIT_SUCCESS; 264 return EXIT_SUCCESS;
305} 265}
306#endif