cmdedit: fix breakage
This commit is contained in:
parent
b01b4e2a1f
commit
253ce00296
@ -255,9 +255,9 @@ static void put(void)
|
|||||||
return;
|
return;
|
||||||
ocursor = cursor;
|
ocursor = cursor;
|
||||||
/* open hole and then fill it */
|
/* open hole and then fill it */
|
||||||
memmove(command_ps + cursor + j, command_ps + cursor, len - cursor + 1);
|
memmove(command_ps + cursor + j, command_ps + cursor, command_len - cursor + 1);
|
||||||
strncpy(command_ps + cursor, delbuf, j);
|
strncpy(command_ps + cursor, delbuf, j);
|
||||||
len += j;
|
command_len += j;
|
||||||
input_end(); /* rewrite new line */
|
input_end(); /* rewrite new line */
|
||||||
input_backward(cursor - ocursor - j + 1); /* at end of new text */
|
input_backward(cursor - ocursor - j + 1); /* at end of new text */
|
||||||
}
|
}
|
||||||
@ -365,8 +365,8 @@ enum {
|
|||||||
static int path_parse(char ***p, int flags)
|
static int path_parse(char ***p, int flags)
|
||||||
{
|
{
|
||||||
int npth;
|
int npth;
|
||||||
const char *tmp;
|
|
||||||
const char *pth;
|
const char *pth;
|
||||||
|
char *tmp;
|
||||||
char **res;
|
char **res;
|
||||||
|
|
||||||
/* if not setenv PATH variable, to search cur dir "." */
|
/* if not setenv PATH variable, to search cur dir "." */
|
||||||
@ -381,7 +381,7 @@ static int path_parse(char ***p, int flags)
|
|||||||
if (!pth || !pth[0] || LONE_CHAR(pth, ':'))
|
if (!pth || !pth[0] || LONE_CHAR(pth, ':'))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
tmp = pth;
|
tmp = (char*)pth;
|
||||||
npth = 1; /* path component count */
|
npth = 1; /* path component count */
|
||||||
while (1) {
|
while (1) {
|
||||||
tmp = strchr(tmp, ':');
|
tmp = strchr(tmp, ':');
|
||||||
@ -393,8 +393,7 @@ static int path_parse(char ***p, int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
res = xmalloc(npth * sizeof(char*));
|
res = xmalloc(npth * sizeof(char*));
|
||||||
res[0] = xstrdup(pth);
|
res[0] = tmp = xstrdup(pth);
|
||||||
tmp = pth;
|
|
||||||
npth = 1;
|
npth = 1;
|
||||||
while (1) {
|
while (1) {
|
||||||
tmp = strchr(tmp, ':');
|
tmp = strchr(tmp, ':');
|
||||||
@ -810,7 +809,7 @@ static void input_tab(int *lastWasTab)
|
|||||||
}
|
}
|
||||||
len_found = strlen(tmp);
|
len_found = strlen(tmp);
|
||||||
/* have space to placed match? */
|
/* have space to placed match? */
|
||||||
if ((len_found - strlen(matchBuf) + len) < BUFSIZ) {
|
if ((len_found - strlen(matchBuf) + command_len) < BUFSIZ) {
|
||||||
/* before word for match */
|
/* before word for match */
|
||||||
command_ps[cursor - recalc_pos] = 0;
|
command_ps[cursor - recalc_pos] = 0;
|
||||||
/* save tail line */
|
/* save tail line */
|
||||||
@ -824,9 +823,9 @@ static void input_tab(int *lastWasTab)
|
|||||||
/* new pos */
|
/* new pos */
|
||||||
recalc_pos = cursor + len_found;
|
recalc_pos = cursor + len_found;
|
||||||
/* new len */
|
/* new len */
|
||||||
len = strlen(command_ps);
|
command_len = strlen(command_ps);
|
||||||
/* write out the matched command */
|
/* write out the matched command */
|
||||||
redraw(cmdedit_y, len - recalc_pos);
|
redraw(cmdedit_y, command_len - recalc_pos);
|
||||||
}
|
}
|
||||||
free(tmp);
|
free(tmp);
|
||||||
} else {
|
} else {
|
||||||
@ -839,7 +838,7 @@ static void input_tab(int *lastWasTab)
|
|||||||
/* Go to the next line */
|
/* Go to the next line */
|
||||||
goto_new_line();
|
goto_new_line();
|
||||||
showfiles();
|
showfiles();
|
||||||
redraw(0, len - sav_cursor);
|
redraw(0, command_len - sav_cursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -982,9 +981,9 @@ static void remember_in_history(const char *str)
|
|||||||
static void
|
static void
|
||||||
vi_Word_motion(char *command, int eat)
|
vi_Word_motion(char *command, int eat)
|
||||||
{
|
{
|
||||||
while (cursor < len && !isspace(command[cursor]))
|
while (cursor < command_len && !isspace(command[cursor]))
|
||||||
input_forward();
|
input_forward();
|
||||||
if (eat) while (cursor < len && isspace(command[cursor]))
|
if (eat) while (cursor < command_len && isspace(command[cursor]))
|
||||||
input_forward();
|
input_forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -992,19 +991,19 @@ static void
|
|||||||
vi_word_motion(char *command, int eat)
|
vi_word_motion(char *command, int eat)
|
||||||
{
|
{
|
||||||
if (isalnum(command[cursor]) || command[cursor] == '_') {
|
if (isalnum(command[cursor]) || command[cursor] == '_') {
|
||||||
while (cursor < len
|
while (cursor < command_len
|
||||||
&& (isalnum(command[cursor+1]) || command[cursor+1] == '_'))
|
&& (isalnum(command[cursor+1]) || command[cursor+1] == '_'))
|
||||||
input_forward();
|
input_forward();
|
||||||
} else if (ispunct(command[cursor])) {
|
} else if (ispunct(command[cursor])) {
|
||||||
while (cursor < len && ispunct(command[cursor+1]))
|
while (cursor < command_len && ispunct(command[cursor+1]))
|
||||||
input_forward();
|
input_forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursor < len)
|
if (cursor < command_len)
|
||||||
input_forward();
|
input_forward();
|
||||||
|
|
||||||
if (eat && cursor < len && isspace(command[cursor]))
|
if (eat && cursor < command_len && isspace(command[cursor]))
|
||||||
while (cursor < len && isspace(command[cursor]))
|
while (cursor < command_len && isspace(command[cursor]))
|
||||||
input_forward();
|
input_forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1012,30 +1011,30 @@ static void
|
|||||||
vi_End_motion(char *command)
|
vi_End_motion(char *command)
|
||||||
{
|
{
|
||||||
input_forward();
|
input_forward();
|
||||||
while (cursor < len && isspace(command[cursor]))
|
while (cursor < command_len && isspace(command[cursor]))
|
||||||
input_forward();
|
input_forward();
|
||||||
while (cursor < len-1 && !isspace(command[cursor+1]))
|
while (cursor < command_len-1 && !isspace(command[cursor+1]))
|
||||||
input_forward();
|
input_forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vi_end_motion(char *command)
|
vi_end_motion(char *command)
|
||||||
{
|
{
|
||||||
if (cursor >= len-1)
|
if (cursor >= command_len-1)
|
||||||
return;
|
return;
|
||||||
input_forward();
|
input_forward();
|
||||||
while (cursor < len-1 && isspace(command[cursor]))
|
while (cursor < command_len-1 && isspace(command[cursor]))
|
||||||
input_forward();
|
input_forward();
|
||||||
if (cursor >= len-1)
|
if (cursor >= command_len-1)
|
||||||
return;
|
return;
|
||||||
if (isalnum(command[cursor]) || command[cursor] == '_') {
|
if (isalnum(command[cursor]) || command[cursor] == '_') {
|
||||||
while (cursor < len-1
|
while (cursor < command_len-1
|
||||||
&& (isalnum(command[cursor+1]) || command[cursor+1] == '_')
|
&& (isalnum(command[cursor+1]) || command[cursor+1] == '_')
|
||||||
) {
|
) {
|
||||||
input_forward();
|
input_forward();
|
||||||
}
|
}
|
||||||
} else if (ispunct(command[cursor])) {
|
} else if (ispunct(command[cursor])) {
|
||||||
while (cursor < len-1 && ispunct(command[cursor+1]))
|
while (cursor < command_len-1 && ispunct(command[cursor+1]))
|
||||||
input_forward();
|
input_forward();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user