Commit Graph

2031 Commits

Author SHA1 Message Date
David Leonard
4642cf5b38 tsort: new applet
function                                             old     new   delta
tsort_main                                             -     578    +578
.rodata                                           104884  104906     +22
applet_names                                        2759    2765      +6
applet_main                                         1596    1600      +4
packed_usage                                       34290   34288      -2
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/1 up/down: 610/-2)            Total: 608 bytes

Signed-off-by: David Leonard <d+busybox@adaptive-enterprises.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-02 14:25:36 +02:00
Denys Vlasenko
987be932ed *: slap on a few ALIGN_PTR where appropriate
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-02-06 20:07:12 +01:00
Denys Vlasenko
ca466f385a *: slap on a few ALIGN* where appropriate
The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map"

function                                             old     new   delta
.rodata                                           108586  108460    -126
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-126)           Total: -126 bytes
   text	   data	    bss	    dec	    hex	filename
 970412	   4219	   1848	 976479	  ee65f	busybox_old
 970286	   4219	   1848	 976353	  ee5e1	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-02-06 19:53:10 +01:00
Denys Vlasenko
1e825acf8d libbb: shrink lineedit_read_key()
function                                             old     new   delta
lineedit_read_key                                    237     231      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-18 00:36:42 +01:00
Denys Vlasenko
ff8fda8482 ls: implement ls -sh (human-readable allocated blocks)
function                                             old     new   delta
display_single                                       979    1018     +39

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-08 22:59:49 +01:00
Emanuele Giacomelli
84a1305888 XXXsum: handle binary sums with " " in the path
If a line specifies a binary checksum whose path contains two adjacent
spaces, when checking digests with -c the two spaces will be used as the
separator between the digest and the pathname instead of " *", as shown:

$ echo foo > "/tmp/two  spaces"
$ md5sum -b "/tmp/two  spaces"   # This is GNU md5sum
d3b07384d113edec49eaa6238ad5ff00 */tmp/two  spaces
$ md5sum -b "/tmp/two  spaces" | ./busybox md5sum -c
md5sum: can't open 'spaces': No such file or directory
spaces: FAILED
md5sum: WARNING: 1 of 1 computed checksums did NOT match

function                                             old     new   delta
md5_sha1_sum_main                                    503     496      -7

Signed-off-by: Emanuele Giacomelli <emanuele.giacomelli@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-08 17:16:00 +01:00
Denys Vlasenko
34e0bb3931 sort: support -h
function                                             old     new   delta
static.scale_suffix                                    -      62     +62
.rodata                                           104304  104336     +32
compare_keys                                         820     848     +28
packed_usage                                       34159   34184     +25
static.suffix                                          -       9      +9
sort_opt_str                                          37      38      +1
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 4/0 up/down: 157/0)             Total: 157 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-05 12:05:55 +01:00
Denys Vlasenko
cc7d2e2178 sort: fix -s -r interaction: 'stable' order is not affected by -r
function                                             old     new   delta
compare_keys                                         818     820      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-04 23:53:21 +01:00
Denys Vlasenko
31f45c1b36 libbb: factor out fflush_stdout_and_exit(EXIT_SUCCESS)
function                                             old     new   delta
fflush_stdout_and_exit_SUCCESS                         -       7      +7
xxd_main                                             890     888      -2
vlock_main                                           353     351      -2
uuencode_main                                        318     316      -2
uniq_main                                            427     425      -2
uname_main                                           250     248      -2
sort_main                                            853     851      -2
shuf_main                                            500     498      -2
route_main                                           238     236      -2
readlink_main                                        113     111      -2
nice_main                                            156     154      -2
last_main                                            957     955      -2
ipcs_main                                            960     958      -2
env_main                                             209     207      -2
chrt_main                                            464     462      -2
cal_main                                             921     919      -2
baseNUM_main                                         650     648      -2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/16 up/down: 7/-32)            Total: -25 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-04 23:31:58 +01:00
Denys Vlasenko
1fc520ed28 md5/shaXsum: use FEATURE_COPYBUF_KB to size the buffer instead of fixed 4k
function                                             old     new   delta
md5_sha1_sum_main                                    536     565     +29
hash_file                                            419     401     -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 29/-18)             Total: 11 bytes

