[rfa] fix readline utf-8 display bug

Elena Zannoni ezannoni@redhat.com
Fri Jan 10 22:23:00 GMT 2003


Michael Elizabeth Chastain writes:
 > This is a patch from Chet Ramey, the maintainer of readline, to fix
 > the problem with perverse screen refresh with UTF-8.  This will fix
 > the problem with the test suite failing to run in UTF-8 environments
 > (the test suite patterns gets confuse by the bad perverse screen refresh).
 > 
 > I tested this in a standalone readline test program and in my gdb
 > testbed.  It works for me with LANG=en_US.UTF-8 (my normal language).
 > I tested with and without the "LC_ALL=C" kludge currently in lib/gdb.exp.
 > 
 > If this patch goes in, then I can submit to patch to revert the
 > assignment to LC_ALL in lib/gdb.exp, and we'll be back to testing
 > in the user's specified locale.
 > 
 > Okay to apply?

Sure. 
Thanks for following this up.

Elena


 > 
 > Michael C
 > 
 > ===
 > 
 > 2003-01-09  Michael Chastain  <mec@shout.net>
 > 
 > 	From Chet Ramey, <chet@po.cwru.edu>, the readline maintainer:
 > 	* display.c: Fix perverse screen refresh with UTF-8.
 > 
 > Index: display.c
 > ===================================================================
 > RCS file: /cvs/src/src/readline/display.c,v
 > retrieving revision 1.6
 > diff -u -r1.6 display.c
 > --- display.c	8 Dec 2002 22:31:37 -0000	1.6
 > +++ display.c	9 Jan 2003 21:17:22 -0000
 > @@ -74,7 +74,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))
 > @@ -1352,9 +1352,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
 >  	    }
 >  	}
 > @@ -1514,8 +1514,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
 > @@ -1598,11 +1605,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);
 >      }
 > @@ -2144,7 +2147,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;
 > @@ -2220,4 +2223,3 @@
 >    return width;
 >  }
 >  #endif /* HANDLE_MULTIBYTE */
 > -	  



More information about the Gdb-patches mailing list