Roman Rakus d1932ba
			     BASH PATCH REPORT
Roman Rakus d1932ba
			     =================
Roman Rakus d1932ba
Roman Rakus d1932ba
Bash-Release: 3.2
Roman Rakus d1932ba
Patch-ID: bash32-044
Roman Rakus d1932ba
Roman Rakus d1932ba
Bug-Reported-by:	slinkp <stuff@slinkp.com>
Roman Rakus d1932ba
Bug-Reference-ID:	<da52a26a-9f38-4861-a918-14d3482b539d@c65g2000hsa.googlegroups.com>
Roman Rakus d1932ba
Bug-Reference-URL:	http://lists.gnu.org/archive/html/bug-bash/2008-05/msg00085.html
Roman Rakus d1932ba
Roman Rakus d1932ba
Bug-Description:
Roman Rakus d1932ba
Roman Rakus d1932ba
The presence of invisible characters in a prompt longer than the screenwidth
Roman Rakus d1932ba
with invisible characters on the first and last prompt lines caused readline
Roman Rakus d1932ba
to place the cursor in the wrong physical location.
Roman Rakus d1932ba
Roman Rakus d1932ba
Patch:
Roman Rakus d1932ba
Roman Rakus d1932ba
*** ../bash-3.2-patched/lib/readline/display.c	2007-12-14 21:12:40.000000000 -0500
Roman Rakus d1932ba
--- lib/readline/display.c	2008-10-23 09:39:46.000000000 -0400
Roman Rakus d1932ba
***************
Roman Rakus d1932ba
*** 911,914 ****
Roman Rakus d1932ba
--- 944,951 ----
Roman Rakus d1932ba
  	     OFFSET (which has already been calculated above).  */
Roman Rakus d1932ba
  
Roman Rakus d1932ba
+ #define INVIS_FIRST()	(prompt_physical_chars > _rl_screenwidth ? prompt_invis_chars_first_line : wrap_offset)
Roman Rakus d1932ba
+ #define WRAP_OFFSET(line, offset)  ((line == 0) \
Roman Rakus d1932ba
+ 					? (offset ? INVIS_FIRST() : 0) \
Roman Rakus d1932ba
+ 					: ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))
Roman Rakus d1932ba
  #define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
Roman Rakus d1932ba
  #define VIS_LLEN(l)	((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
Roman Rakus d1932ba
***************
Roman Rakus d1932ba
*** 945,949 ****
Roman Rakus d1932ba
  		  _rl_last_c_pos > wrap_offset &&
Roman Rakus d1932ba
  		  o_cpos < prompt_last_invisible)
Roman Rakus d1932ba
! 		_rl_last_c_pos -= wrap_offset;
Roman Rakus d1932ba
  		  
Roman Rakus d1932ba
  	      /* If this is the line with the prompt, we might need to
Roman Rakus d1932ba
--- 982,992 ----
Roman Rakus d1932ba
  		  _rl_last_c_pos > wrap_offset &&
Roman Rakus d1932ba
  		  o_cpos < prompt_last_invisible)
Roman Rakus d1932ba
! 		_rl_last_c_pos -= prompt_invis_chars_first_line;	/* XXX - was wrap_offset */
Roman Rakus d1932ba
! 	      else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
Roman Rakus d1932ba
! 			(MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
Roman Rakus d1932ba
! 			cpos_adjusted == 0 &&
Roman Rakus d1932ba
! 			_rl_last_c_pos != o_cpos &&
Roman Rakus d1932ba
! 			_rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))
Roman Rakus d1932ba
! 		_rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
Roman Rakus d1932ba
  		  
Roman Rakus d1932ba
  	      /* If this is the line with the prompt, we might need to
Roman Rakus d1932ba
***************
Roman Rakus d1932ba
*** 1205,1209 ****
Roman Rakus d1932ba
  {
Roman Rakus d1932ba
    register char *ofd, *ols, *oe, *nfd, *nls, *ne;
Roman Rakus d1932ba
!   int temp, lendiff, wsatend, od, nd, o_cpos;
Roman Rakus d1932ba
    int current_invis_chars;
Roman Rakus d1932ba
    int col_lendiff, col_temp;
Roman Rakus d1932ba
--- 1264,1268 ----
Roman Rakus d1932ba
  {
Roman Rakus d1932ba
    register char *ofd, *ols, *oe, *nfd, *nls, *ne;
Roman Rakus d1932ba
!   int temp, lendiff, wsatend, od, nd, twidth, o_cpos;
Roman Rakus d1932ba
    int current_invis_chars;
Roman Rakus d1932ba
    int col_lendiff, col_temp;
Roman Rakus d1932ba
***************
Roman Rakus d1932ba
*** 1221,1225 ****
Roman Rakus d1932ba
      temp = _rl_last_c_pos;
Roman Rakus d1932ba
    else
Roman Rakus d1932ba
!     temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
Roman Rakus d1932ba
    if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
Roman Rakus d1932ba
  	&& _rl_last_v_pos == current_line - 1)
Roman Rakus d1932ba
--- 1280,1284 ----
Roman Rakus d1932ba
      temp = _rl_last_c_pos;
Roman Rakus d1932ba
    else
Roman Rakus d1932ba
!     temp = _rl_last_c_pos - WRAP_OFFSET (_rl_last_v_pos, visible_wrap_offset);
Roman Rakus d1932ba
    if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
Roman Rakus d1932ba
  	&& _rl_last_v_pos == current_line - 1)
Roman Rakus d1932ba
***************
Roman Rakus d1932ba
*** 1587,1599 ****
Roman Rakus d1932ba
  	    {
Roman Rakus d1932ba
  	      _rl_output_some_chars (nfd + lendiff, temp - lendiff);
Roman Rakus d1932ba
- #if 1
Roman Rakus d1932ba
  	     /* XXX -- this bears closer inspection.  Fixes a redisplay bug
Roman Rakus d1932ba
  		reported against bash-3.0-alpha by Andreas Schwab involving
Roman Rakus d1932ba
  		multibyte characters and prompt strings with invisible
Roman Rakus d1932ba
  		characters, but was previously disabled. */
