Commit Graph

1821 Commits

Author SHA1 Message Date
Denys Vlasenko
b920a38dc0 tar: postpone creation of symlinks with "suspicious" targets. Closes 8411
function                                             old     new   delta
data_extract_all                                     968    1038     +70
tar_main                                             952     986     +34
scan_tree                                            258     262      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 108/0)             Total: 108 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-24 17:20:13 +02:00
Denys Vlasenko
fd5e66eb8e basename: do not use argc
function                                             old     new   delta
basename_main                                        153     148      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-21 18:41:46 +02:00
Denys Vlasenko
72089cf6b4 config: deindent all help texts
Those two spaces after tab have no effect, and always a nuisance when editing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-21 09:50:55 +02:00
Denys Vlasenko
ae178cee3d Update remaining menuconfig items with approximate applet sizes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-19 14:32:54 +02:00
Ron Yorston
a165603d24 od_bloaty: fix floating point output
Currently od_bloaty does this:

   $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | busybox od -f
   od: invalid character 'F' in type string 'fF'
   $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | busybox od -t fD
   od: invalid character 'D' in type string 'fD'
   $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | busybox od -t f
   0000000
   0000010

The first two occur because the alphabetic length specifier isn't being
properly skipped.  The third is due to the empty length specifier being
treated as alphabetic so we fall off the end of the FDL_sizeof array with
undetermined consequences.  Coreutils defaults to printing a double in
this case.

With this patch the output is:

   $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | ./busybox od -f
   0000000   0.0000000e+00   0.0000000e+00
   0000010
   $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | ./busybox od -t fD
   0000000   0.000000000000000e+00
   0000010
   $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | ./busybox od -t f
   0000000   0.000000000000000e+00
   0000010

I guess nobody uses BusyBox od to print floating point numbers.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-19 13:12:02 +02:00
Denys Vlasenko
4eed2c6c50 Update menuconfig items with approximate applet sizes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 22:01:24 +02:00
Denys Vlasenko
483405a9b0 Tweaks from mass recompile for 1.27.1 release
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 20:17:51 +02:00
Ron Yorston
513a2457b6 printf: fix format string sanity check
One of the tests for printf checks for an invalid bare '%' in the
format string:

   $ busybox printf '%' a b c
   printf: %: invalid format

On x86_64 a slightly different test doesn't work correctly:

   $ busybox printf '%' d e f
   printf: invalid number 'd'
   printf: invalid number 'e'
   printf: invalid number 'f'

On other platforms the test fails randomly depending on how the
arguments are laid out in memory.

There are two places in the code where strchr is used to determine if
a character in the format string is valid.  However, strchr also returns
a valid pointer if the character being searched for is the null terminator
thus causing the code to incorrectly suppose that a valid character has
been found.

Add explicit checks for the null terminator.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 16:00:38 +02:00
Denys Vlasenko
c49638b7d2 arch: new applet (same as unmae -m). ~30 bytes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-16 16:43:41 +02:00
Denys Vlasenko
7b6e8f3f1a uuencode: allow space instead of "`" as padding char. Closes 10046
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-14 17:24:59 +02:00
Denys Vlasenko
d5b98e2ef4 dd: fix status=none. Closes 10066
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-14 13:44:30 +02:00
Denys Vlasenko
75e90b1548 cat: fix "cat -An" ignoring -n; make numbering go througn all files
function                                             old     new   delta
cat_main                                             418     428     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-14 10:47:18 +02:00
Kang-Che Sung
a2bdc5c554 cat: allow compiling out -n and -b
When these options were introduced in d88f94a5df
it provides no config options to compile them out. Now provide one.

