aboutsummaryrefslogtreecommitdiff
path: root/coreutils (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'busybox' into mergemergeRon Yorston2024-12-301-183/+272
|\
| * cut: code shrinkbusyboxDenys Vlasenko2024-12-211-6/+5
| | | | | | | | | | | | | | | | | | move "linenum" manipulations to the one place where it is used. function old new delta cut_main 1373 1360 -13 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: code shrinkDenys Vlasenko2024-12-211-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | This change eliminates one temporary: - if (dcount++ < cut_list[cl_pos].startpos) + dcount++; + if (dcount <= cut_list[cl_pos].startpos) function old new delta cut_main 1402 1373 -29 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: fix up -D/-s behavior with -FDenys Vlasenko2024-12-201-3/+3
| | | | | | | | | | | | | | | | | | | | function old new delta cut_main 1388 1402 +14 packed_usage 34934 34933 -1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 14/-1) Total: 13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: remove unnecessary initialization of regmatch_tDenys Vlasenko2024-12-201-1/+1
| | | | | | | | | | | | | | function old new delta cut_main 1404 1388 -16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: shorten error messages on bad syntax even moreDenys Vlasenko2024-12-161-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | $ cut -s -b3 cut: -s requires -f or -F $ cut -d@ -b3 cut: -d DELIM requires -f or -F function old new delta static.requires_f - 19 +19 static._op_on_field 32 - -32 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 0/0 up/down: 19/-32) Total: -13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: shorten error messages on bad syntaxDenys Vlasenko2024-12-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need to mimic GNU cut error messages. $ cut -d@ -b3 cut: -d DELIM makes sense only with -f or -F $ cut -s -b3 cut: -s makes sense only with -f or -F function old new delta static._op_on_field 31 32 +1 .rodata 105659 105598 -61 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 1/-61) Total: -60 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: terminate cut_list[] so that we don't need "size of the array" variableDenys Vlasenko2024-12-161-20/+25
| | | | | | | | | | | | | | function old new delta cut_main 1410 1404 -6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: we can't get empty cut_list[], remove the check for thatDenys Vlasenko2024-12-161-8/+11
| | | | | | | | | | | | | | function old new delta .rodata 105685 105659 -26 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: disallow -f '' and -f '-'Denys Vlasenko2024-12-151-15/+19
| | | | | | | | | | | | | | function old new delta cut_main 1391 1410 +19 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: fix -F n-m to match toyboxDenys Vlasenko2024-12-141-0/+10
| | | | | | | | | | | | | | function old new delta cut_main 1339 1391 +52 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: simplify getopt32 codeDenys Vlasenko2024-12-131-11/+8
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: "it's legal to pass an empty list" seems to be untrueDenys Vlasenko2024-12-131-46/+44
| | | | | | | | | | | | | | function old new delta cut_main 1344 1339 -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: whitespace fixesDenys Vlasenko2024-12-131-3/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: tweak commentsDenys Vlasenko2024-12-131-3/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: fix handling of -d ''Denys Vlasenko2024-12-131-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: prevent infinite loop if -F REGEX matches empty delimiterDenys Vlasenko2024-12-131-1/+3
| | | | | | | | | | | | | | function old new delta cut_main 1339 1348 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: tweak --helpDenys Vlasenko2024-12-111-9/+8
| | | | | | | | | | | | | | | | | | | | | | function old new delta packed_usage 34901 34934 +33 cut_main 1353 1339 -14 .rodata 105724 105685 -39 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 33/-53) Total: -20 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: fix -d$'\n' --output-delimiter=@@ behaviorDenys Vlasenko2024-12-101-7/+27
| | | | | | | | | | | | | | | | | | | | function old new delta cut_main 1261 1353 +92 packed_usage 34925 34901 -24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 92/-24) Total: 68 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: implement --output-delimiterDenys Vlasenko2024-12-101-2/+25
| | | | | | | | | | | | | | | | | | | | function old new delta cut_main 1204 1261 +57 static.cut_longopts - 20 +20 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 77/0) Total: 77 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: with -F disabled in .config, don't show it in --helpDenys Vlasenko2024-12-101-5/+13
| | | | | | | | | | | | | | function old new delta packed_usage 34897 34849 -48 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: comment out code which seems to be not neededDenys Vlasenko2024-12-101-7/+7
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: fix "echo 1.2 | cut -d. -f1,3" (print "1", not "1.")Denys Vlasenko2024-12-101-5/+18
| | | | | | | | | | | | | | function old new delta cut_main 1228 1201 -27 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: with -F, do not regcomp() pattern for every fileDenys Vlasenko2024-12-101-18/+24
| | | | | | | | | | | | | | function old new delta cut_main 1218 1228 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: rename "cut_lists" to "cut_list"Denys Vlasenko2024-12-101-19/+20
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: rename some variables to hopefully better namesDenys Vlasenko2024-12-101-13/+19
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: "orig_line" is redundant, remove itDenys Vlasenko2024-12-101-2/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: allocate "printed" only if OPT_CHAR or OPT_BYTEDenys Vlasenko2024-12-101-3/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: localize 'spos' variable, convert !NUMVAR to NUMVAR == 0Denys Vlasenko2024-12-101-5/+6
| | | | | | | | | | | | This imporves readability Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: simplify OPT_ names, eliminate one variableDenys Vlasenko2024-12-101-24/+27
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: improve detection of invalid rangesRon Yorston2024-12-101-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 0068ce2fa (cut: add toybox-compatible options -O OUTSEP, -D, -F LIST) added detection of reversed ranges. Further improvements are possible. - The test for reversed ranges compared the start after it had been decremented with the end before decrement. It thus missed ranges of the form 2-1. - Zero isn't a valid start value for a range. (Nor is it a valid end value, but that's caught by the test for a reversed range.) - The code if (!*ltok) e = INT_MAX; duplicates a check that's already been made. - Display the actual range in the error message to make it easier to find which range was at fault. function old new delta .rodata 100273 100287 +14 cut_main 1239 1237 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 14/-2) Total: 12 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: fix "-s" flag to omit blank linesColin McAllister2024-12-101-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using cut with the delimiter flag ("-d") with the "-s" flag to only output lines containing the delimiter will print blank lines. This is deviant behavior from cut provided by GNU Coreutils. Blank lines should be omitted if "-s" is used with "-d". This change introduces a somewhat naiive, yet efficient solution, where line length is checked before looping though bytes. If line length is zero and the "-s" flag is used, the code will jump to parsing the next line to avoid printing a newline character. function old new delta cut_main 1196 1185 -11 Signed-off-by: Colin McAllister <colinmca242@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | nproc: remove old codeRon Yorston2024-11-071-3/+1
| | | | | | | | | | | | | | | | | | Upstream commit 5a68a246e (nproc: prepare for arbitrarily large CPU masks) dynamically allocated the 'masks' array. When this was merged into busybox-w32 the old code was inadvertantly left in place. Remove it now. This has no effect on Windows builds.
* | cut: improve detection of invalid rangesRon Yorston2024-10-281-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 0068ce2fa (cut: add toybox-compatible options -O OUTSEP, -D, -F LIST) added detection of reversed ranges. Further improvements are possible. - The test for reversed ranges compared the start after it had been decremented with the end before decrement. It thus missed ranges of the form 2-1. - Zero isn't a valid start value for a range. (Nor is it a valid end value, but that's caught by the test for a reversed range.) - The code if (!*ltok) e = INT_MAX; duplicates a check that's already been made. - Display the actual range in the error message to make it easier to find which range was at fault. Adds 0-48 bytes. (GitHub issue #467)
* | cut: detect error when bounds are reversedRon Yorston2024-10-221-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | The command 'cut -b 3-2' failed to detect that the bounds were incorrectly ordered, though the check worked when the difference between the bounds was larger. The comparison was made after the lower bound has been decremented but before the upper bound had. Adds 0-16 bytes. (GitHub issue #467)
* | id: code shrinkRon Yorston2024-10-091-1/+19
| | | | | | | | | | | | | | | | The bogus user/group ids we use on Windows are very limited. Make these limitations explicit in the 'id' applet. Saves 464 bytes.
* | test: code shrink supplementary groupsRon Yorston2024-10-091-0/+4
| | | | | | | | | | | | | | | | Since we don't use is_in_supplementary_groups() there's no need for the cached_groupinfo structure to include the members required for its support or for them to be initialised. Saves 32 bytes.
* | Merge branch 'busybox' into mergeRon Yorston2024-10-081-44/+47
|\|
| * test: -x can return 0/1 early if all X bits are the sameDenys Vlasenko2024-10-071-10/+10
| | | | | | | | | | | | | | function old new delta nexpr 702 725 +23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: cache more of uid/gid syscallsDenys Vlasenko2024-10-071-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Testcase: setuidgid 1:1 strace ash -c 'test -x TODO; test -x TODO; echo $?' should show that second "test -x" does not query ids again. function old new delta ash_main 1236 1256 +20 get_cached_euid - 19 +19 get_cached_egid - 19 +19 test_main 56 72 +16 test_exec 119 135 +16 is_in_supplementary_groups 52 57 +5 nexpr 718 702 -16 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 4/1 up/down: 95/-16) Total: 79 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: make "test -x" use cached groupinfoDenys Vlasenko2024-10-071-4/+17
| | | | | | | | | | | | | | | | | | | | | | function old new delta test_main2 - 407 +407 testcmd 10 23 +13 test_main 418 56 -362 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 420/-362) Total: 58 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: simplify parameter passing in is_in_supplementary_groups()Denys Vlasenko2024-10-071-8/+18
| | | | | | | | | | | | | | | | | | | | | | function old new delta is_in_supplementary_groups 54 52 -2 nexpr 721 718 -3 test_exec 125 119 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-11) Total: -11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: move is_in_supplementary_groups() from test to libbbDenys Vlasenko2024-10-071-19/+1
| | | | | | | | | | | | | | | | | | | | function old new delta is_in_supplementary_groups - 54 +54 nexpr 766 721 -45 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 54/-45) Total: 9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * test: Invert return value of test_eaccess and rename it to test_st_modeDenys Vlasenko2024-10-061-16/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | From dash: From: herbert <herbert@gondor.apana.org.au> Date: Wed, 2 Mar 2005 22:14:54 +1100 Invert return value of test_eaccess and rename it to test_st_mode. function old new delta nexpr 800 766 -34 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * test: code shrinkDenys Vlasenko2024-10-061-1/+1
| | | | | | | | | | | | | | function old new delta nexpr 813 800 -13 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: adjust usage for timeout and pipe_progressRon Yorston2024-10-021-2/+2
| | | | | | | | | | | | | | | | Reduce the divergence from upstream in the usage messages for timeout and pipe_progress. This only affects the source; there are no visible of functional changes.
* | cut: don't print empty lines with '-s' optionRon Yorston2024-09-231-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A command like 'cut -f1 -s' would print empty lines even though they don't contain a delimiter. Add a test to avoid this. Based on a submission to the upstream mailing list: http://lists.busybox.net/pipermail/busybox/2024-July/090834.html Adds 32 bytes in 32-bit build, saves 32 in 64-bit. (GitHub issue #459)
* | dd: add support for writing to physical drivesRon Yorston2024-08-021-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A common use of 'dd' is to copy boot images to removable media. This didn't work on Windows because opening a physical drive failed with the default flags used by 'dd'. If the output file is a physical drive remove incompatible flags. Writing to a physical drive requires elevated privileges and the drive must be offline. Adds 80 bytes. (GitHub issue #435)
* | Merge branch 'busybox' into mergeRon Yorston2024-07-141-9/+14
|\|
| * timeout: allow fractional seconds in timeout valuesRon Yorston2024-07-131-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'timeout' applet uses parse_duration_str() to obtain its timeout values. The default configuration enables float durations. However, the applet silently ignores fractional seconds. This results in unexpected behaviour: $ timeout 5.99 sleep 5.1; echo $? Terminated 143 When float durations are enabled ensure that any fractional seconds are taken into account. function old new delta timeout_wait 44 92 +48 timeout_main 383 365 -18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 48/-18) Total: 30 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>