Roman Rakus d1932ba
! 	      _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
Roman Rakus d1932ba
! #else
Roman Rakus d1932ba
! 	      _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff);
Roman Rakus d1932ba
! #endif
Roman Rakus d1932ba
  	    }
Roman Rakus d1932ba
  	}
Roman Rakus d1932ba
--- 1648,1660 ----
Roman Rakus d1932ba
  	    {
Roman Rakus d1932ba
  	      _rl_output_some_chars (nfd + lendiff, temp - lendiff);
Roman Rakus d1932ba
  	     /* XXX -- this bears closer inspection.  Fixes a redisplay bug
Roman Rakus d1932ba
  		reported against bash-3.0-alpha by Andreas Schwab involving
Roman Rakus d1932ba
  		multibyte characters and prompt strings with invisible
Roman Rakus d1932ba
  		characters, but was previously disabled. */
Roman Rakus d1932ba
! 	      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
Roman Rakus d1932ba
! 		twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
Roman Rakus d1932ba
! 	      else
Roman Rakus d1932ba
! 		twidth = temp - lendiff;
Roman Rakus d1932ba
! 	      _rl_last_c_pos += twidth;
Roman Rakus d1932ba
  	    }
Roman Rakus d1932ba
  	}
Roman Rakus d1932ba
***************
Roman Rakus d1932ba
*** 1789,1793 ****
Roman Rakus d1932ba
    int cpos, dpos;		/* current and desired cursor positions */
Roman Rakus d1932ba
  
Roman Rakus d1932ba
!   woff = W_OFFSET (_rl_last_v_pos, wrap_offset);
Roman Rakus d1932ba
    cpos = _rl_last_c_pos;
Roman Rakus d1932ba
  #if defined (HANDLE_MULTIBYTE)
Roman Rakus d1932ba
--- 1850,1854 ----
Roman Rakus d1932ba
    int cpos, dpos;		/* current and desired cursor positions */
Roman Rakus d1932ba
  
Roman Rakus d1932ba
!   woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
Roman Rakus d1932ba
    cpos = _rl_last_c_pos;
Roman Rakus d1932ba
  #if defined (HANDLE_MULTIBYTE)
Roman Rakus d1932ba
***************
Roman Rakus d1932ba
*** 1803,1807 ****
Roman Rakus d1932ba
  	 prompt string, since they're both buffer indices and DPOS is a
Roman Rakus d1932ba
  	 desired display position. */
Roman Rakus d1932ba
!       if (new > prompt_last_invisible)		/* XXX - don't use woff here */
Roman Rakus d1932ba
  	{
Roman Rakus d1932ba
  	  dpos -= woff;
Roman Rakus d1932ba
--- 1864,1872 ----
Roman Rakus d1932ba
  	 prompt string, since they're both buffer indices and DPOS is a
Roman Rakus d1932ba
  	 desired display position. */
Roman Rakus d1932ba
!       if ((new > prompt_last_invisible) ||		/* XXX - don't use woff here */
Roman Rakus d1932ba
! 	  (prompt_physical_chars > _rl_screenwidth &&
Roman Rakus d1932ba
! 	   _rl_last_v_pos == prompt_last_screen_line &&
Roman Rakus d1932ba
! 	   wrap_offset != woff &&
Roman Rakus d1932ba
! 	   new > (prompt_last_invisible-_rl_screenwidth-wrap_offset)))
Roman Rakus d1932ba
  	{
Roman Rakus d1932ba
  	  dpos -= woff;
Roman Rakus d1932ba
*** ../bash-3.2/patchlevel.h	Thu Apr 13 08:31:04 2006
Roman Rakus d1932ba
--- patchlevel.h	Mon Oct 16 14:22:54 2006
Roman Rakus d1932ba
***************
Roman Rakus d1932ba
*** 26,30 ****
Roman Rakus d1932ba
     looks for to find the patch level (for the sccs version string). */
Roman Rakus d1932ba
  
Roman Rakus d1932ba
! #define PATCHLEVEL 43
Roman Rakus d1932ba
  
Roman Rakus d1932ba
  #endif /* _PATCHLEVEL_H_ */
Roman Rakus d1932ba
--- 26,30 ----
Roman Rakus d1932ba
     looks for to find the patch level (for the sccs version string). */
Roman Rakus d1932ba
  
Roman Rakus d1932ba
! #define PATCHLEVEL 44
Roman Rakus d1932ba
  
Roman Rakus d1932ba
  #endif /* _PATCHLEVEL_H_ */