In my test, for unrolled sha1, COPYBUF_KB=64 increases throughput
from 367 MB/s to 457 MB/s.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-04 00:51:04 +01:00
Denys Vlasenko
0e2cb6d1e2 echo: add FIXME comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-29 07:26:23 +01:00
Matthew Slowe
7d49fedc86 timeout: add support for "timeout -k KILL_SECS"
function                                             old     new   delta
timeout_main                                         307     373     +66
timeout_wait                                           -      42     +42
.rodata                                           104201  104203      +2
packed_usage                                       34097   34096      -1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/1 up/down: 110/-1)            Total: 109 bytes

Signed-off-by: Matthew Slowe <foo@mafoo.org.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17 23:11:17 +01:00
Ron Yorston
7105e4afdd printf: allow 0 as a flag and allow multiple flags
The '%' character in a format specification may be followed by
one or more flags from the list "+- #0".  BusyBox printf didn't
support the '0' flag or allow multiple flags to be provided.
As a result the formats '%0*d' and '%0 d' were considered to be
invalid.

The lack of support for '0' was pointed out by Andrew Snyder on the
musl mailing list:

   https://www.openwall.com/lists/musl/2021/12/14/2

function                                             old     new   delta
printf_main                                          860     891     +31
.rodata                                            99281   99282      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 32/0)               Total: 32 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17 21:13:26 +01:00
Denys Vlasenko
c7b90dc4d1 uudecode: special-case "/dev/stdout", closes 14241
function                                             old     new   delta
uudecode_main                                        295     322     +27

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-12 00:34:15 +01:00
Denys Vlasenko
94c78aa0b9 config system: move some options closer to relevalnt tool subdirectories
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-12 13:23:29 +02:00
YU Jincheng
5156b24553 Make const ptr assign as function call in clang
- This can act as memory barrier in clang to avoid
  read before assign of a const ptr

Signed-off-by: LoveSy <shana@zju.edu.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-09 22:30:45 +02:00
Andrej Valek
ecac9853f2 mktemp: add --tmpdir option
Make mktemp more compatible with coreutils.
- add "--tmpdir" option
- add long variants for "d,q,u" options

Note: Upstream ca-certificate update script started using this option.

function                                             old     new   delta
.rodata                                           104179  104219     +40
mktemp_main                                          186     194      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 48/0)               Total: 48 bytes

Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
Signed-off-by: Peter Marko <peter.marko@siemens.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-08 21:02:56 +02:00
YU Jincheng
1f925038ab *: generalize "const trick"
While at it, change all "__asm__" to "asm"

Co-authored-by: canyie <31466456+canyie@users.noreply.github.com>
Signed-off-by: YU Jincheng <shana@zju.edu.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-07 15:22:35 +02:00
Denys Vlasenko
6279aec03d libbb: clarify what bb_mode_string() generates
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-17 17:10:38 +02:00
Denys Vlasenko
59ac467dc6 libbb: eliminate a static data array in bb_mode_string()
function                                             old     new   delta
print_stat                                           861     869      +8
header_verbose_list_ar                                73      77      +4
display_single                                       975     979      +4
header_verbose_list                                  237     239      +2
bb_mode_string                                       124     115      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 18/-9)               Total: 9 bytes
   text	   data	    bss	    dec	    hex	filename
1043136	    559	   5052	1048747	 1000ab	busybox_old
1043153	    559	   5020	1048732	 10009c	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-17 01:18:31 +02:00
Denys Vlasenko
2df4e0a370 chmod: correctly report changed modes
Chmod used to incorrectly report as changed even files for which the
mode did not change. This was caused by extra bits in the st_mode, that
were not present when parsed from passed argument in the form of octal
number.

