aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-27 22:52:13 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-28 13:32:04 +0100
commit1476760600eff7c51c78b0ba02f1b08558178289 (patch)
tree3aa056f2a76b1e2c2319b62349c09db05a5661d7
parent83e7e13628686c3b11ef14dec94fae169ee08c43 (diff)
downloadbusybox-w32-1476760600eff7c51c78b0ba02f1b08558178289.tar.gz
busybox-w32-1476760600eff7c51c78b0ba02f1b08558178289.tar.bz2
busybox-w32-1476760600eff7c51c78b0ba02f1b08558178289.zip
bc: rename config options
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c63
-rwxr-xr-xtestsuite/dc.tests3
-rwxr-xr-xtestsuite/head.tests2
-rwxr-xr-xtestsuite/unzip.tests4
4 files changed, 33 insertions, 39 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 7179811fe..6463817bb 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -27,19 +27,6 @@
27//config: easier. 27//config: easier.
28//config: 5) "read()" accepts expressions, not only numeric literals. 28//config: 5) "read()" accepts expressions, not only numeric literals.
29//config: 29//config:
30//config: Options:
31//config: -i --interactive force interactive mode
32//config: -q --quiet don't print version and copyright
33//config: -s --standard error if any non-POSIX extensions are used
34//config: -w --warn warn if any non-POSIX extensions are used
35//config: -l --mathlib use predefined math routines:
36//config: s(expr) sine in radians
37//config: c(expr) cosine in radians
38//config: a(expr) arctangent, returning radians
39//config: l(expr) natural log
40//config: e(expr) raises e to the power of expr
41//config: j(n, x) Bessel function of integer order n of x
42//config:
43//config:config DC 30//config:config DC
44//config: bool "dc (36 kb)" 31//config: bool "dc (36 kb)"
45//config: default y 32//config: default y
@@ -60,31 +47,32 @@
60//config: whitespace where a register should be, it skips the whitespace. 47//config: whitespace where a register should be, it skips the whitespace.
61//config: If the character following is not a lowercase letter, an error 48//config: If the character following is not a lowercase letter, an error
62//config: is issued. Otherwise, the register name is parsed by the 49//config: is issued. Otherwise, the register name is parsed by the
63//config: following regex: 50//config: following regex: [a-z][a-z0-9_]*
64//config: [a-z][a-z0-9_]*
65//config: This generally means that register names will be surrounded by 51//config: This generally means that register names will be surrounded by
66//config: whitespace. Examples: 52//config: whitespace. Examples:
67//config: l idx s temp L index S temp2 < do_thing 53//config: l idx s temp L index S temp2 < do_thing
68//config: Also note that, like the FreeBSD dc, extended registers are not 54//config: Also note that, like the FreeBSD dc, extended registers are not
69//config: allowed unless the "-x" option is given. 55//config: allowed unless the "-x" option is given.
70//config: 56//config:
71//config:config FEATURE_DC_SMALL 57//config:if BC || DC # for menuconfig indenting
72//config: bool "Minimal dc implementation (4.2 kb), not using bc code base" 58//config:
59//config:config FEATURE_DC_BIG
60//config: bool "Use bc code base for dc (larger, more features)"
73//config: depends on DC && !BC 61//config: depends on DC && !BC
74//config: default n 62//config: default y
75//config: 63//config:
76//config:config FEATURE_DC_LIBM 64//config:config FEATURE_DC_LIBM
77//config: bool "Enable power and exp functions (requires libm)" 65//config: bool "Enable power and exp functions (requires libm)"
78//config: default y 66//config: default y
79//config: depends on FEATURE_DC_SMALL 67//config: depends on DC && !BC && !FEATURE_DC_BIG
80//config: help 68//config: help
81//config: Enable power and exp functions. 69//config: Enable power and exp functions.
82//config: NOTE: This will require libm to be present for linking. 70//config: NOTE: This will require libm to be present for linking.
83//config: 71//config:
84//config:config FEATURE_BC_SIGNALS 72//config:config FEATURE_BC_INTERACTIVE
85//config: bool "Interactive mode (+4kb)" 73//config: bool "Interactive mode (+4kb)"
86//config: default y 74//config: default y
87//config: depends on (BC || DC) && !FEATURE_DC_SMALL 75//config: depends on BC || (DC && FEATURE_DC_BIG)
88//config: help 76//config: help
89//config: Enable interactive mode: when started on a tty, 77//config: Enable interactive mode: when started on a tty,
90//config: ^C interrupts execution and returns to command line, 78//config: ^C interrupts execution and returns to command line,
@@ -99,9 +87,9 @@
99//config:config FEATURE_BC_LONG_OPTIONS 87//config:config FEATURE_BC_LONG_OPTIONS
100//config: bool "Enable bc/dc long options" 88//config: bool "Enable bc/dc long options"
101//config: default y 89//config: default y
102//config: depends on (BC || DC) && !FEATURE_DC_SMALL 90//config: depends on BC || (DC && FEATURE_DC_BIG)
103//config: help 91//config:
104//config: Enable long options for bc and dc. 92//config:endif
105 93
106//applet:IF_BC(APPLET(bc, BB_DIR_USR_BIN, BB_SUID_DROP)) 94//applet:IF_BC(APPLET(bc, BB_DIR_USR_BIN, BB_SUID_DROP))
107//applet:IF_DC(APPLET(dc, BB_DIR_USR_BIN, BB_SUID_DROP)) 95//applet:IF_DC(APPLET(dc, BB_DIR_USR_BIN, BB_SUID_DROP))
@@ -137,11 +125,11 @@
137//usage: "obase = A\n" 125//usage: "obase = A\n"
138//usage: 126//usage:
139//usage:#define dc_trivial_usage 127//usage:#define dc_trivial_usage
140//usage: IF_NOT_FEATURE_DC_SMALL("[-x] ")"[-eSCRIPT]... [-fFILE]... [FILE]..." 128//usage: IF_FEATURE_DC_BIG("[-x] ")"[-eSCRIPT]... [-fFILE]... [FILE]..."
141//usage: 129//usage:
142//usage:#define dc_full_usage "\n" 130//usage:#define dc_full_usage "\n"
143//usage: "\nTiny RPN calculator. Operations:" 131//usage: "\nTiny RPN calculator. Operations:"
144//usage: "\n+, -, *, /, %, ~, ^," IF_NOT_FEATURE_DC_SMALL(" |,") 132//usage: "\n+, -, *, /, %, ~, ^," IF_FEATURE_DC_BIG(" |,")
145//usage: "\np - print top of the stack without popping" 133//usage: "\np - print top of the stack without popping"
146//usage: "\nf - print entire stack" 134//usage: "\nf - print entire stack"
147//usage: "\nk - pop the value and set the precision" 135//usage: "\nk - pop the value and set the precision"
@@ -164,7 +152,7 @@
164#include "libbb.h" 152#include "libbb.h"
165#include "common_bufsiz.h" 153#include "common_bufsiz.h"
166 154
167#if ENABLE_FEATURE_DC_SMALL 155#if !ENABLE_BC && !ENABLE_FEATURE_DC_BIG
168# include "dc.c" 156# include "dc.c"
169#else 157#else
170 158
@@ -765,7 +753,7 @@ struct globals {
765 753
766 BcVec input_buffer; 754 BcVec input_buffer;
767 755
768 IF_FEATURE_BC_SIGNALS(smallint ttyin;) 756 IF_FEATURE_BC_INTERACTIVE(smallint ttyin;)
769 IF_FEATURE_CLEAN_UP(smallint exiting;) 757 IF_FEATURE_CLEAN_UP(smallint exiting;)
770 758
771 BcProgram prog; 759 BcProgram prog;
@@ -788,7 +776,7 @@ struct globals {
788#define G_posix (ENABLE_BC && (option_mask32 & BC_FLAG_S)) 776#define G_posix (ENABLE_BC && (option_mask32 & BC_FLAG_S))
789#define G_warn (ENABLE_BC && (option_mask32 & BC_FLAG_W)) 777#define G_warn (ENABLE_BC && (option_mask32 & BC_FLAG_W))
790#define G_exreg (ENABLE_DC && (option_mask32 & DC_FLAG_X)) 778#define G_exreg (ENABLE_DC && (option_mask32 & DC_FLAG_X))
791#if ENABLE_FEATURE_BC_SIGNALS 779#if ENABLE_FEATURE_BC_INTERACTIVE
792# define G_interrupt bb_got_signal 780# define G_interrupt bb_got_signal
793# define G_ttyin G.ttyin 781# define G_ttyin G.ttyin
794#else 782#else
@@ -876,7 +864,7 @@ struct globals {
876// To make code more readable, each such function has a "z" 864// To make code more readable, each such function has a "z"
877// ("always returning zero") prefix, i.e. zbc_foo or zdc_foo. 865// ("always returning zero") prefix, i.e. zbc_foo or zdc_foo.
878// 866//
879#if ENABLE_FEATURE_BC_SIGNALS || ENABLE_FEATURE_CLEAN_UP 867#if ENABLE_FEATURE_BC_INTERACTIVE || ENABLE_FEATURE_CLEAN_UP
880# define ERRORS_ARE_FATAL 0 868# define ERRORS_ARE_FATAL 0
881# define ERRORFUNC /*nothing*/ 869# define ERRORFUNC /*nothing*/
882# define IF_ERROR_RETURN_POSSIBLE(a) a 870# define IF_ERROR_RETURN_POSSIBLE(a) a
@@ -906,7 +894,7 @@ static void fflush_and_check(void)
906#if ENABLE_FEATURE_CLEAN_UP 894#if ENABLE_FEATURE_CLEAN_UP
907#define QUIT_OR_RETURN_TO_MAIN \ 895#define QUIT_OR_RETURN_TO_MAIN \
908do { \ 896do { \
909 IF_FEATURE_BC_SIGNALS(G_ttyin = 0;) /* do not loop in main loop anymore */ \ 897 IF_FEATURE_BC_INTERACTIVE(G_ttyin = 0;) /* do not loop in main loop anymore */ \
910 G_exiting = 1; \ 898 G_exiting = 1; \
911 return BC_STATUS_FAILURE; \ 899 return BC_STATUS_FAILURE; \
912} while (0) 900} while (0)
@@ -1834,7 +1822,7 @@ static FAST_FUNC BC_STATUS zbc_num_k(BcNum *restrict a, BcNum *restrict b,
1834 c->num[i + j] += (BcDig) carry; 1822 c->num[i + j] += (BcDig) carry;
1835 len = BC_MAX(len, i + j + !!carry); 1823 len = BC_MAX(len, i + j + !!carry);
1836 1824
1837#if ENABLE_FEATURE_BC_SIGNALS 1825#if ENABLE_FEATURE_BC_INTERACTIVE
1838 // a=2^1000000 1826 // a=2^1000000
1839 // a*a <- without check below, this will not be interruptible 1827 // a*a <- without check below, this will not be interruptible
1840 if (G_interrupt) return BC_STATUS_FAILURE; 1828 if (G_interrupt) return BC_STATUS_FAILURE;
@@ -2001,7 +1989,7 @@ static FAST_FUNC BC_STATUS zbc_num_d(BcNum *a, BcNum *b, BcNum *restrict c, size
2001 for (q = 0; n[len] != 0 || bc_num_compare(n, b->num, len) >= 0; ++q) 1989 for (q = 0; n[len] != 0 || bc_num_compare(n, b->num, len) >= 0; ++q)
2002 bc_num_subArrays(n, b->num, len); 1990 bc_num_subArrays(n, b->num, len);
2003 c->num[i] = q; 1991 c->num[i] = q;
2004#if ENABLE_FEATURE_BC_SIGNALS 1992#if ENABLE_FEATURE_BC_INTERACTIVE
2005 // a=2^100000 1993 // a=2^100000
2006 // scale=40000 1994 // scale=40000
2007 // 1/a <- without check below, this will not be interruptible 1995 // 1/a <- without check below, this will not be interruptible
@@ -2486,7 +2474,7 @@ static void xc_read_line(BcVec *vec, FILE *fp)
2486 bc_vec_pop_all(vec); 2474 bc_vec_pop_all(vec);
2487 fflush_and_check(); 2475 fflush_and_check();
2488 2476
2489#if ENABLE_FEATURE_BC_SIGNALS 2477#if ENABLE_FEATURE_BC_INTERACTIVE
2490 if (G_interrupt) { // ^C was pressed 2478 if (G_interrupt) { // ^C was pressed
2491 intr: 2479 intr:
2492 if (fp != stdin) { 2480 if (fp != stdin) {
@@ -2533,7 +2521,7 @@ static void xc_read_line(BcVec *vec, FILE *fp)
2533 bool bad_chars = 0; 2521 bool bad_chars = 0;
2534 2522
2535 do { 2523 do {
2536#if ENABLE_FEATURE_BC_SIGNALS 2524#if ENABLE_FEATURE_BC_INTERACTIVE
2537 if (G_interrupt) { 2525 if (G_interrupt) {
2538 // ^C was pressed: ignore entire line, get another one 2526 // ^C was pressed: ignore entire line, get another one
2539 bc_vec_pop_all(vec); 2527 bc_vec_pop_all(vec);
@@ -7223,7 +7211,7 @@ static int xc_vm_init(const char *env_len)
7223//TODO: in GNU bc, the check is (isatty(0) && isatty(1)), 7211//TODO: in GNU bc, the check is (isatty(0) && isatty(1)),
7224//-i option unconditionally enables this regardless of isatty(): 7212//-i option unconditionally enables this regardless of isatty():
7225 if (isatty(0)) { 7213 if (isatty(0)) {
7226#if ENABLE_FEATURE_BC_SIGNALS 7214#if ENABLE_FEATURE_BC_INTERACTIVE
7227 G_ttyin = 1; 7215 G_ttyin = 1;
7228 // With SA_RESTART, most system calls will restart 7216 // With SA_RESTART, most system calls will restart
7229 // (IOW: they won't fail with EINTR). 7217 // (IOW: they won't fail with EINTR).
@@ -7342,4 +7330,5 @@ int dc_main(int argc UNUSED_PARAM, char **argv)
7342} 7330}
7343#endif 7331#endif
7344 7332
7345#endif // not DC_SMALL 7333#endif // DC_BIG
7334
diff --git a/testsuite/dc.tests b/testsuite/dc.tests
index 2756608f7..29b413cad 100755
--- a/testsuite/dc.tests
+++ b/testsuite/dc.tests
@@ -41,6 +41,9 @@ testing "dc complex without spaces (multiple args)" \
41 "16\n" \ 41 "16\n" \
42 "" "" 42 "" ""
43 43
44optional FEATURE_DC_BIG
45# All tests below depend on FEATURE_DC_BIG
46
44testing "dc '>a' (conditional execute string) 1" \ 47testing "dc '>a' (conditional execute string) 1" \
45 "dc" \ 48 "dc" \
46 "1\n9\n" \ 49 "1\n9\n" \
diff --git a/testsuite/head.tests b/testsuite/head.tests
index 50660d267..97bf889d8 100755
--- a/testsuite/head.tests
+++ b/testsuite/head.tests
@@ -31,10 +31,12 @@ testing "head -n <positive number>" \
31 "line 1\nline 2\n" \ 31 "line 1\nline 2\n" \
32 "" "" 32 "" ""
33 33
34optional FEATURE_FANCY_HEAD
34testing "head -n <negative number>" \ 35testing "head -n <negative number>" \
35 "head -n -9 head.input" \ 36 "head -n -9 head.input" \
36 "line 1\nline 2\nline 3\n" \ 37 "line 1\nline 2\nline 3\n" \
37 "" "" 38 "" ""
39SKIP=
38 40
39rm head.input 41rm head.input
40 42
diff --git a/testsuite/unzip.tests b/testsuite/unzip.tests
index af53de9df..e198dfc4b 100755
--- a/testsuite/unzip.tests
+++ b/testsuite/unzip.tests
@@ -31,10 +31,10 @@ rmdir foo
31rm foo.zip 31rm foo.zip
32 32
33# File containing some damaged encrypted stream 33# File containing some damaged encrypted stream
34optional FEATURE_UNZIP_CDF 34optional FEATURE_UNZIP_CDF CONFIG_UNICODE_SUPPORT
35testing "unzip (bad archive)" "uudecode; unzip bad.zip 2>&1; echo \$?" \ 35testing "unzip (bad archive)" "uudecode; unzip bad.zip 2>&1; echo \$?" \
36"Archive: bad.zip 36"Archive: bad.zip
37 inflating: ]3j½r«IK-%Ix 37 inflating: ]3j½r«I??K-%Ix
38unzip: corrupted data 38unzip: corrupted data
39unzip: inflate error 39unzip: inflate error
401 401