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