summaryrefslogtreecommitdiff
path: root/editors
AgeCommit message (Collapse)Author
2021-04-15vi: allow backward search to specify line addressRon Yorston
It should be possible to use a backward search as a line address in colon commands. function old new delta colon 3661 3701 +40 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 40/0) Total: 40 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-15vi: detect and warn about invalid line addressesRon Yorston
BusyBox vi didn't have proper handling for invalid markers or unsuccessful searches in colon line addresses. This could result in the wrong lines being affected by a change. Detect when an invalid address is specified, propagate an error indicator up the call chain and issue a warning. function old new delta colon 3604 3661 +57 .rodata 105195 105211 +16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 73/0) Total: 73 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-15vi: code shrink colon line addressesRon Yorston
Remove some unnecessary code in get_one_address() and rewrite get_address(). function old new delta colon 3325 3604 +279 get_one_address 342 - -342 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/0 up/down: 279/-342) Total: -63 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-15vi: make context marks more like viRon Yorston
The context marks that are automatically updated and can be used with the "''" command didn't behave the same as in vi. Marks were only being set for certain editing commands when they should have been set on successful movement commands. Make BusyBox vi behave more like vi. function old new delta .rodata 105179 105194 +15 do_cmd 4723 4668 -55 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 15/-55) Total: -40 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-15vi: correct autoindent for 'O' commandRon Yorston
Opening a line above the current line with the 'O' command should use the current, not previous, line to determine how much to autoindent. function old new delta char_insert 531 563 +32 do_cmd 4746 4723 -23 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 32/-23) Total: 9 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-15vi: allow ctrl-D to reduce indentationRon Yorston
When whitespace has been automatically added to a new line due to autoindent entering ctrl-D should reduce the level of indentation. Implement an approximation of this by treating ctrl-D as backspace. For the common case of indentation using tabs this is good enough. My attempt at a full implementation was three times bigger. function old new delta char_insert 476 531 +55 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 55/0) Total: 55 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-15vi: don't move cursor when yanking whole linesRon Yorston
When whole lines are yanked using 'yy' or 'Y' vi doesn't change the cursor position. Make BusyBox vi do the same. function old new delta do_cmd 4776 4786 +10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 10/0) Total: 10 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-15vi: reset command count when specifying '0' rangeRon Yorston
Since commit a54450248 (vi: allow the '.' command to have a repetition count) using '0' to specify a range doesn't work with a non-zero repeat count, e.g. '1d0'. Users wouldn't normally try to do that but the '.' command does. Add a special case in get_motion_char() to handle this. function old new delta find_range 737 746 +9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/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-04-15vi: code shrink motion by paragraphRon Yorston
Use a hand-coded loop to search for paragraph boundaries instead of calling char_search(). We were using a loop anyway to skip consecutive newlines. function old new delta do_cmd 4792 4752 -40 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-40) Total: -40 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-15vi: position cursor on last column of tabRon Yorston
Vi places the cursor on the last column of a tab character whereas BusyBox vi puts it on the first. This is disconcerting for experienced vi users and makes it impossible to distinguish visually between an empty line and one containing just a tab. It wasn't always this way. Prior to commit e3cbfb91d (vi: introduce FEATURE_VI_8BIT) BusyBox vi also put the cursor on the last column. However there were problems with cursor positioning when text was inserted before a tab. Commit eaabf0675 (vi: multiple fixes by Natanael Copa) includes a partial attempt to fix this. (The code is still present but it's never executed. Clever compilers optimise it away.) Revert the changes of commit e3cbfb91d and fix the insert problem for all tabs, not just the first. To quote Natanael: "Costs a few bytes but its worth it imho". function old new delta refresh 974 1000 +26 move_to_col 81 83 +2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 28/0) Total: 28 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-15vi: correctly record deleted charactersRon Yorston
The undo queue didn't record deleted characters properly. For example, insert some text, backspace over a couple of characters then exit insert mode. At this point undo will restore two nulls instead of the deleted characters. The fix is in undo_push(): record the state of the UNDO_USE_SPOS flag and clear it before using 'u_type'. Also, update the comments to reflect the fact that UNDO_QUEUED_FLAG isn't actually used. function old new delta undo_push 443 435 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-8) Total: -8 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-13vi: allow writing to another file if this one is readonlyAlison Winters
Version 2. Same change but rebased after Ron's improvements. Fixes bug where if you open a read only file, you can't save it as a different filename. function old new delta colon 3160 3162 +2 Signed-off-by: Alison Winters <alisonatwork@outlook.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-11vi: improvements to reporting of changesRon Yorston
Traditional vi is mostly silent about the results of yank, delete, change, undo or substitution commands. Vim reports some details about undo and substitution. BusyBox vi is positively verbose in comparison. Make some improvements to BusyBox vi: - Add vim-like reporting of changes caused by substitutions, of the form '64 substitutions on 53 lines'. This replaces a fairly useless report of the result of the last change made. - Ensure that the report about put operations correctly reflects the newly introduced repetition count. - Commit 25d2592640 tried to limit status updates for delete and yank operations by detecting whether the register had changed. This didn't always work because the previously allocated memory could be reused for the new register contents. Fix this by delaying freeing the old register until after the new one has been allocated. - Add a configuration option to control verbose status reporting. This is on by default. Turning it off make BusyBox vi as taciturn as traditional vi and saves 435 bytes. function old new delta colon 3212 3292 +80 yank_status - 74 +74 static.text_yank 99 86 -13 string_insert 130 76 -54 do_cmd 4842 4776 -66 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/3 up/down: 154/-133) Total: 21 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-11vi: issue a warning on failure to find a characterRon Yorston
When a search for a character within a line fails issue a warning. function old new delta ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0) Total: 0 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-11vi: make the substitute command more like viRon Yorston
Make the ':s/find/replace/g' command behave more like vi: - the final delimiter is optional if no flag is specified; - the cursor is moved to the first visible character of the last line where a substitution was made; - a warning is displayed if no substitution was made. function old new delta colon 3156 3212 +56 .rodata 105133 105142 +9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 65/0) Total: 65 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-11vi: make put commands more like viRon Yorston
Make the put commands 'p' and 'P' behave more like vi: - allow a repetition count to be specified; - when the text being inserted doesn't include a newline the cursor should be positioned at the end of the inserted text. function old new delta do_cmd 4765 4842 +77 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 77/0) Total: 77 bytes v2: Don't break build when FEATURE_VI_UNDO is disabled. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-11vi: allow the '.' command to have a repetition countRon Yorston
The '.' command repeats the last text change. When it has a repetition count replay the change the number of times requested. Update the stored count if it changes. For example, 3dw deletes 3 words . deletes another 3 words 2. deletes 2 words and changes the stored count . deletes 2 words function old new delta do_cmd 4746 4781 +35 .rodata 105133 105138 +5 edit_file 887 849 -38 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 40/-38) Total: 2 bytes v2: Change implementation to include repetition count in string. Otherwise repeating 'r' doesn't work properly. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-11vi: allow 'r' command to be aborted, repeatedRon Yorston
Make the 'r' command behave more like vi: - abort the command if ESC is entered after the 'r'; - allow a repeat count to be entered before the 'r'; - if the repeat count exceeds the space available on the line don't change any characters and issue an alert. function old new delta do_cmd 4679 4746 +67 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 67/0) Total: 67 bytes v2: Don't break build when FEATURE_VI_UNDO is disabled. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-11vi: improvements to undoRon Yorston
The left shift operator ('<') didn't support undo at all; right shift ('>') required changes to be undone separately for each line. Allow both types of shift to be undone as a single operation. Also, neither traditional vi nor vim yank the lines being shifted by the '<' and '>' commands, so remove that call to yank_delete(); When a repetition count was specified for the '~', 'x', 'X' or 's' commands the changes had to be undone one character at a time. Allow undo as a single operation (though the delete and change parts of the 's' command still have to be undone separately). function old new delta undo_push_insert 37 40 +3 do_cmd 4695 4663 -32 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 3/-32) Total: -29 bytes v2: Don't break build when FEATURE_VI_UNDO is disabled. Don't reset 'undo_del' too early in '~' handling code. Code shrink '~'. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-11vi: more fixes to range selection by wordRon Yorston
An example in my vi book presents different ways to fix the spelling of the last word in a line: ... anyweigh. With the cursor on the 'e' the command 'cway' should do the job. Since commit 776b56d77, though, 'cw' incorrectly includes the full stop in the range if we're on the last line of the file. (Prior to commit 776b56d77 BusyBox vi got 'cw' right in this case but 'cW' wrong: it *didn't* delete the full stop.) Reinstate some of the bloat removed by the earlier commit to fix this. Also, commit 7b4c2276a (vi: fix word operations across line boundaries) incorrectly ignores whitespace after a single character word. Adjust the condition to avoid this. function old new delta find_range 707 737 +30 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 30/0) Total: 30 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-11vi: improvements to range selectionRon Yorston
Rewrite find_range(), pushing quite a bit of code from do_cmd() down into it. - The commands 'y', 'd', 'c', '<' and '>' can be given twice to specify a whole-line range. BusyBox vi actually accepted any second character from that group, e.g. 'dc' or '<y', with the latter being accepted even if yank was disabled. Require the two characters to match. - '<' and '>' commands followed by ESC incorrectly issued an alert. - Allow search commands and a marker (specified as "y'a", for example) to define a range for those operators that support it. function old new delta find_range 518 707 +189 .rodata 105119 105133 +14 get_motion_char 68 - -68 do_cmd 4860 4695 -165 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 2/1 up/down: 203/-233) Total: -30 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-11vi: code shrink search commandsRon Yorston
Changes to search commands ('/', '?', 'n' and 'N'): - Rewrite to be smaller and (possibly) clearer. - Issue a warning when a repeat search is requested without a previous search having been made. Vim and BusyBox vi support a repetition count for searches though the original vi doesn't. If the count exceeds the number of occurrences of the search string the search may loop through the file multiple times. function old new delta .rodata 105135 105119 -16 do_cmd 4898 4860 -38 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-54) Total: -54 bytes Signed-off-by; Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-08vi: changes to option handlingRon Yorston
Since commit 70ee23399 (vi: code shrink) the ':set' command is unable to process multiple options on a line. Fix this by temporarily null-terminating each option. Change the default setting for all options to off to match vim. Actually, 'flash' isn't an option in vim, only traditional vi, where it's on by default. In vim the corresponding option is 'visualbell' which defaults to off. POSIX doesn't have either of these. Allow the abbreviation 'ts' for the 'tabstop' option. Issue an error message if: - an option is not implemented - an option that takes a value has no '=' or has a 'no' prefix - a boolean option has a '=' function old new delta colon 2944 3003 +59 .rodata 103171 103189 +18 vi_main 274 270 -4 setops 73 - -73 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 2/1 up/down: 77/-77) Total: 0 bytes v2: Try harder to detect invalid options. Thanks to Peter D for pointing this out. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-30vi: deal with invalid movements in shift commandsRon Yorston
Since commit 25d259264 (vi: make buffer handling more vi-like) find_range() can return early when an invalid movement is specified. The call to find_range() in the code that handles shift commands ('<' and '>') doesn't check for this condition. Previously this only resulted in the current line being shifted but it can now result in a segfault. Check for an invalid movement and notify the user without taking any further action. function old new delta do_cmd 4890 4898 +8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 8/0) Total: 8 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-29vi: code shrinkRon Yorston
- In the '+' and '-' commands the call to dot_skip_over_ws() is only needed for the final line processed so it can be moved out of the while loop. - Marking sync_cursor() NOINLINE doesn't seem to offer the same advantages it did in 2009 (commit adf922ec2). function old new delta refresh 694 974 +280 do_cmd 4900 4887 -13 sync_cursor 336 - -336 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/1 up/down: 280/-349) Total: -69 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-29vi: improve operations involving paragraph movementRon Yorston
Movement by paragraph doesn't always involve whole lines. If the cursor is positioned in the middle of a line deleting to either end of the paragraph will result in one partial line and zero or more full lines. Adjust the end of ranges delimited by paragraph movement to more closely match what vi does. function old new delta find_range 467 518 +51 at_eof - 49 +49 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 100/0) Total: 100 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-29vi: improve motion by paragraphRon Yorston
When moving by paragraph ('{' and '}'): - Treat multiple empty lines as a single paragraph separator. - When no paragraph separator is found move to the start or end of the file depending on the direction of motion. function old new delta do_cmd 4821 4900 +79 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 79/0) Total: 79 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-29vi: allow repetition count for paragraph motionRon Yorston
The paragraph motion commands '{' and '}' should accept a count. function old new delta do_cmd 5054 5071 +17 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 17/0) Total: 17 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-29vi: allow motion count for change/delete/yank/shiftRon Yorston
The motion that determines the range of a change, delete, yank or shift operation can have its own count. Thus the commands '5dd' and 'd5d' are equivalent: both delete 5 lines. When the command itself also has a count the two values are multiplied. Thus the command '2d3w' deletes 6 words and '2D3G' deletes from the current line to line 6. (When dealing with structured data it might make sense to think in units of 3 words so '2d3w' is deleting 2 such units. It doesn't seem quite as sensible to express 'delete from current line to line 6' as '2D3G' but vi permits it.) function old new delta get_motion_char - 68 +68 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/0 up/down: 68/0) Total: 68 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-29vi: support more commands for range selectionRon Yorston
Add 'F', 'T' and '|' as commands that can be used to specify a range for change/delete/yank operations. function old new delta .rodata 105129 105135 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 6/0) Total: 6 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-29vi: improvements to character search within lineRon Yorston
- Use a common routine to handle all commands to search for a character in a line. - When searching for the nth occurrence of a character don't move the cursor if fewer than n occurrences are present. - Add support for the 'T' command, search backwards for character after next occurrence of given character. function old new delta do_cmd 4861 4805 -56 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-56) Total: -56 bytes v2: Add parentheses to avoid searches continuing past end of line. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-29vi: remember cursor column during vertical motionRon Yorston
When the 'j'/'k' commands or up/down arrow keys are used to move the cursor vertically 'vi' remembers the original cursor column and positions the cursor there if possible. Also, if the '$' command has been used to position the cursor at the end of a line vertical movements keep the cursor at the end of the line. Make BusyBox 'vi' do the same. function old new delta refresh 674 694 +20 do_cmd 4853 4861 +8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 28/0) Total: 28 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-29vi: 'G'/'M' commands move to first visible characterRon Yorston
The 'G' command with no target (meaning 'go to last line') should position the cursor on the first visible character of the line, as it already does in other cases. The 'M' command should position the cursor on the first visible character (as 'H' and 'L' already do). function old new delta do_cmd 4842 4853 +11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 11/0) Total: 11 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-29vi: don't overwrite existing fileRon Yorston
If the name of the file being written doesn't match the current filename and the output file already exists vi should issue a warning and not overwrite the file. Because the test only compares the file names it's somewhat over- protective. If the current file name is 'my_text' and the user tries to save to './my_text' they'll be prevented from doing so. function old new delta colon 3092 3151 +59 .rodata 105118 105146 +28 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 87/0) Total: 87 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-29vi: make buffer handling more vi-likeRon Yorston
Vi places text affected by change/delete/yank operations into a buffer. The contents of such buffers can be restored with the put commands, 'p' or 'P'. These behave differently depending on whether the buffer contains whole lines or partial lines. For whole lines the text is copied into the file on the line before (P) or after (p) the current line. For partial lines the text is copied before or after the current cursor position. Whether an operation results in whole or partial lines depends on the command used. BusyBox vi treats any buffer with a newline as though it contained whole lines. This is incorrect. Deleting multiple words across a line boundary results in a buffer with a newline but not having whole lines. Rework how buffers are handled to behave more like vi. function old new delta static.text_yank 79 99 +20 colon 3092 3097 +5 edit_file 885 887 +2 yank_delete 127 112 -15 .rodata 105139 105101 -38 find_range 514 467 -47 do_cmd 5088 4842 -246 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/4 up/down: 27/-346) Total: -319 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-29vi: code shrinkRon Yorston
I was puzzled by code in find_range() which handles forward word movement. It included a test to see if we're at the start of a word. Since these are forward word movements surely we'd expect to be at the start of a word? In fact, the test was intended to fix a problem with changes to the last word in a file, as discussed in the thread starting here: http://lists.busybox.net/pipermail/busybox/2004-January/044552.html The code can be simplified by testing directly for end of file instead of indirectly for not being at the start of a word. Since trailing whitespace is now handled in do_cmd() the code to back up off a newline is no longer required. function old new delta find_range 619 514 -105 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-105) Total: -105 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-29vi: fix word operations across line boundariesRon Yorston
Commit 4b49422a0 (vi: fix changes to word at end of line. Closes 11796) fixed a problem where an operation on a word at the end of a line followed by a line starting with whitespace incorrectly joined the lines. However it also broke the case where operating on multiple words across a line boundary *should* join the lines. Fix this by detecting when trailing whitepace in a word operation includes a newline. Whitespace beyond the newline is excluded from consideration. function old new delta do_cmd 5083 5088 +5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 5/0) Total: 5 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-01vi: code shrinkDenys Vlasenko
function old new delta setops 85 73 -12 colon 2965 2915 -50 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-62) Total: -62 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-01vi: restore 0 offset after :set noXXX commandAlison Winters
Fixes bug where commands after the first noXXX command are ignored. e.g. :set noic tabstop=4 While at it, stop recognizing "notabstop=NNN". function old new delta colon 2990 2965 -25 Signed-off-by: Alison Winters <alisonatwork@outlook.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-22diff: code shrinkRon Yorston
function old new delta diff_main 1515 1495 -20 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-20) Total: -20 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-03libbb: introduce and use fputs_stdoutRon Yorston
function old new delta fputs_stdout - 12 +12 zxc_vm_process 7237 7230 -7 yes_main 85 78 -7 write_block 380 373 -7 wrapf 305 298 -7 strings_main 437 430 -7 show_bridge 353 346 -7 rev_main 384 377 -7 put_prompt_custom 58 51 -7 put_cur_glyph_and_inc_cursor 168 161 -7 print_numbered_lines 152 145 -7 print_named_ascii 130 123 -7 print_name 135 128 -7 print_login_issue 386 379 -7 print_ascii 208 201 -7 powertop_main 1249 1242 -7 od_main 1789 1782 -7 logread_main 518 511 -7 head_main 804 797 -7 display_process_list 1319 1312 -7 cut_main 1002 995 -7 bb_dump_dump 1550 1543 -7 bb_ask_noecho 393 386 -7 baseNUM_main 702 695 -7 expand_main 755 745 -10 dumpleases_main 497 487 -10 write1 12 - -12 putcsi 37 23 -14 print_login_prompt 55 41 -14 paste_main 525 511 -14 cat_main 440 426 -14 print_it 245 230 -15 print_addrinfo 1188 1171 -17 print_rule 770 750 -20 print_linkinfo 842 822 -20 httpd_main 791 771 -20 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 0/34 up/down: 12/-341) Total: -329 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-02vi: fix range selection by forward character motionRon Yorston
Selection of ranges for change/delete/yank by forward character motion commands (SPACE or 'l') was incorrect. The range was always one character whereas vi allows the size of the range to be specified. Fix this by executing the motion command the required number of times. There is a complication when the range is at the end of a line. We need to distinguish between a range which excludes the last character and one which includes it. This requires comparing the actual range with that expected from the command count. (With the additional quirk that a command count of zero is equivalent to a command count of one.) function old new delta find_range 587 619 +32 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/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-02-02awk: allow printf('%c') to output NUL, closes 13486Ron Yorston
Treat the output of printf as binary rather than a null-terminated string so that NUL characters can be output. This is considered to be a GNU extension, though it's also available in mawk and FreeBSD's awk. function old new delta evaluate 3487 3504 +17 awk_printf 504 519 +15 ------------------------------------------------------------------------------ (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>
2020-12-13help text: replace [OPTIONS] with actual options (if not too long)Denys Vlasenko
function old new delta packed_usage 33620 33665 +45 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-02awk: FS regex matches only non-empty separators (gawk compat)Denys Vlasenko
function old new delta awk_split 484 553 +69 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-30decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nillyDenys Vlasenko
text data bss dec hex filename 1021988 559 5052 1027599 fae0f busybox_old 1021236 559 5052 1026847 fab1f busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-16awk: fix dodgy multi-char separators splitting logicDenys Vlasenko
function old new delta awk_split 521 484 -37 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-01libbb: shrink recursive_action() by reducing memory pressureDenys Vlasenko
function old new delta recursive_action1 - 316 +316 file_action_grep 161 164 +3 add_to_prg_cache_if_socket 202 205 +3 depmod_main 509 511 +2 writeFileToTarball 488 489 +1 parse_module 281 282 +1 fileAction 207 208 +1 act 189 190 +1 add_to_dirlist 65 64 -1 writeTarFile 196 194 -2 uuidcache_init 47 45 -2 uuidcache_check_device 109 107 -2 true_action 8 6 -2 run_parts_main 310 308 -2 netstat_main 534 532 -2 lsusb_main 29 27 -2 lspci_main 45 43 -2 initial_scan 138 136 -2 grep_main 845 843 -2 find_main 482 480 -2 config_file_action 437 435 -2 chmod_main 142 140 -2 dirAction 14 10 -4 diff_main 1544 1540 -4 chown_main 154 148 -6 skip_dir 136 129 -7 dir_act 191 184 -7 recursive_action 453 69 -384 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 7/20 up/down: 328/-439) Total: -111 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-23randomconfig fixesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-09awk: disallow "str"++, closes bug 12981Denys Vlasenko
function old new delta parse_expr 887 896 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>