Submitted By: Jeremy Utley (jeremy@linuxfromscratch.org) Date: 2003-11-20 Initial Package Version: 4.3 Origin: GNU archive (http://ftp.gnu.org/gnu/readline/readline-4.3-patches) Description: Conglomeration of the 5 posted GNU patches to the Readline 4.3 source code. diff -Naur readline-4.3/bind.c readline-4.3-new/bind.c --- readline-4.3/bind.c 2002-01-24 16:15:52.000000000 +0000 +++ readline-4.3-new/bind.c 2003-11-20 06:35:07.000000000 +0000 @@ -311,7 +311,7 @@ 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 -Naur readline-4.3/display.c readline-4.3-new/display.c --- readline-4.3/display.c 2002-06-04 14:54:47.000000000 +0000 +++ readline-4.3-new/display.c 2003-11-20 06:35:07.000000000 +0000 @@ -70,7 +70,7 @@ 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 @@ { _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 @@ #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 @@ #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 @@ 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 @@ return width; } #endif /* HANDLE_MULTIBYTE */ - diff -Naur readline-4.3/mbutil.c readline-4.3-new/mbutil.c --- readline-4.3/mbutil.c 2002-06-04 15:54:29.000000000 +0000 +++ readline-4.3-new/mbutil.c 2003-11-20 06:35:07.000000000 +0000 @@ -205,14 +205,16 @@ 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 @@ 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 @@ 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 -Naur readline-4.3/readline.c readline-4.3-new/readline.c --- readline-4.3/readline.c 2002-03-13 22:10:46.000000000 +0000 +++ readline-4.3-new/readline.c 2003-11-20 06:35:07.000000000 +0000 @@ -684,6 +684,7 @@ } #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 -Naur readline-4.3/vi_mode.c readline-4.3-new/vi_mode.c --- readline-4.3/vi_mode.c 2002-05-23 17:27:58.000000000 +0000 +++ readline-4.3-new/vi_mode.c 2003-11-20 06:35:07.000000000 +0000 @@ -680,7 +680,8 @@ 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 @@ /* 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);