Patch by Wolf <wolf@wolfsden.cz>.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-17 00:39:21 +02:00
Ron Yorston
9fe1548bbf date,touch: allow timezone offsets in dates
Allow ISO 8601 style dates to include a timezone offset.  Like
the '@' format these dates aren't relative to the user's current
timezone and shouldn't be subject to DST adjustment.

- The implementation uses the strptime() '%z' format specifier.
  This an extension which may not be available so the use of
  timezones is a configuration option.

- The 'touch' applet has been updated to respect whether DST
  adjustment is required, matching 'date'.

function                                             old     new   delta
parse_datestr                                        624     730    +106
static.fmt_str                                       106     136     +30
touch_main                                           388     392      +4
date_main                                            818     819      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 141/0)             Total: 141 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-17 00:11:30 +02:00
Denys Vlasenko
9346ea9550 df: "support" -H as an alias of -h
function                                             old     new   delta
df_main                                             1065    1068      +3
.rodata                                           104232  104233      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 4/0)                 Total: 4 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-11 00:47:03 +02:00
Denys Vlasenko
0599e0f87b basename: implement -a and -s SUFFIX
function                                             old     new   delta
basename_main                                        145     207     +62
packed_usage                                       33914   33950     +36
.rodata                                           104241  104250      +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 107/0)             Total: 107 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-09 23:45:13 +02:00
Denys Vlasenko
6a9b3f7acf shuf: add a TODO, code shrink
function                                             old     new   delta
shuf_main                                            501     500      -1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-07 22:51:42 +02:00
Denys Vlasenko
f4ba69d476 shuf: make -i 99999999990-100000000000 work even on 32 bits
function                                             old     new   delta
shuf_main                                            443     501     +58
.rodata                                           104238  104245      +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 65/0)               Total: 65 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-04 17:00:22 +02:00
Denys Vlasenko
49a2e484b5 shuf: in -i RANGE, accept numbers up to width of pointers
function                                             old     new   delta
.rodata                                           108468  108474      +6
shuf_main                                            555     542     -13

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-29 14:39:01 +02:00
Denys Vlasenko
60f4843468 shuf: with -i LOW-HIGH, do not allow any argv's
function                                             old     new   delta
shuf_main                                            436     441      +5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-23 15:52:34 +02:00
Denys Vlasenko
d59f539d57 shuf: tweak --help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-23 15:48:22 +02:00
Ron Yorston
8817e285b7 shuf: speed-up when limited output is requested
A user noted that the following command was slower than they
expected:

   busybox shuf -i "1500000000-$(date +%s)" -n 5

At time of writing the range contains 128 million values.  On my
system this takes 7.7s whereas 'shuf' from coreutils takes a
handful of milliseconds.

Optimise BusyBox 'shuf' for cases where -n is specified by stopping
shuffling once the required number of lines have been processed.
On my system the time for the example is reduced to 0.4s.

function                                             old     new   delta
shuf_main                                            520     540     +20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 20/0)               Total: 20 bytes

v2: Code shrink.  Since outlines <= numlines:
    - the loop in shuffle_lines() only needs to test the value of
      outlines;
    - shuffle_lines() can be called unconditionally.
    Update timing to allow for the 13 million seconds elapsed since v1.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-22 15:40:21 +02:00
Denys Vlasenko
1ce60699c1 dd: tweak --help
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-15 23:05:30 +02:00
Denys Vlasenko
ac2d4d88ce touch: fix SEGV if !ENABLE_FEATURE_TOUCH_SUSV3
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-15 20:23:40 +02:00
Ron Yorston
98cb561b5f cp: fix build failure with long options disabled
When long options were disabled cp failed to compile with:

coreutils/cp.c:130:9: error: empty enum is invalid
  130 |         };
      |         ^

