Skip to content

Commit

Permalink
同步至官方mirror/busybox@8e71f2a
Browse files Browse the repository at this point in the history
  • Loading branch information
mysterywolf committed May 12, 2021
1 parent eb3256f commit d824307
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 75 deletions.
52 changes: 0 additions & 52 deletions .gitignore

This file was deleted.

48 changes: 25 additions & 23 deletions vi.c
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ static char *get_address(char *p, int *b, int *e)
break;
state = GET_SEPARATOR;
} else {
if (state == GET_SEPARATOR && *e < 0)
if (state == GET_SEPARATOR && *b >= 0 && *e < 0)
*e = count_lines(text, dot);
break;
}
Expand Down Expand Up @@ -1588,9 +1588,20 @@ static void colon(char *buf)
modified_count = 0;
last_modified_count = -1;
}
if (cmd[0] == 'x'
|| cmd[1] == 'q' || cmd[1] == 'n'
) {
if (cmd[1] == 'n') {
editing = 0;
} else if (cmd[0] == 'x' || cmd[1] == 'q') {
// are there other files to edit?
int n = cmdline_filecnt - optind - 1;
if (n > 0) {
if (useforce) {
// force end of argv list
optind = cmdline_filecnt;
} else {
status_line_bold("%u more file(s) to edit", n);
goto ret;
}
}
editing = 0;
}
}
Expand Down Expand Up @@ -2247,11 +2258,10 @@ static int at_eof(const char *s)

static int find_range(char **start, char **stop, int cmd)
{
char *save_dot, *p, *q, *t;
char *p, *q, *t;
int buftype = -1;
int c;

save_dot = dot;
p = q = dot;

#if ENABLE_FEATURE_VI_YANKMARK
Expand Down Expand Up @@ -2340,14 +2350,8 @@ static int find_range(char **start, char **stop, int cmd)
}
}

if (buftype == WHOLE || cmd == '<' || cmd == '>') {
p = begin_line(p);
q = end_line(q);
}

*start = p;
*stop = q;
dot = save_dot;
return buftype;
}

Expand Down Expand Up @@ -3103,7 +3107,7 @@ static char *get_input_line(const char *prompt)
strcpy(buf, prompt);
last_status_cksum = 0; // force status update
go_bottom_and_clear_to_eol();
write1(prompt); // write out the :, /, or ? prompt
write1(buf); // write out the :, /, or ? prompt

i = strlen(buf);
while (i < MAX_INPUT_LEN - 1) {
Expand All @@ -3116,8 +3120,8 @@ static char *get_input_line(const char *prompt)
#endif
c == 8 || c == 127) {
// user wants to erase prev char
buf[--i] = '\0';
write1("\b \b"); // erase char on screen
buf[--i] = '\0';
if (i <= 0) // user backs up before b-o-l, exit
break;
} else if (c > 0 && c < 256) { // exclude Unicode
Expand Down Expand Up @@ -4116,7 +4120,7 @@ static void do_cmd(int c)
if (find_range(&p, &q, c) == -1)
goto dc6;
i = count_lines(p, q); // # of lines we are shifting
for ( ; i > 0; i--, p = next_line(p)) {
for (p = begin_line(p); i > 0; i--, p = next_line(p)) {
if (c == '<') {
// shift left- remove tab or tabstop spaces
if (*p == '\t') {
Expand Down Expand Up @@ -4368,12 +4372,16 @@ static void do_cmd(int c)
# endif
if (c == 'y' || c == 'Y')
yf = YANKONLY;
save_dot = dot;
#endif
// determine range, and whether it spans lines
buftype = find_range(&p, &q, c);
if (buftype == -1) // invalid range
goto dc6;
if (buftype == WHOLE) {
save_dot = p; // final cursor position is start of range
p = begin_line(p);
q = end_line(q);
}
dot = yank_delete(p, q, buftype, yf, ALLOW_UNDO); // delete word
if (buftype == WHOLE) {
if (c == 'c') {
Expand All @@ -4382,15 +4390,9 @@ static void do_cmd(int c)
if (dot != (end-1)) {
dot_prev();
}
} else if (c == 'd') {
dot_begin();
dot_skip_over_ws();
}
#if ENABLE_FEATURE_VI_YANKMARK
else /* (c == 'y' || c == 'Y') */ {
} else {
dot = save_dot;
}
#endif
}
// if CHANGING, not deleting, start inserting after the delete
if (c == 'c') {
Expand Down

0 comments on commit d824307

Please sign in to comment.