Hi,
I have found a bug in readline when handling multiline with wide characters.
This bug could be reproduced.
Type into line wide character(2 byte) and two another ascii
character(1 byte) for example "á12". Now if you prepend any ascii
characters (for example 'k') as many as the wide character reach
beginning of second line, the last character is doubled, it is printed
two times. If you press Ctrl-l the redraw is successfull. The last
character is not doubled.
start:
|á12 |
after prepending several 'k', the buggy result is:
|kkkkkkk|
|á122 |
instead of
|kkkkkkk|
|á12 |
Attached patch fixes this problem.
There is a problem in function update_line. In case where wide
character is at the beginning of new line and is not at the beginning
of old line, data of old line is moved and first character from new
line is copied into the old line. Problem is that there is no
modification of indices referencing moved data.
I am using readline 6.0 on ubuntu karmic(i386).
Martin Hamrle
--- readline-6.0.orig/display.c 2009-08-02 19:43:39.000000000 +0200
+++ readline6-6.0/display.c 2009-08-02 19:14:14.000000000 +0200
@@ -1319,11 +1319,15 @@
ret = mbrtowc (&wc, old, MB_CUR_MAX, &ps);
if (ret != 0 && bytes != 0)
{
- if (MB_INVALIDCH (ret))
- memmove (old+bytes, old+1, strlen (old+1));
- else
- memmove (old+bytes, old+ret, strlen (old+ret));
+ int i;
+ if (MB_INVALIDCH (ret)){
+ ret = 1;
+ }
+ memmove (old+bytes, old+ret, strlen (old+ret));
memcpy (old, new, bytes);
+ omax += bytes - ret;
+ for(i = current_line + 1; i <= inv_botlin + 1; i++)
+ vis_lbreaks[i] += bytes - ret;
}
}
else
@@ -1668,7 +1672,7 @@
multibyte characters and prompt strings with invisible
characters, but was previously disabled. */
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
- twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
+ twidth = _rl_col_width (nfd+lendiff, 0, temp-lendiff);
else
twidth = temp - lendiff;
_rl_last_c_pos += twidth;
_______________________________________________
Bug-readline mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-readline