Commit Graph

17416 Commits

Author SHA1 Message Date
Ron Yorston
38e9c8c95b vi: don't right shift empty lines
The right shift command ('>') shouldn't affect empty lines.

function                                             old     new   delta
do_cmd                                              4860    4894     +34
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 34/0)               Total: 34 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-20 15:26:09 +02:00
Ron Yorston
f9217cd235 vi: support ~/.exrc
Run initialisation commands from ~/.exrc.  As with EXINIT these
commands are processed before the first file is loaded.

Commands starting with double quotes are ignored.  This is how
comments are often included in .exrc.

function                                             old     new   delta
vi_main                                              268     406    +138
colon                                               4033    4071     +38
.rodata                                           108411  108442     +31
packed_usage                                       34128   34118     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 207/-10)           Total: 197 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-20 15:26:09 +02:00
Ron Yorston
f07772f19e vi: changes to handling of -c and EXINIT
Rewrite handling of command line arguments so any number of -c
commands will be processed.  Previously only two -c commands
were allowed (or one if EXINIT was set).

Process commands from EXINIT before the first file is read into
memory, as specified by POSIX.

function                                             old     new   delta
run_cmds                                               -      77     +77
.rodata                                           108410  108411      +1
vi_main                                              305     268     -37
edit_file                                            816     764     -52
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/2 up/down: 78/-89)            Total: -11 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-20 15:26:09 +02:00
Denys Vlasenko
29b53ef03f udhcp: fix build breakage on MIPS
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-20 13:38:16 +02:00
Denys Vlasenko
9d286a0a55 Start 1.35.0 development cycle
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-19 15:06:57 +02:00
Denys Vlasenko
d922947834 Bump version to 1.34.0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-19 15:04:39 +02:00
Denys Vlasenko
540aa11661 scripts/randomtest.loop: let user know about SKIP_MOUNT_MAND_TESTS
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-16 20:03:07 +02:00
Denys Vlasenko
9ba502456f fdisk: indentation fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-16 11:13:30 +02:00
Denys Vlasenko
59243a86d9 busybox: fix "busybox --help busybox" not showing correct text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-16 08:53:42 +02:00
Denys Vlasenko
8e8cea2a1b awk: fix testsuite
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-16 07:37:22 +02:00
Denys Vlasenko
d6a7203042 vi: fix compile-time error if !ENABLE_FEATURE_VI_SETOPTS
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-16 01:31:32 +02:00
Denys Vlasenko
8d718686f7 tar: fix testsuite
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-16 00:48:50 +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
b259415b51 dd: fix testsuite
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-15 23:01:33 +02:00
Denys Vlasenko
d32ef3174b *: remove remains of FEATURE_TOUCH_NODEREF
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-15 20:50:13 +02:00
Denys Vlasenko
319e20b56b taskset: disallow "taskset -p 0"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-15 20:41:18 +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
Denys Vlasenko
eaa8ee40aa cut: fix testsuite
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-15 20:15:42 +02:00
Denys Vlasenko
21afddefd2 hush: fix "error: invalid preprocessing directive ##"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-15 20:08:53 +02:00
Denys Vlasenko
2a1ce6b20e traceroute: fix compile error due to FreeBSD compat
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-15 20:06:52 +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
Harald van Dijk
8ae6a4344d tar: exclude files before updating hardlink info list
When excluding one file, and including another file that is a hardlink
of the excluded file, it should be stored as an ordinary file.

function                                             old     new   delta
writeFileToTarball                                   489     493      +4

