diff options
author | Ron Yorston <rmy@pobox.com> | 2021-06-09 16:11:03 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-14 20:58:17 +0200 |
commit | f7ed0e8ae0508fafe91ae3eb20663b9f7870adda (patch) | |
tree | 8c9b51bd5afb3be4cc53aec6d8f5444fbb7ae22b | |
parent | e2b9215868a3d72691e5bc0f887354254606447b (diff) | |
download | busybox-w32-f7ed0e8ae0508fafe91ae3eb20663b9f7870adda.tar.gz busybox-w32-f7ed0e8ae0508fafe91ae3eb20663b9f7870adda.tar.bz2 busybox-w32-f7ed0e8ae0508fafe91ae3eb20663b9f7870adda.zip |
vi: ':r' should insert text after current line
When no line number is specified ':read' should place the inserted
text after the current line, not before.
This used to be correct but was broken when commit 0c42a6b07
(vi: fix empty line range regression) revealed a bug in commit
7a8ceb4eb (vi: changes to line addresses for colon commands).
function old new delta
colon 3960 3952 -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>
-rw-r--r-- | editors/vi.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/editors/vi.c b/editors/vi.c index beccef4b4..7c1877bb2 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -2998,12 +2998,10 @@ static void colon(char *buf) | |||
2998 | status_line_bold("No current filename"); | 2998 | status_line_bold("No current filename"); |
2999 | goto ret; | 2999 | goto ret; |
3000 | } | 3000 | } |
3001 | if (e < 0) { // no addr given- read after current line | 3001 | if (e == 0) { // user said ":0r foo" |
3002 | q = begin_line(dot); | ||
3003 | } else if (e == 0) { // user said ":0r foo" | ||
3004 | q = text; | 3002 | q = text; |
3005 | } else { // addr given- read after that line | 3003 | } else { // read after given line or current line if none given |
3006 | q = next_line(find_line(e)); | 3004 | q = next_line(e > 0 ? find_line(e) : dot); |
3007 | // read after last line | 3005 | // read after last line |
3008 | if (q == end-1) | 3006 | if (q == end-1) |
3009 | ++q; | 3007 | ++q; |