Tomas Janousek 5a0cfd
			     BASH PATCH REPORT
Tomas Janousek 5a0cfd
			     =================
Tomas Janousek 5a0cfd
Tomas Janousek 5a0cfd
Bash-Release: 3.2
Tomas Janousek 5a0cfd
Patch-ID: bash32-024
Tomas Janousek 5a0cfd
Tomas Janousek 5a0cfd
Bug-Reported-by:	Peter Volkov <torre_cremata@mail.ru>
Tomas Janousek 5a0cfd
Bug-Reference-ID:	<1178376645.9063.25.camel@localhost>
Tomas Janousek 5a0cfd
Bug-Reference-URL:	http://bugs.gentoo.org/177095
Tomas Janousek 5a0cfd
Tomas Janousek 5a0cfd
Bug-Description:
Tomas Janousek 5a0cfd
Tomas Janousek 5a0cfd
The readline display code miscalculated the screen position when performing
Tomas Janousek 5a0cfd
a redisplay in which the new text occupies more screen space that the old,
Tomas Janousek 5a0cfd
but takes fewer bytes to do so (e.g., when replacing a shorter string
Tomas Janousek 5a0cfd
containing multibyte characters with a longer one containing only ASCII).
Tomas Janousek 5a0cfd
Tomas Janousek 5a0cfd
Patch:
Tomas Janousek 5a0cfd
Tomas Janousek 5a0cfd
*** ../bash-3.2-patched/lib/readline/display.c	Thu Apr 26 11:38:22 2007
Tomas Janousek 5a0cfd
--- lib/readline/display.c	Thu Jul 12 23:10:10 2007
Tomas Janousek 5a0cfd
***************
Tomas Janousek 5a0cfd
*** 1519,1527 ****
Tomas Janousek 5a0cfd
        /* Non-zero if we're increasing the number of lines. */
Tomas Janousek 5a0cfd
        int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin;
Tomas Janousek 5a0cfd
        /* Sometimes it is cheaper to print the characters rather than
Tomas Janousek 5a0cfd
  	 use the terminal's capabilities.  If we're growing the number
Tomas Janousek 5a0cfd
  	 of lines, make sure we actually cause the new line to wrap
Tomas Janousek 5a0cfd
  	 around on auto-wrapping terminals. */
Tomas Janousek 5a0cfd
!       if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
Tomas Janousek 5a0cfd
  	{
Tomas Janousek 5a0cfd
  	  /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and
Tomas Janousek 5a0cfd
--- 1568,1596 ----
Tomas Janousek 5a0cfd
        /* Non-zero if we're increasing the number of lines. */
Tomas Janousek 5a0cfd
        int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin;
Tomas Janousek 5a0cfd
+       /* If col_lendiff is > 0, implying that the new string takes up more
Tomas Janousek 5a0cfd
+ 	 screen real estate than the old, but lendiff is < 0, meaning that it
Tomas Janousek 5a0cfd
+ 	 takes fewer bytes, we need to just output the characters starting
Tomas Janousek 5a0cfd
+ 	 from the first difference.  These will overwrite what is on the
Tomas Janousek 5a0cfd
+ 	 display, so there's no reason to do a smart update.  This can really
Tomas Janousek 5a0cfd
+ 	 only happen in a multibyte environment. */
Tomas Janousek 5a0cfd
+       if (lendiff < 0)
Tomas Janousek 5a0cfd
+ 	{
Tomas Janousek 5a0cfd
+ 	  _rl_output_some_chars (nfd, temp);
Tomas Janousek 5a0cfd
+ 	  _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
Tomas Janousek 5a0cfd
+ 	  /* If nfd begins before any invisible characters in the prompt,
Tomas Janousek 5a0cfd
+ 	     adjust _rl_last_c_pos to account for wrap_offset and set
Tomas Janousek 5a0cfd
+ 	     cpos_adjusted to let the caller know. */
Tomas Janousek 5a0cfd
+ 	  if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
Tomas Janousek 5a0cfd
+ 	    {
Tomas Janousek 5a0cfd
+ 	      _rl_last_c_pos -= wrap_offset;
Tomas Janousek 5a0cfd
+ 	      cpos_adjusted = 1;
Tomas Janousek 5a0cfd
+ 	    }
Tomas Janousek 5a0cfd
+ 	  return;
Tomas Janousek 5a0cfd
+ 	}
Tomas Janousek 5a0cfd
        /* Sometimes it is cheaper to print the characters rather than
Tomas Janousek 5a0cfd
  	 use the terminal's capabilities.  If we're growing the number
Tomas Janousek 5a0cfd
  	 of lines, make sure we actually cause the new line to wrap
Tomas Janousek 5a0cfd
  	 around on auto-wrapping terminals. */
Tomas Janousek 5a0cfd
!       else if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
Tomas Janousek 5a0cfd
  	{
Tomas Janousek 5a0cfd
  	  /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and
Tomas Janousek 5a0cfd
*** ../bash-3.2/patchlevel.h	Thu Apr 13 08:31:04 2006
Tomas Janousek 5a0cfd
--- patchlevel.h	Mon Oct 16 14:22:54 2006
Tomas Janousek 5a0cfd
***************
Tomas Janousek 5a0cfd
*** 26,30 ****
Tomas Janousek 5a0cfd
     looks for to find the patch level (for the sccs version string). */
Tomas Janousek 5a0cfd
  
Tomas Janousek 5a0cfd
! #define PATCHLEVEL 23
Tomas Janousek 5a0cfd
  
Tomas Janousek 5a0cfd
  #endif /* _PATCHLEVEL_H_ */
Tomas Janousek 5a0cfd
--- 26,30 ----
Tomas Janousek 5a0cfd
     looks for to find the patch level (for the sccs version string). */
Tomas Janousek 5a0cfd
  
Tomas Janousek 5a0cfd
! #define PATCHLEVEL 24
Tomas Janousek 5a0cfd
  
Tomas Janousek 5a0cfd
  #endif /* _PATCHLEVEL_H_ */