Signed-off-by: Harald van Dijk <harald@gigawatt.nl>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-02 20:13:28 +02:00
Denys Vlasenko
3d40dfabe1 tar: simplify addition of --exclude=GLOB to the expansion of -X EXCLFILE
function                                             old     new   delta
tar_main                                            1115    1105     -10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-02 19:58:13 +02:00
Denys Vlasenko
37460f5daf hush: tweak ${var/pattern/repl} optimization
function                                             old     new   delta
expand_one_var                                      2507    2502      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-27 18:13:39 +02:00
Denys Vlasenko
49cc3cac30 hush: optimize ${var/pattern/repl} for trivial patterns
function                                             old     new   delta
expand_one_var                                      2353    2507    +154

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-27 17:53:55 +02:00
Denys Vlasenko
c450437a4e shell: update psubst testcases
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-27 04:20:32 +02:00
Denys Vlasenko
8dd676c6c3 hush: add missed "undef"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-27 04:09:45 +02:00
Denys Vlasenko
b278d82c61 hush: implement $'str' bashism
function                                             old     new   delta
parse_dollar_squote                                    -     441    +441
encode_then_expand_vararg                            359     380     +21
parse_stream                                        2252    2271     +19
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 481/0)             Total: 481 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-26 15:32:46 +02:00
Denys Vlasenko
05c5d745f7 ahell: update testsuite
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-25 22:03:16 +02:00
Denys Vlasenko
53d45c934f ash: speed up ${v//pattern/repl}
function                                             old     new   delta
subevalvar                                          1447    1457     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-25 21:54:14 +02:00
Denys Vlasenko
1310d7b1d1 ash: speed up ${v//pattern/repl} if !ASH_OPTIMIZE_FOR_SIZE
function                                             old     new   delta
subevalvar                                          1353    1447     +94
.rodata                                           104179  104184      +5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 99/0)               Total: 99 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-22 18:15:59 +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
dabbeeb793 awk: whitespace and debugging tweaks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-14 16:58:05 +02:00
Denys Vlasenko
95fffd8a7f vi: remove redundant assignment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-14 16:32:19 +02:00
Denys Vlasenko
d3480dd582 awk: disallow break/continue outside of loops
function                                             old     new   delta
.rodata                                           104139  104186     +47
chain_group                                          610     633     +23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 70/0)               Total: 70 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-14 16:32:19 +02:00
Denys Vlasenko
d62627487a awk: tighten parsing - disallow extra semicolons
'; BEGIN {...}' and 'BEGIN {...} ;; {...}' are not accepted by gawk

function                                             old     new   delta
parse_program                                        332     353     +21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-14 16:32:19 +02:00
Ron Yorston
e6f4145f29 vi: fix regex search compilation error
Building with FEATURE_VI_REGEX_SEARCH enabled fails.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2021-07-13 18:23:43 +02:00
Denys Vlasenko
36feb26824 vi: somewhat more readable code, no logic changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-13 16:16:21 +02:00
Ron Yorston
2759201401 vi: allow delimiter in ':s' to be escaped
When regular expressions are allowed in search commands it becomes
possible to escape the delimiter in search/replace commands.  For
example, this command will replace '/abc' with '/abc/':

   :s/\/abc/\/abc\//g

The code to split the command into 'find' and 'replace' strings
should allow for this possibility.

VI_REGEX_SEARCH isn't enabled by default.  When it is:

function                                             old     new   delta
strchr_backslash                                       -      38     +38
colon                                               4378    4373      -5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 38/-5)              Total: 33 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-13 14:42:20 +02:00
Denys Vlasenko
95ac4a48f1 vi: allow regular expressions in ':s' commands
BusyBox vi has never supported the use of regular expressions in
search/replace (':s') commands.  Implement this using GNU regex
when VI_REGEX_SEARCH is enabled.

The implementation:

- uses basic regular expressions, to match those used in the search
  command;

- only supports substitution of back references ('\0' - '\9') in the
  replacement string.  Any other character following a backslash is
  treated as that literal character.

VI_REGEX_SEARCH isn't enabled in the default build.  In that case:

function                                             old     new   delta
colon                                               4036    4033      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3)               Total: -3 bytes

When VI_REGEX_SEARCH is enabled:

function                                             old     new   delta
colon                                               4036    4378    +342
.rodata                                           108207  108229     +22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 364/0)             Total: 364 bytes

