aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrian Somers <brian@FreeBSD.org>1998-06-27 16:10:40 +0000
committerBrian Somers <brian@FreeBSD.org>1998-06-27 16:10:40 +0000
commit10d91426852cca57cde24ceac631a99b247c214f (patch)
tree5603b822edfb9e2b3ba8cb674ed64b21a41ef644 /lib
parent431e760b940f014f770e94576b85d811293733ff (diff)
downloadsrc-10d91426852cca57cde24ceac631a99b247c214f.tar.gz
src-10d91426852cca57cde24ceac631a99b247c214f.zip
Fixes assorted problems with the history edit functions in libedit. This
affects sh, ftp (and others?). Submitted by: Max Euston <meuston@jmrodgers.com> PR: 6516
Notes
Notes: svn path=/head/; revision=37199
Diffstat (limited to 'lib')
-rw-r--r--lib/libedit/chared.c17
-rw-r--r--lib/libedit/chared.h1
-rw-r--r--lib/libedit/common.c5
-rw-r--r--lib/libedit/map.c2
-rw-r--r--lib/libedit/read.c4
-rw-r--r--lib/libedit/vi.c34
6 files changed, 49 insertions, 14 deletions
diff --git a/lib/libedit/chared.c b/lib/libedit/chared.c
index dcd189c90343..ed6a7c71e090 100644
--- a/lib/libedit/chared.c
+++ b/lib/libedit/chared.c
@@ -153,12 +153,27 @@ ce__isword(p)
/* cv__isword():
- * Return if p is part of a word according to vi
+ * Return type of word for p according to vi
*/
protected int
cv__isword(p)
int p;
{
+ if (isspace((unsigned char) p))
+ return 0;
+ if ((unsigned char) p == '_' || isalnum((unsigned char) p))
+ return 1;
+ return 2;
+}
+
+
+/* c___isword():
+ * Return if p is part of a space-delimited word (!isspace)
+ */
+protected int
+c___isword(p)
+ int p;
+{
return !isspace((unsigned char) p);
}
diff --git a/lib/libedit/chared.h b/lib/libedit/chared.h
index 22d07f0392ee..f979b9344c30 100644
--- a/lib/libedit/chared.h
+++ b/lib/libedit/chared.h
@@ -138,6 +138,7 @@ protected int cv__isword __P((int));
protected void cv_delfini __P((EditLine *));
protected char *cv__endword __P((char *, char *, int));
protected int ce__isword __P((int));
+protected int c___isword __P((int));
protected void cv_undo __P((EditLine *, int, int, char *));
protected char *cv_next_word __P((EditLine*, char *, char *, int,
int (*)(int)));
diff --git a/lib/libedit/common.c b/lib/libedit/common.c
index 6908819e7b87..66b7c9009833 100644
--- a/lib/libedit/common.c
+++ b/lib/libedit/common.c
@@ -110,8 +110,11 @@ ed_insert(el, c)
re_refresh(el);
}
+ if (el->el_state.inputmode == MODE_REPLACE_1 || el->el_state.inputmode == MODE_REPLACE)
+ el->el_chared.c_undo.action=CHANGE;
+
if (el->el_state.inputmode == MODE_REPLACE_1)
- (void) vi_command_mode(el, 0);
+ return vi_command_mode(el, 0);
return CC_NORM;
}
diff --git a/lib/libedit/map.c b/lib/libedit/map.c
index 3b282ccca810..571982704e22 100644
--- a/lib/libedit/map.c
+++ b/lib/libedit/map.c
@@ -701,7 +701,7 @@ private el_action_t el_map_vi_command[] = {
/* 82 */ VI_REPLACE_MODE, /* R */
/* 83 */ VI_SUBSTITUTE_LINE, /* S */
/* 84 */ VI_TO_PREV_CHAR, /* T */
- /* 85 */ ED_UNASSIGNED, /* U */
+ /* 85 */ VI_UNDO_LINE, /* U */
/* 86 */ ED_UNASSIGNED, /* V */
/* 87 */ VI_NEXT_SPACE_WORD, /* W */
/* 88 */ ED_DELETE_PREV_CHAR, /* X */
diff --git a/lib/libedit/read.c b/lib/libedit/read.c
index 6475a25f068a..d8d662826ce5 100644
--- a/lib/libedit/read.c
+++ b/lib/libedit/read.c
@@ -196,10 +196,10 @@ read_getcmd(el, cmdnum, ch)
el_action_t *cmdnum;
char *ch;
{
- el_action_t cmd = 0;
+ el_action_t cmd = ED_UNASSIGNED;
int num;
- while (cmd == 0 || cmd == ED_SEQUENCE_LEAD_IN) {
+ while (cmd == ED_UNASSIGNED || cmd == ED_SEQUENCE_LEAD_IN) {
if ((num = el_getc(el, ch)) != 1) /* if EOF or error */
return num;
diff --git a/lib/libedit/vi.c b/lib/libedit/vi.c
index 3a8ef0541ad2..5099757d9354 100644
--- a/lib/libedit/vi.c
+++ b/lib/libedit/vi.c
@@ -173,7 +173,7 @@ vi_prev_space_word(el, c)
el->el_line.cursor = cv_prev_word(el, el->el_line.cursor,
el->el_line.buffer,
el->el_state.argument,
- cv__isword);
+ c___isword);
if (el->el_chared.c_vcmd.action & DELETE) {
cv_delfini(el);
@@ -186,7 +186,7 @@ vi_prev_space_word(el, c)
/* vi_prev_word():
* Vi move to the previous word
- * [B]
+ * [b]
*/
protected el_action_t
/*ARGSUSED*/
@@ -200,7 +200,7 @@ vi_prev_word(el, c)
el->el_line.cursor = cv_prev_word(el, el->el_line.cursor,
el->el_line.buffer,
el->el_state.argument,
- ce__isword);
+ cv__isword);
if (el->el_chared.c_vcmd.action & DELETE) {
cv_delfini(el);
@@ -227,7 +227,7 @@ vi_next_space_word(el, c)
el->el_line.cursor = cv_next_word(el, el->el_line.cursor,
el->el_line.lastchar,
el->el_state.argument,
- cv__isword);
+ c___isword);
if (el->el_map.type == MAP_VI)
if (el->el_chared.c_vcmd.action & DELETE) {
@@ -254,7 +254,7 @@ vi_next_word(el, c)
el->el_line.cursor = cv_next_word(el, el->el_line.cursor,
el->el_line.lastchar,
el->el_state.argument,
- ce__isword);
+ cv__isword);
if (el->el_map.type == MAP_VI)
if (el->el_chared.c_vcmd.action & DELETE) {
@@ -346,7 +346,7 @@ vi_replace_char(el, c)
el->el_chared.c_undo.ptr = el->el_line.cursor;
el->el_chared.c_undo.isize = 0;
el->el_chared.c_undo.dsize = 0;
- return CC_NORM;
+ return CC_ARGHACK;
}
@@ -366,13 +366,13 @@ vi_replace_mode(el, c)
el->el_chared.c_undo.ptr = el->el_line.cursor;
el->el_chared.c_undo.isize = 0;
el->el_chared.c_undo.dsize = 0;
- return CC_NORM;
+ return CC_ARGHACK;
}
/* vi_substitute_char():
* Vi replace character under the cursor and enter insert mode
- * [r]
+ * [s]
*/
protected el_action_t
/*ARGSUSED*/
@@ -448,7 +448,8 @@ vi_add(el, c)
EditLine *el;
int c;
{
- int ret;
+ el_action_t ret;
+
el->el_map.current = el->el_map.key;
if (el->el_line.cursor < el->el_line.lastchar) {
el->el_line.cursor++;
@@ -664,6 +665,21 @@ vi_undo(el, c)
}
+/* vi_undo_line():
+ * Vi undo all changes
+ * [U]
+ */
+protected el_action_t
+/*ARGSUSED*/
+vi_undo_line(el, c)
+ EditLine *el;
+ int c;
+{
+
+ return hist_get(el);
+}
+
+
/* vi_command_mode():
* Vi enter command mode (use alternative key bindings)
* [<ESC>]