Introduce config FEATURE_CATN.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-14 09:56:13 +02:00
Denys Vlasenko
9de9c871bf shuf: fix random line selection. Closes 9971
"""
For example, given input file:

    foo
    bar
    baz

after shuffling the input file, foo will never end up back on the first line.
This came to light when I ran into a use-case where someone was selecting
a random line from a file using shuf | head -n 1, and the results on busybox
were showing a statistical anomaly (as in, the first line would never ever
be picked) vs the same process running on environments that had gnu coreutils
installed.

On line https://git.busybox.net/busybox/tree/coreutils/shuf.c#n56 it uses
r %= i, which will result in 0 <= r < i, while the algorithm specifies
0 <= r <= i.
"""

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-09 00:39:15 +02:00
Denys Vlasenko
a8cf9c5a3f libbb: new function bb_getgroups() - allocating wrapper around getgroups()
function                                             old     new   delta
bb_getgroups                                           -     111    +111
nexpr                                                843     757     -86
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/1 up/down: 111/-86)            Total: 25 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-04 18:56:45 +02:00
Laurent Bercot
2599937c4e ls: fix support for long options when FEATURE_LS_COLOR is deselected
Declaration of ls_longopts and initialization of applet_long_options
were incorrectly guarded with ENABLE_FEATURE_LS_COLOR; that yielded a
"ls: NO_OPT: \xff" error message when long options were selected and
color support was not. This patch ensures long options are
initialized separately from color support.

Signed-off-by: Laurent Bercot <ska-dietlibc@skarnet.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-05-26 16:50:53 +02:00
Denys Vlasenko
10ad622dc2 Spelling fixes in comments, documentation, tests and examples
By klemens <ka7@github.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-17 16:13:32 +02:00
Denys Vlasenko
d85352b4ff factor: fix stray semicolon
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-17 15:57:07 +02:00
Denys Vlasenko
8352b717ce factor: support "no-argvs" usage
function                                             old     new   delta
factorize_numstr                                       -      72     +72
packed_usage                                       31562   31566      +4
factor_main                                          109     101      -8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 76/-8)              Total: 68 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-14 14:23:49 +02:00
Denys Vlasenko
107159ef1c factor: improve comments for sieving logic... also fix a typo
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-13 13:38:16 +02:00
Denys Vlasenko
021d50405b factor: improve comments for sieving logic
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-13 13:34:40 +02:00
Denys Vlasenko
c054822027 factor: tweak comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-13 10:51:13 +02:00
Denys Vlasenko
e31ca2e9b2 catv: convert this bbox-specific applet into "cat -v"
function                                             old     new   delta
cat_main                                             150     320    +170
packed_usage                                       31511   31552     +41
applet_install_loc                                   190     189      -1
applet_main                                         1516    1512      -4
applet_names                                        2618    2613      -5
catv_main                                            227       -    -227
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 2/3 up/down: 211/-237)          Total: -26 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-12 17:17:29 +02:00
Denys Vlasenko
d9eb40c185 fix errors found with make_single_applets.sh
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-12 15:48:19 +02:00
Denys Vlasenko
0cecbe7d5d Sort more misplaced applets into coreutils or util-linux
No code changes