v2: Rebase.  Code shrink.  Ensure empty replacement string is null terminated.

Signed-off-by: Andrey Dobrovolsky <andrey.dobrovolsky.odessa@gmail.com>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-13 14:38:20 +02:00
Ron Yorston
c76c78740a vi: improve handling of anchored searches
Suppose we search for a git conflict marker '<<<<<<< HEAD' using
the command '/^<<<'.  Using 'n' to go to the next match finds
'<<<' on the current line, apparently ignoring the '^' anchor.

Set a flag in the compiled regular expression to indicate that the
start of the string should not be considered a beginning-of-line
anchor.  An exception has to be made when the search starts from
the beginning of the file.  Make a similar change for end-of-line
anchors.

This doesn't affect a default build with VI_REGEX_SEARCH disabled.
When it's enabled:

function                                             old     new   delta
char_search                                          247     285     +38

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-13 13:50:59 +02:00
Ron Yorston
2916443ab6 vi: use basic regular expressions for search
Both traditional vi and vim use basic regular expressions for
search.  Also, they don't allow matches to extend across line
endings.  Thus with the file:

   123
   234

the search '/2.*4$' should find the second '2', not the first.

Make BusyBox vi do the same.

Whether or not VI_REGEX_SEARCH is enabled:

function                                             old     new   delta
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0)                 Total: 0 bytes

Signed-off-by: Andrey Dobrovolsky <andrey.dobrovolsky.odessa@gmail.com>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-13 13:36:29 +02:00
Ron Yorston
b50ac07cba vi: allow 'gg' to specify a range
Commit 7b93e317c (vi: enable 'dG' command. Closes 11801) allowed
'G' to be used as a range specifier for change/yank/delete
operations.

Add similar support for 'gg'.  This requires setting the 'cmd_error'
flag if 'g' is followed by any character other than another 'g'.

function                                             old     new   delta
do_cmd                                              4852    4860      +8
.rodata                                           108179  108180      +1
------------------------------------------------------------------------------
(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-07-13 13:32:13 +02:00
Denys Vlasenko
ab755e3717 awk: in parsing, remove superfluous NEWLINE check; optimize builtin arg evaluation
function                                             old     new   delta
exec_builtin                                        1149    1145      -4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-12 13:30:30 +02:00
Denys Vlasenko
8d269ef859 awk: fix printf "%-10c", 0
function                                             old     new   delta
awk_printf                                           596     626     +30

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-12 11:27:11 +02:00
Denys Vlasenko
caa93ecdd3 awk: fix corner case in awk_printf
Example where it wasn't working:
    awk 'BEGIN { printf "qwe %s rty %c uio\n", "a", 0, "c" }'
- the NUL printing in %c caused premature stop of printing.

function                                             old     new   delta
awk_printf                                           593     596      +3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-11 18:16:10 +02:00
Denys Vlasenko
f5f336e787 tc: fix for parsing of "dev IFACE" and printing of "class list"
First part (parsing fix) is from Steffen Nurpmeso <steffen@sdaoden.eu>

function                                             old     new   delta
.rodata                                           104120  104138     +18
print_qdisc                                          469     464      -5
tc_main                                              980     969     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 18/-16)              Total: 2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-11 14:50:04 +02:00
Denys Vlasenko
39aabfe8f0 awk: unbreak "cmd" | getline
function                                             old     new   delta
evaluate                                            3337    3343      +6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-11 12:51:43 +02:00
Denys Vlasenko
4ef8841b21 awk: unbreak "printf('%c') can output NUL" testcase
function                                             old     new   delta
awk_printf                                           546     593     +47

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-11 12:25:33 +02:00
Denys Vlasenko
3d57a84907 awk: undo TI_PRINT, it introduced a bug (print with any redirect acting as printf)
function                                             old     new   delta
evaluate                                            3329    3337      +8

Patch by Ron Yorston <rmy@pobox.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-07-11 12:00:31 +02:00