Rearrange the conditional compilation to suit.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-15 18:26:56 +02:00
Rob Landley
0068ce2fa0 cut: add toybox-compatible options -O OUTSEP, -D, -F LIST
function                                             old     new   delta
cut_main                                             884    1201    +317
packed_usage                                       33823   33885     +62
.rodata                                           104186  104179      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 379/-7)            Total: 372 bytes

Signed-off-by: Rob Landley <rob@landley.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-20 16:29:22 +02:00
Denys Vlasenko
0231e34427 ls: revert last change (short name must be allocated)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-25 19:48:34 +02:00
Ron Yorston
a84bbc5425 cp,mv: fix -t DIR option
When the '-t DIR' option is used the loop over the remaining
arguments should terminate when a NULL pointer is reached.

function                                             old     new   delta
mv_main                                              585     590      +5
cp_main                                              492     496      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 9/0)                 Total: 9 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-25 00:23:29 +02:00
Ron Yorston
2dade4f18a uniq: really support -z
Commit 894466cc5 (uniq: support -z) added support for NUL delimited
output.  Unfortunately nobody told getopt32().

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-24 23:37:06 +02:00
Denys Vlasenko
6481070eb9 nproc: code shrink
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-24 13:47:49 +02:00
Denys Vlasenko
df96a3cd08 ls: code shrink
function                                             old     new   delta
scan_and_display_dirs_recur                          576     574      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-24 13:37:53 +02:00
Denys Vlasenko
56bbbfae7d cp: implement -n
function                                             old     new   delta
.rodata                                           103681  103722     +41
packed_usage                                       33698   33717     +19
copy_file                                           1678    1696     +18
cp_main                                              500     492      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 78/-8)              Total: 70 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-22 15:28:34 +02:00
Denys Vlasenko
91b9549a8c crc32: code shrink for !CKSUM config
function                                             old     new   delta
cksum_main                                           215     203     -12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-22 10:24:06 +02:00
Denys Vlasenko
836580a7d6 cksum: fix handling of read errors
function                                             old     new   delta
cksum_main                                           377     399     +22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-22 09:29:22 +02:00
Denys Vlasenko
ea9b96e5aa crc32: new applet
function                                             old     new   delta
cksum_main                                           258     377    +119
.rodata                                           103672  103681      +9
applet_names                                        2745    2751      +6
applet_main                                         1588    1592      +4
packed_usage                                       33734   33698     -36
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 138/-36)           Total: 102 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-22 01:07:54 +02:00
Denys Vlasenko
0ec52d438a cp: implement -t DIR
function                                             old     new   delta
packed_usage                                       33713   33734     +21
.rodata                                           103670  103672      +2
cp_main                                              506     500      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 23/-6)              Total: 17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-21 19:38:39 +02:00
Denys Vlasenko
1de709fda2 cp: preparatory indenting of code block, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-21 19:38:02 +02:00
Denys Vlasenko
d82c937a31 df: support -t TYPE
function                                             old     new   delta
packed_usage                                       33656   33716     +60
df_main                                             1029    1065     +36
.rodata                                           103395  103397      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 98/0)               Total: 98 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-20 15:03:21 +02:00
Denys Vlasenko
a2a9113f35 df: POSIXLY_CORRECT sets _default_ scale, -m/-h overrides it
function                                             old     new   delta
df_main                                             1034    1029      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-20 14:46:19 +02:00
Denys Vlasenko
d71c7892ac shred: with -u, unlink file even if it is zero length
function                                             old     new   delta
shred_main                                           391     387      -4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-20 13:48:21 +02:00
Denys Vlasenko
ec3170ac95 shred: implement -s SIZE
function                                             old     new   delta
shred_main                                           337     391     +54
.rodata                                           103393  103395      +2
packed_usage                                       33666   33656     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 56/-10)             Total: 46 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-20 13:08:50 +02:00
Denys Vlasenko
c113796884 env: implement -0
function                                             old     new   delta
packed_usage                                       33590   33618     +28
env_main                                             187     209     +22
.rodata                                           103242  103250      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 58/0)               Total: 58 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-17 13:39:46 +02:00