aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-04-28 09:10:16 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2019-04-28 17:16:46 +0200
commit7b93e317c13053e40e76cc5c36404f92d05dd41c (patch)
treebbe4eb630d80211237971cddc9b5a188620b2c7b
parent4b49422a08b89bd01023e7b4fa73ab058ee66932 (diff)
downloadbusybox-w32-7b93e317c13053e40e76cc5c36404f92d05dd41c.tar.gz
busybox-w32-7b93e317c13053e40e76cc5c36404f92d05dd41c.tar.bz2
busybox-w32-7b93e317c13053e40e76cc5c36404f92d05dd41c.zip
vi: enable 'dG' command. Closes 11801
The 'G' command was omitted from the list of commands that change or delete whole lines. Add it in the appropriate places so the 'dG', 'cG' and 'yG' commands work, including in cases where an explicit line number has been supplied. function old new delta find_range 534 596 +62 .rodata 175166 175167 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 63/0) Total: 63 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>
-rw-r--r--editors/vi.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/editors/vi.c b/editors/vi.c
index dfef42019..8af1ef76b 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -3001,11 +3001,14 @@ static void do_cmd(int c);
3001static int find_range(char **start, char **stop, char c) 3001static int find_range(char **start, char **stop, char c)
3002{ 3002{
3003 char *save_dot, *p, *q, *t; 3003 char *save_dot, *p, *q, *t;
3004 int cnt, multiline = 0; 3004 int cnt, multiline = 0, forward;
3005 3005
3006 save_dot = dot; 3006 save_dot = dot;
3007 p = q = dot; 3007 p = q = dot;
3008 3008
3009 // will a 'G' command move forwards or backwards?
3010 forward = cmdcnt == 0 || cmdcnt > count_lines(text, dot);
3011
3009 if (strchr("cdy><", c)) { 3012 if (strchr("cdy><", c)) {
3010 // these cmds operate on whole lines 3013 // these cmds operate on whole lines
3011 p = q = begin_line(p); 3014 p = q = begin_line(p);
@@ -3029,13 +3032,13 @@ static int find_range(char **start, char **stop, char c)
3029 if (dot > text && *dot == '\n') 3032 if (dot > text && *dot == '\n')
3030 dot--; // stay off NL 3033 dot--; // stay off NL
3031 q = dot; 3034 q = dot;
3032 } else if (strchr("H-k{", c)) { 3035 } else if (strchr("H-k{", c) || (c == 'G' && !forward)) {
3033 // these operate on multi-lines backwards 3036 // these operate on multi-lines backwards
3034 q = end_line(dot); // find NL 3037 q = end_line(dot); // find NL
3035 do_cmd(c); // execute movement cmd 3038 do_cmd(c); // execute movement cmd
3036 dot_begin(); 3039 dot_begin();
3037 p = dot; 3040 p = dot;
3038 } else if (strchr("L+j}\r\n", c)) { 3041 } else if (strchr("L+j}\r\n", c) || (c == 'G' && forward)) {
3039 // these operate on multi-lines forwards 3042 // these operate on multi-lines forwards
3040 p = begin_line(dot); 3043 p = begin_line(dot);
3041 do_cmd(c); // execute movement cmd 3044 do_cmd(c); // execute movement cmd
@@ -3781,7 +3784,7 @@ static void do_cmd(int c)
3781 } else if (strchr("^0bBeEft%$ lh\b\177", c1)) { 3784 } else if (strchr("^0bBeEft%$ lh\b\177", c1)) {
3782 // partial line copy text into a register and delete 3785 // partial line copy text into a register and delete
3783 dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete word 3786 dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete word
3784 } else if (strchr("cdykjHL+-{}\r\n", c1)) { 3787 } else if (strchr("cdykjGHL+-{}\r\n", c1)) {
3785 // whole line copy text into a register and delete 3788 // whole line copy text into a register and delete
3786 dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete lines 3789 dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete lines
3787 whole = 1; 3790 whole = 1;