summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2011-11-23 19:11:27 -0500
committerChet Ramey <chet.ramey@case.edu>2011-11-23 19:11:27 -0500
commit753c336c548b9a1358058751c6288b6e31458d89 (patch)
tree271d7bcfa4c4d8d5e2a613109fd9623731846d98
parent1e4e5d08e95b810dc5bcec9a3b9b296a0c3afa85 (diff)
downloadreadline-753c336c548b9a1358058751c6288b6e31458d89.tar.gz
Readline-4.3.005 import
-rw-r--r--bind.c2
-rw-r--r--display.c26
-rw-r--r--mbutil.c20
-rw-r--r--readline.c1
-rw-r--r--vi_mode.c7
5 files changed, 35 insertions, 21 deletions
diff --git a/bind.c b/bind.c
index 65ef401..7103888 100644
--- a/bind.c
+++ b/bind.c
@@ -311,7 +311,7 @@ rl_generic_bind (type, keyseq, data, map)
mapped to something, `abc' to be mapped to something else,
and the function bound to `a' to be executed when the user
types `abx', leaving `bx' in the input queue. */
- if (k.function /* && k.type == ISFUNC */)
+ if (k.function && ((k.type == ISFUNC && k.function != rl_do_lowercase_version) || k.type == ISMACR))
{
map[ANYOTHERKEY] = k;
k.function = 0;
diff --git a/display.c b/display.c
index 5150ea6..f1b86a4 100644
--- a/display.c
+++ b/display.c
@@ -70,7 +70,7 @@ static void insert_some_chars PARAMS((char *, int, int));
static void cr PARAMS((void));
#if defined (HANDLE_MULTIBYTE)
-static int _rl_col_width PARAMS((char *, int, int));
+static int _rl_col_width PARAMS((const char *, int, int));
static int *_rl_wrapped_line;
#else
# define _rl_col_width(l, s, e) (((e) <= (s)) ? 0 : (e) - (s))
@@ -1348,9 +1348,9 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
{
_rl_output_some_chars (nfd + lendiff, temp - lendiff);
#if 0
- _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff) - col_lendiff;
-#else
_rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
+#else
+ _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff);
#endif
}
}
@@ -1510,8 +1510,15 @@ _rl_move_cursor_relative (new, data)
#if defined (HANDLE_MULTIBYTE)
/* If we have multibyte characters, NEW is indexed by the buffer point in
a multibyte string, but _rl_last_c_pos is the display position. In
- this case, NEW's display position is not obvious. */
- if ((MB_CUR_MAX == 1 || rl_byte_oriented ) && _rl_last_c_pos == new) return;
+ this case, NEW's display position is not obvious and must be
+ calculated. */
+ if (MB_CUR_MAX == 1 || rl_byte_oriented)
+ {
+ if (_rl_last_c_pos == new)
+ return;
+ }
+ else if (_rl_last_c_pos == _rl_col_width (data, 0, new))
+ return;
#else
if (_rl_last_c_pos == new) return;
#endif
@@ -1594,11 +1601,7 @@ _rl_move_cursor_relative (new, data)
#endif
{
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
- {
- tputs (_rl_term_cr, 1, _rl_output_character_function);
- for (i = 0; i < new; i++)
- putc (data[i], rl_outstream);
- }
+ _rl_backspace (_rl_last_c_pos - _rl_col_width (data, 0, new));
else
_rl_backspace (_rl_last_c_pos - new);
}
@@ -2117,7 +2120,7 @@ _rl_current_display_line ()
scan from the beginning of the string to take the state into account. */
static int
_rl_col_width (str, start, end)
- char *str;
+ const char *str;
int start, end;
{
wchar_t wc;
@@ -2193,4 +2196,3 @@ _rl_col_width (str, start, end)
return width;
}
#endif /* HANDLE_MULTIBYTE */
-
diff --git a/mbutil.c b/mbutil.c
index 50302f0..8794d02 100644
--- a/mbutil.c
+++ b/mbutil.c
@@ -205,14 +205,16 @@ _rl_get_char_len (src, ps)
if (tmp == (size_t)(-2))
{
/* shorted to compose multibyte char */
- memset (ps, 0, sizeof(mbstate_t));
+ if (ps)
+ memset (ps, 0, sizeof(mbstate_t));
return -2;
}
else if (tmp == (size_t)(-1))
{
/* invalid to compose multibyte char */
/* initialize the conversion state */
- memset (ps, 0, sizeof(mbstate_t));
+ if (ps)
+ memset (ps, 0, sizeof(mbstate_t));
return -1;
}
else if (tmp == (size_t)0)
@@ -225,9 +227,12 @@ _rl_get_char_len (src, ps)
return 1. Otherwise return 0. */
int
_rl_compare_chars (buf1, pos1, ps1, buf2, pos2, ps2)
- char *buf1, *buf2;
- mbstate_t *ps1, *ps2;
- int pos1, pos2;
+ char *buf1;
+ int pos1;
+ mbstate_t *ps1;
+ char *buf2;
+ int pos2;
+ mbstate_t *ps2;
{
int i, w1, w2;
@@ -276,8 +281,11 @@ _rl_adjust_point(string, point, ps)
pos++;
/* clear the state of the byte sequence, because
in this case effect of mbstate is undefined */
- memset (ps, 0, sizeof (mbstate_t));
+ if (ps)
+ memset (ps, 0, sizeof (mbstate_t));
}
+ else if (tmp == 0)
+ pos++;
else
pos += tmp;
}
diff --git a/readline.c b/readline.c
index 28801f1..f583358 100644
--- a/readline.c
+++ b/readline.c
@@ -684,6 +684,7 @@ _rl_dispatch_subseq (key, map, got_subseq)
}
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap &&
+ key != ANYOTHERKEY &&
_rl_vi_textmod_command (key))
_rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);
#endif
diff --git a/vi_mode.c b/vi_mode.c
index 5d146b3..8930364 100644
--- a/vi_mode.c
+++ b/vi_mode.c
@@ -680,7 +680,8 @@ _rl_vi_change_mbchar_case (count)
int count;
{
wchar_t wc;
- char mb[MB_LEN_MAX];
+ char mb[MB_LEN_MAX+1];
+ int mblen;
mbstate_t ps;
memset (&ps, 0, sizeof (mbstate_t));
@@ -703,7 +704,9 @@ _rl_vi_change_mbchar_case (count)
/* Vi is kind of strange here. */
if (wc)
{
- wctomb (mb, wc);
+ mblen = wctomb (mb, wc);
+ if (mblen >= 0)
+ mb[mblen] = '\0';
rl_begin_undo_group ();
rl_delete (1, 0);
rl_insert_text (mb);