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