Surprisingly, nice and renice are coming from different packages :)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-12 14:16:29 +02:00
Denys Vlasenko
783d57af7b Sort some miscutils/ applets into coreutils or util-linux
No code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-12 13:58:40 +02:00
Denys Vlasenko
1bc0bd13b5 w: new applet, alias to "who -H"
function                                             old     new   delta
who_main                                             451     463     +12
packed_usage                                       31477   31485      +8
applet_main                                         1508    1512      +4
applet_names                                        2606    2608      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 26/0)               Total: 26 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-11 18:17:03 +02:00
Denys Vlasenko
a976aaab0b factor: remove debug code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-11 07:50:42 +02:00
Denys Vlasenko
8a134ec680 libbb: move isqrt from factor, use it in diff too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-11 07:34:56 +02:00
Denys Vlasenko
10673c44f1 factor: much faster, and very slightly larger isqrt()
function                                             old     new   delta
isqrt_odd                                             70      88     +18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-11 07:02:42 +02:00
Denys Vlasenko
cc1f8ba489 factor: don't be too clever in isqrt - be small instead
function                                             old     new   delta
isqrt_odd                                            111      70     -41

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-10 18:30:35 +02:00
Denys Vlasenko
ad5394d591 factor: add code to test isqrt() correctness
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-10 13:53:57 +02:00
Denys Vlasenko
dd3a395053 factor: 25% faster sieving
function                                             old     new   delta
factorize                                            287     260     -27

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-10 12:10:46 +02:00
Denys Vlasenko
4908c79a01 factor: better comments, slightl more clever conversion even->odd
function                                             old     new   delta
isqrt_odd                                            114     111      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-10 11:47:48 +02:00
Denys Vlasenko
f428f1dc6c factor: fix HALF_FMT usage
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-10 10:13:14 +02:00
Denys Vlasenko
12dc4fbf18 factor: fix comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-10 00:41:11 +02:00
Denys Vlasenko
bef1713217 factor: a bit more simple isqrt
function                                             old     new   delta
isqrt_odd                                             87      80      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-10 00:28:26 +02:00
Denys Vlasenko
c6476dca54 factor: simpler isqrt
function                                             old     new   delta
isqrt_odd                                            102      87     -15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-10 00:24:16 +02:00
Denys Vlasenko
c804d4ec5c factor: factor2 variable is unused now, drop it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-09 23:19:47 +02:00
Denys Vlasenko
7e5f2f3b51 factor: expand comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-09 23:12:38 +02:00
Denys Vlasenko
1d232fd440 factor: 30% faster code (estimate max possible factor just once)
function                                             old     new   delta
factorize                                              -     161    +161
isqrt_odd                                              -     102    +102
factor_main                                          281     110    -171
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/1 up/down: 263/-171)           Total: 92 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-09 22:54:57 +02:00
Denys Vlasenko
c1b5b2a190 nl: fix copyright message
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-09 21:19:29 +02:00
Denys Vlasenko
ee7f75d94f factor: new applet
thus far only able to factor up to ULLONG_MAX

function                                             old     new   delta
factor_main                                            -     378    +378
packed_usage                                       31427   31502     +75
applet_names                                        2590    2597      +7
applet_main                                         1500    1504      +4
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/0 up/down: 464/0)             Total: 464 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-09 21:18:43 +02:00
Denys Vlasenko
87ae0fe095 nproc: new applet
function                                             old     new   delta
nproc_main                                             -      98     +98
applet_names                                        2584    2590      +6
applet_main                                         1496    1500      +4
applet_install_loc                                   187     188      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-07 21:47:53 +02:00
Denys Vlasenko
0f7f1ae094 shred: smaller code
function                                             old     new   delta
shred_main                                           361     356      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-07 21:10:00 +02:00
Denys Vlasenko
2f59bf39e2 shred: new applet
function                                             old     new   delta
shred_main                                             -     361    +361
packed_usage                                       31427   31467     +40
applet_names                                        2578    2584      +6
applet_main                                         1492    1496      +4
run_applet_and_exit                                  679     682      +3
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 4/0 up/down: 414/0)             Total: 414 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-07 20:45:08 +02:00
Jody Bruchon
19578b4edf Add help text for 'uniq -i'
Signed-off-by: Jody Bruchon <jody@jodybruchon.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-05 18:51:27 +02:00
Denys Vlasenko
e7ac7abf06 nl: use CONFIG_NL, not CONFIG_UNIQ
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-05 18:31:19 +02:00
Denys Vlasenko
d88f94a5df nl: new applet; also implement cat -nb (similar functionality to nl)
function                                             old     new   delta
nl_main                                                -     201    +201
print_numbered_lines                                   -     115    +115
cat_main                                              36     149    +113
static.nl_longopts                                     -     106    +106
packed_usage                                       31081   31182    +101
applet_main                                         1488    1492      +4
applet_names                                        2575    2578      +3
applet_suid                                           93      94      +1
applet_install_loc                                   186     187      +1
------------------------------------------------------------------------------
(add/remove: 4/0 grow/shrink: 6/0 up/down: 645/0)             Total: 645 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-05 18:17:17 +02:00
Jody Bruchon
8808f7fc2e uniq: add -i option to ignore case
Signed-off-by: Jody Bruchon <jody@jodybruchon.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-03-30 18:15:54 +02:00