aboutsummaryrefslogtreecommitdiff
path: root/editors (follow)
Commit message (Collapse)AuthorAgeFilesLines
* patch: improved handling of files with no final newlineRon Yorston2026-04-161-9/+31
| | | | | | | | | | | | | Commit 2275a53f0 (patch: handle files with no final newline) was incomplete. It only detected a line with no newline in the first section of a hunk. Add the code necessary to detect the '\ No newline at end of file' warning in the second section. Also add some tests. Adds 48-80 bytes. (GitHub issue #575)
* patch: handle files with no final newlineRon Yorston2026-04-141-0/+18
| | | | | | | | | | | | The 'patch' applet was unable to process diffs which included the '\ No newline at end of file' warning. Detect this case and mark the lines affected so they can be emitted without a newline. Adds 45-69 bytes. (GitHub issue #575)
* Merge branch 'busybox' into mergeRon Yorston2026-03-111-1/+1
|\
| * *: placate warnings where strchr/strstr returns constant pointerDenys Vlasenko2026-02-151-1/+1
| | | | | | | | | | | | | | | | | | Newer glibc is now smarter and can propagate const-ness from those! function old new delta readtoken1 3111 3108 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2026-02-122-132/+125
|\|
| * vi: code shrinkDenys Vlasenko2026-02-071-7/+9
| | | | | | | | | | | | | | | | | | | | | | function old new delta .rodata 107007 107019 +12 run_cmds 62 50 -12 indicate_error 78 55 -23 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 12/-35) Total: -23 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: fix last commit - do terminate the :CMD on the first whitespaceDenys Vlasenko2026-02-071-0/+1
| | | | | | | | | | | | | | function old new delta colon 3942 3952 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: fix ":list" commandDenys Vlasenko2026-02-071-32/+30
| | | | | | | | | | | | | | | | | | | | | | function old new delta .rodata 107010 107007 -3 show_status_line 372 362 -10 colon 3989 3942 -47 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-60) Total: -60 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: code shrinkDenys Vlasenko2026-02-061-15/+17
| | | | | | | | | | | | | | function old new delta colon 4005 3989 -16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: fix "s /find/repl" with whitespace before /Denys Vlasenko2026-02-061-11/+12
| | | | | | | | | | | | | | function old new delta colon 3977 4005 +28 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: code shrink, optimize: do not call count_lines() unless neededDenys Vlasenko2026-02-061-73/+61
| | | | | | | | | | | | | | function old new delta colon 4010 3980 -30 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * *: use xasprintf_inplace() in more placesDenys Vlasenko2026-02-061-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta .rodata 107009 107018 +9 parse_stream 3075 3069 -6 buffer_print 612 603 -9 expand_args 159 144 -15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 9/-30) Total: -21 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: introduce and use xasprintf_inplace()Denys Vlasenko2026-02-051-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta xasprintf_and_free - 49 +49 watch_main 269 282 +13 singlemount 1313 1315 +2 append_mount_options 157 149 -8 ip_port_str 122 112 -10 lsblk_main 869 858 -11 add_cmd 1178 1167 -11 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/4 up/down: 64/-40) Total: 24 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2026-02-021-39/+33
|\|
| * awk: use more understandable form of "split-globals" trickDenys Vlasenko2026-01-241-39/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta parse_expr 986 998 +12 chain_group 633 640 +7 next_token 930 934 +4 getvar_s 102 101 -1 awk_main 891 888 -3 evaluate 3379 3355 -24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/3 up/down: 23/-28) Total: -5 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2026-01-221-13/+23
|\|
| * cmp: fix -n causing all diffs to be output, implement size suffixes for SKIPDenys Vlasenko2026-01-181-11/+21
| | | | | | | | | | | | | | | | | | | | function old new delta packed_usage 35802 35828 +26 cmp_main 616 595 -21 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 26/-21) Total: 5 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cmp: stop skipping bytes if EOF is reachedGiorgi Tchankvetadze2026-01-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, if a skip value is larger than the file size, cmp will continue to loop and call getc() until the skip count is satisfied, even though EOF has been reached. For large skip values (e.g., 1 billion), this results in significant CPU waste and execution time (e.g., 11 seconds on a modern CPU). This patch checks for EOF inside the skip loop and breaks early. Test case: $ touch empty.txt $ time ./busybox cmp empty.txt empty.txt 1000000000 1000000000 Before: real 0m10.937s After: real 0m0.002s function old new delta cmp_main 594 616 +22 Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2025-10-091-2/+0
|\|
| * vi: warn about range in ':!' commandDenys Vlasenko2025-10-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently vi in Busybox doesn't support filtering text through an external command with ':1,2!cmd'. Instead it behaves as if no range had been supplied and displays the output of the command. Issue a warning and do nothing in such cases. function old new delta colon 3993 4010 +17 Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | vi: warn about range in ':!' commandRon Yorston2025-09-191-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | Currently vi in Busybox doesn't support filtering text through an external command with ':1,2!cmd'. Instead it behaves as if no range had been supplied and displays the output of the command. Issue a warning and do nothing in such cases. Adds 32 bytes. (GitHub issue #524)
* | Merge branch 'busybox' into mergeRon Yorston2025-08-101-1/+1
|\|
| * diff: code shrinkDenys Vlasenko2025-07-041-1/+1
| | | | | | | | | | | | | | function old new delta diffreg 1317 1307 -10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | sed: ensure temporary file is deleted on errorRon Yorston2025-07-301-1/+6
| | | | | | | | | | | | | | | | | | | | | | It wasn't possible to delete the temporary output file in case of error on Windows because it was open. Close the file before trying to unlink it. Adds 16 bytes. (GitHub issue #509)
* | Merge branch 'busybox' into mergeRon Yorston2024-09-281-2/+0
|\|
| * ed: fix line insertion before current line. Closes 15081Ron Yorston2024-09-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When text is inserted by insertLine() the lines following the insertion are moved down and the insertion point is made the new current line. To avoid too much scanning of the linked list of lines setCurNum() may use the position of the old current line to determine the location of the new current line. If the insertion point is before the old current line in the file the latter will have been moved down, so its line pointer needs to be adjusted. function old new delta insertLine 162 180 +18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 18/0) Total: 18 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ed: fix line insertion before current lineRon Yorston2024-07-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When text is inserted by insertLine() the lines following the insertion are moved down and the insertion point is made the new current line. To avoid too much scanning of the linked list of lines setCurNum() may use the position of the old current line to determine the location of the new current line. If the insertion point is before the old current line in the file the latter will have been moved down, so its line pointer needs to be adjusted. (GitHub issue #431)
* | Merge branch 'busybox' into mergeRon Yorston2024-07-131-3/+4
|\|
| * vi: Ensure that the edit buffer ends in a newlinePetja Patjas2024-07-111-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently vi assumes that the edit buffer ends in a newline. This may not be the case. For example: $ printf test > test $ vi test <press 'o'> We fix this by inserting a newline to the end during initialization. Signed-off-by: Petja Patjas <pp01415943@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2024-07-101-63/+125
|\|
| * awk: mktime() with no arguments is not allowedDenys Vlasenko2024-07-101-2/+1
| | | | | | | | | | | | It was SEGVing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: improve comments and constants, no code changesDenys Vlasenko2024-07-101-20/+27
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * qwk: code shrinkDenys Vlasenko2024-07-091-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta mk_splitter 100 96 -4 as_regex 103 99 -4 parse_expr 991 986 -5 awk_split 544 538 -6 awk_getline 559 552 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-26) Total: -26 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: restore assignment precedence to be lower than ternary ?:Denys Vlasenko2024-07-091-11/+54
| | | | | | | | | | | | | | Something is fishy with constrcts like "3==v=3" in gawk, they should not work, but do. Ignore those for now. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: do not infinitely recurse getvar_s() if CONVFMT is set to a numeric valueDenys Vlasenko2024-07-091-6/+14
| | | | | | | | | | | | | | | | | | | | | | function old new delta fmt_num 247 257 +10 evaluate 3385 3379 -6 getvar_s 111 102 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 10/-15) Total: -5 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: fix use after free (CVE-2023-42363)Natanael Copa2024-07-091-8/+13
| | | | | | | | | | | | | | | | | | | | function old new delta evaluate 3377 3385 +8 Fixes https://bugs.busybox.net/show_bug.cgi?id=15865 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2024-06-231-4/+0
|\|
| * awk: fix segfault when compiled by clangRon Yorston2024-03-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A 32-bit build of BusyBox using clang segfaulted in the test "awk assign while assign". Specifically, on line 7 of the test input where the adjustment of the L.v pointer when the Fields array was reallocated L.v += Fields - old_Fields_ptr; was out by 4 bytes. Rearrange to code so both gcc and clang generate code that works. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* | build system: avoid full rebuild when EXTRAVERSION changesRon Yorston2024-02-161-0/+3
| | | | | | | | | | | | | | | | | | | | The last two commits allow EXTRAVERSION to track the current state of a git repository. The build system was unable to determine which files were affected by changes to EXTRAVERSION and caused a full rebuild when it changed. Alter how the version information is passed to the code so only a handful of files need to be rebuilt when it changes.
* | awk: fix segfault when compiled by clangRon Yorston2024-01-191-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A 32-bit build of BusyBox using clang segfaulted in the test "awk assign while assign". Specifically, on line 7 of the test input where the adjustment of the L.v pointer when the Fields array was reallocated: L.v += Fields - old_Fields_ptr; was out by 4 bytes. Rearrange to code so both gcc and clang generate code that works. This patch has been submitted upstream. Until it's accepted there the new code is only used in builds for Windows.
* | Merge branch 'busybox' into mergeRon Yorston2024-01-052-16/+22
|\|
| * sed: check errors writing file with sed -iDominique Martinet2024-01-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sed would currently not error if write failed when modifying a file. This can be reproduced with the following 'script': $ sudo mount -t tmpfs tmpfs -o size=1M /tmp/m $ sudo chmod 777 /tmp/m $ echo foo > /tmp/m/foo $ dd if=/dev/zero of=/tmp/m/fill bs=4k dd: error writing '/tmp/m/fill': No space left on device 256+0 records in 255+0 records out 1044480 bytes (1.0 MB, 1020 KiB) copied, 0.00234567 s, 445 MB/s $ busybox sed -i -e 's/.*/bar/' /tmp/m/foo $ echo $? 0 $ cat /tmp/m/foo <empty> new behaviour: $ echo foo > /tmp/m/foo $ ./busybox sed -i -e 's/.*/bar/' /tmp/m/foo sed: write error $ echo $? 4 $ cat /tmp/m/foo foo function old new delta sed_main 754 801 +47 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 47/0) Total: 47 bytes text data bss dec hex filename 75727 2510 1552 79789 137ad busybox_old 75774 2510 1552 79836 137dc busybox_unstripped Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: fix handling of empty fieldsDenys Vlasenko2023-12-311-16/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by M Rubon <rubonmtz@gmail.com>: Busybox awk handles references to empty (not provided in the input) fields differently during the first line of input, as compared to subsequent lines. $ (echo a ; echo b) | awk '$2 != 0' #wrong b No field $2 value is provided in the input. When awk references field $2 for the "a" line, it is seen to have a different behaviour than when it is referenced for the "b" line. Problem in BusyBox v1.36.1 embedded in OpenWrt 23.05.0 Same problem also in 21.02 versions of OpenWrt Same problem in BusyBox v1.37.0.git I get the correct expected output from Ubuntu gawk and Debian mawk, and from my fix. will@dev:~$ (echo a ; echo b) | awk '$2 != 0' #correct a b will@dev:~/busybox$ (echo a ; echo b ) | ./busybox awk '$2 != 0' #fixed a b I built and poked into the source code at editors/awk.c The function fsrealloc(int size) is core to allocating, initializing, reallocating, and reinitializing fields, both real input line fields and imaginary fields that the script references but do not exist in the input. When fsrealloc() needs more field space than it has previously allocated, it initializes those new fields differently than how they are later reinitialized for the next input line. This works fine for fields defined in the input, like $1, but does not work the first time when there is no input for that field (e.g. field $99) My one-line fix simply makes the initialization and clrvar() reinitialization use the same value for .type. I am not sure if there are regression tests to run, but I have not done those. I'm not sure if I understand why clrvar() is not setting .type to a default constant value, but in any case I have left that untouched. function old new delta ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0) Total: 0 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeFRP-5236-g7dff7f376Ron Yorston2023-12-051-49/+66
|\|
| * awk: implement -E; do not reorder -f and -eDenys Vlasenko2023-10-021-48/+65
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta awk_main 843 891 +48 next_input_file 243 261 +18 packed_usage 34631 34638 +7 .rodata 105391 105390 -1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 73/-1) Total: 72 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | diff: more changes to --binaryRon Yorston2023-08-061-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The changes introduced to support the --binary option gave incorrect results when comparing files with CRLF line endings *without* the --binary option present. The code needs to keep track of the position within the file and is confused by text mode. As an alternative solution, always use binary mode but skip the CR of a CRLF pair when the --binary option isn't used. This gives results matching GNU diff when comparing files with matching line endings, with or without --binary. When line endings differ the results aren't always the same. Costs 32 bytes in the 32-bit build, saves 16 in 64-bit. (GitHub issue #348)
* | Merge branch 'busybox' into mergeRon Yorston2023-07-136-6/+6
|\|
| * Update applet size estimatesDenys Vlasenko2023-07-106-6/+6
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2023-06-161-163/+246
|\|
| * awk: fix subst code to handle "start of word" pattern correctly (needs ↵Denys Vlasenko2023-06-081-13/+36
| | | | | | | | | | | | | | | | | | REG_STARTEND) function old new delta awk_sub 637 714 +77 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>