busybox/editors
Ron Yorston 4b49422a08 vi: fix changes to word at end of line. Closes 11796
As reported in bug 11796 BusyBox vi incorrectly handles changes
to a word at the end of a line.  If the following line starts
with whitespace changing or deleting the last word of a line
with the 'cw' or 'dw' commands causes the lines to be joined.

This happens because the range for the change returned by
find_range() covers all whitespace after the word, including
newlines.  The problem can be fixed by setting 'ml' to zero
to indicate to yank_delete() that processing should stop at
the end of the current line.

However, this results in a new problem.  'dw' correctly deletes
all whitespace following the word but so does 'cw', which should
preserve the trailing whitespace.  To fix this the code to omit
whitespace from the change is modified to include all whitespace
not just blanks.

function                                             old     new   delta
do_cmd                                              5034    5069     +35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 35/0)               Total: 35 bytes

Reported-by: David Kelly <david.kelly@liberica.ch>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-28 17:16:46 +02:00
..
awk.c awk: Fix overly permissive func arg list parsing 2019-01-21 12:59:19 +01:00
cmp.c config: update size information 2018-12-28 03:20:17 +01:00
Config.src restore documentation on the build config language 2018-06-06 15:16:48 +02:00
diff.c regularize format of source file headers, no code changes 2017-09-18 16:28:43 +02:00
ed.c config: update size information 2018-12-28 03:20:17 +01:00
Kbuild.src switch editors/* to embedded-in-source kbuild system 2013-11-13 12:45:33 +01:00
patch_bbox.c getopt32: remove applet_long_options 2017-08-08 17:09:40 +02:00
patch_toybox.c config: update size information 2018-12-28 03:20:17 +01:00
patch.c config: update size information 2018-12-28 03:20:17 +01:00
sed_summary.htm doc: add info about sed s/.../.../I modifier 2008-03-01 19:29:56 +00:00
sed.c sed: code shrink 2019-01-21 13:49:28 +01:00
sed1line.txt add sed mini-doc 2007-11-13 17:13:31 +00:00
vi.c vi: fix changes to word at end of line. Closes 11796 2019-04-28 17:16:46 +02:00