summaryrefslogtreecommitdiffstats
path: root/contrib/libreadline
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2007-11-07 04:42:20 +0000
committerache <ache@FreeBSD.org>2007-11-07 04:42:20 +0000
commitcf6720ae992ee53f08f3f0959bbd448462636f41 (patch)
tree7883175243c155e4e2457e85578c99f8db5d2465 /contrib/libreadline
parentc5fcccabb7d654ede15e4c933abc518d1499df09 (diff)
downloadFreeBSD-src-cf6720ae992ee53f08f3f0959bbd448462636f41.zip
FreeBSD-src-cf6720ae992ee53f08f3f0959bbd448462636f41.tar.gz
Merge after importing official patches 3-7
Diffstat (limited to 'contrib/libreadline')
-rw-r--r--contrib/libreadline/complete.c2
-rw-r--r--contrib/libreadline/display.c55
-rw-r--r--contrib/libreadline/vi_mode.c48
3 files changed, 95 insertions, 10 deletions
diff --git a/contrib/libreadline/complete.c b/contrib/libreadline/complete.c
index 3606d50..9a930a1 100644
--- a/contrib/libreadline/complete.c
+++ b/contrib/libreadline/complete.c
@@ -429,7 +429,7 @@ get_y_or_n (for_pager)
return (1);
if (c == 'n' || c == 'N' || c == RUBOUT)
return (0);
- if (c == ABORT_CHAR)
+ if (c == ABORT_CHAR || c < 0)
_rl_abort_internal ();
if (for_pager && (c == NEWLINE || c == RETURN))
return (2);
diff --git a/contrib/libreadline/display.c b/contrib/libreadline/display.c
index 399cd4b..728364f 100644
--- a/contrib/libreadline/display.c
+++ b/contrib/libreadline/display.c
@@ -1519,11 +1519,31 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
{
/* Non-zero if we're increasing the number of lines. */
int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin;
+ /* If col_lendiff is > 0, implying that the new string takes up more
+ screen real estate than the old, but lendiff is < 0, meaning that it
+ takes fewer bytes, we need to just output the characters starting
+ from the first difference. These will overwrite what is on the
+ display, so there's no reason to do a smart update. This can really
+ only happen in a multibyte environment. */
+ if (lendiff < 0)
+ {
+ _rl_output_some_chars (nfd, temp);
+ _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
+ /* If nfd begins before any invisible characters in the prompt,
+ adjust _rl_last_c_pos to account for wrap_offset and set
+ cpos_adjusted to let the caller know. */
+ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
+ {
+ _rl_last_c_pos -= wrap_offset;
+ cpos_adjusted = 1;
+ }
+ return;
+ }
/* Sometimes it is cheaper to print the characters rather than
use the terminal's capabilities. If we're growing the number
of lines, make sure we actually cause the new line to wrap
around on auto-wrapping terminals. */
- if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
+ else if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
{
/* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and
_rl_horizontal_scroll_mode == 1, inserting the characters with
@@ -1599,8 +1619,22 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
temp = nls - nfd;
if (temp > 0)
{
+ /* If nfd begins at the prompt, or before the invisible
+ characters in the prompt, we need to adjust _rl_last_c_pos
+ in a multibyte locale to account for the wrap offset and
+ set cpos_adjusted accordingly. */
_rl_output_some_chars (nfd, temp);
- _rl_last_c_pos += _rl_col_width (nfd, 0, temp);;
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ {
+ _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
+ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
+ {
+ _rl_last_c_pos -= wrap_offset;
+ cpos_adjusted = 1;
+ }
+ }
+ else
+ _rl_last_c_pos += temp;
}
}
/* Otherwise, print over the existing material. */
@@ -1608,8 +1642,20 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
{
if (temp > 0)
{
+ /* If nfd begins at the prompt, or before the invisible
+ characters in the prompt, we need to adjust _rl_last_c_pos
+ in a multibyte locale to account for the wrap offset and
+ set cpos_adjusted accordingly. */
_rl_output_some_chars (nfd, temp);
_rl_last_c_pos += col_temp; /* XXX */
+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ {
+ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
+ {
+ _rl_last_c_pos -= wrap_offset;
+ cpos_adjusted = 1;
+ }
+ }
}
lendiff = (oe - old) - (ne - new);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
@@ -1745,7 +1791,10 @@ _rl_move_cursor_relative (new, data)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
dpos = _rl_col_width (data, 0, new);
- if (dpos > prompt_last_invisible) /* XXX - don't use woff here */
+ /* Use NEW when comparing against the last invisible character in the
+ prompt string, since they're both buffer indices and DPOS is a
+ desired display position. */
+ if (new > prompt_last_invisible) /* XXX - don't use woff here */
{
dpos -= woff;
/* Since this will be assigned to _rl_last_c_pos at the end (more
diff --git a/contrib/libreadline/vi_mode.c b/contrib/libreadline/vi_mode.c
index d0f01b1..342d454 100644
--- a/contrib/libreadline/vi_mode.c
+++ b/contrib/libreadline/vi_mode.c
@@ -887,6 +887,13 @@ rl_vi_domove (key, nextkey)
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+ if (c < 0)
+ {
+ *nextkey = 0;
+ return -1;
+ }
+
*nextkey = c;
if (!member (c, vi_motion))
@@ -903,6 +910,11 @@ rl_vi_domove (key, nextkey)
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key (); /* real command */
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ {
+ *nextkey = 0;
+ return -1;
+ }
*nextkey = c;
}
else if (key == c && (key == 'd' || key == 'y' || key == 'c'))
@@ -1225,14 +1237,22 @@ static int
_rl_vi_callback_char_search (data)
_rl_callback_generic_arg *data;
{
+ int c;
#if defined (HANDLE_MULTIBYTE)
- _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
+ c = _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
#else
RL_SETSTATE(RL_STATE_MOREINPUT);
- _rl_vi_last_search_char = rl_read_key ();
+ c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
#endif
+ if (c <= 0)
+ return -1;
+
+#if !defined (HANDLE_MULTIBYTE)
+ _rl_vi_last_search_char = c;
+#endif
+
_rl_callback_func = 0;
_rl_want_redisplay = 1;
@@ -1248,6 +1268,7 @@ int
rl_vi_char_search (count, key)
int count, key;
{
+ int c;
#if defined (HANDLE_MULTIBYTE)
static char *target;
static int tlen;
@@ -1294,11 +1315,17 @@ rl_vi_char_search (count, key)
else
{
#if defined (HANDLE_MULTIBYTE)
- _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
+ c = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
+ if (c <= 0)
+ return -1;
+ _rl_vi_last_search_mblen = c;
#else
RL_SETSTATE(RL_STATE_MOREINPUT);
- _rl_vi_last_search_char = rl_read_key ();
+ c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ return -1;
+ _rl_vi_last_search_char = c;
#endif
}
}
@@ -1468,6 +1495,9 @@ _rl_vi_callback_getchar (mb, mlen)
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
+ if (c < 0)
+ return -1;
+
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
c = _rl_read_mbstring (c, mb, mlen);
@@ -1486,6 +1516,9 @@ _rl_vi_callback_change_char (data)
_rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
+ if (c < 0)
+ return -1;
+
_rl_callback_func = 0;
_rl_want_redisplay = 1;
@@ -1517,6 +1550,9 @@ rl_vi_change_char (count, key)
else
_rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
+ if (c < 0)
+ return -1;
+
return (_rl_vi_change_char (count, c, mb));
}
@@ -1651,7 +1687,7 @@ _rl_vi_set_mark ()
ch = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
- if (ch < 'a' || ch > 'z')
+ if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
{
rl_ding ();
return -1;
@@ -1703,7 +1739,7 @@ _rl_vi_goto_mark ()
rl_point = rl_mark;
return 0;
}
- else if (ch < 'a' || ch > 'z')
+ else if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
{
rl_ding ();
return -1;
OpenPOWER on IntegriCloud