Karsten Hopp f51e78
To: vim-dev@vim.org
Karsten Hopp f51e78
Subject: patch 7.1.093
Karsten Hopp f51e78
Fcc: outbox
Karsten Hopp f51e78
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp f51e78
Mime-Version: 1.0
Karsten Hopp f51e78
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp f51e78
Content-Transfer-Encoding: 8bit
Karsten Hopp f51e78
------------
Karsten Hopp f51e78
Karsten Hopp f51e78
Patch 7.1.093
Karsten Hopp f51e78
Problem:    Reading past end of a screen line when determining cell width.
Karsten Hopp f51e78
	    (Dominique Pelle)
Karsten Hopp f51e78
Solution:   Add an argument to mb_off2cells() for the maximum offset.
Karsten Hopp f51e78
Files:	    src/globals.h, src/gui.c, src/mbyte.c, src/proto/mbyte.pro,
Karsten Hopp f51e78
	    src/screen.c
Karsten Hopp f51e78
Karsten Hopp f51e78
Karsten Hopp f51e78
*** ../vim-7.1.092/src/globals.h	Thu Aug 30 12:24:21 2007
Karsten Hopp f51e78
--- src/globals.h	Wed Aug 29 22:27:45 2007
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 801,807 ****
Karsten Hopp f51e78
  EXTERN int (*mb_char2bytes) __ARGS((int c, char_u *buf)) INIT(= latin_char2bytes);
Karsten Hopp f51e78
  EXTERN int (*mb_ptr2cells) __ARGS((char_u *p)) INIT(= latin_ptr2cells);
Karsten Hopp f51e78
  EXTERN int (*mb_char2cells) __ARGS((int c)) INIT(= latin_char2cells);
Karsten Hopp f51e78
! EXTERN int (*mb_off2cells) __ARGS((unsigned off)) INIT(= latin_off2cells);
Karsten Hopp f51e78
  EXTERN int (*mb_ptr2char) __ARGS((char_u *p)) INIT(= latin_ptr2char);
Karsten Hopp f51e78
  EXTERN int (*mb_head_off) __ARGS((char_u *base, char_u *p)) INIT(= latin_head_off);
Karsten Hopp f51e78
  
Karsten Hopp f51e78
--- 801,807 ----
Karsten Hopp f51e78
  EXTERN int (*mb_char2bytes) __ARGS((int c, char_u *buf)) INIT(= latin_char2bytes);
Karsten Hopp f51e78
  EXTERN int (*mb_ptr2cells) __ARGS((char_u *p)) INIT(= latin_ptr2cells);
Karsten Hopp f51e78
  EXTERN int (*mb_char2cells) __ARGS((int c)) INIT(= latin_char2cells);
Karsten Hopp f51e78
! EXTERN int (*mb_off2cells) __ARGS((unsigned off, unsigned max_off)) INIT(= latin_off2cells);
Karsten Hopp f51e78
  EXTERN int (*mb_ptr2char) __ARGS((char_u *p)) INIT(= latin_ptr2char);
Karsten Hopp f51e78
  EXTERN int (*mb_head_off) __ARGS((char_u *base, char_u *p)) INIT(= latin_head_off);
Karsten Hopp f51e78
  
Karsten Hopp f51e78
*** ../vim-7.1.092/src/gui.c	Wed Aug 15 20:07:53 2007
Karsten Hopp f51e78
--- src/gui.c	Wed Aug 29 22:16:51 2007
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 1080,1086 ****
Karsten Hopp f51e78
  		cur_width = gui.char_width;
Karsten Hopp f51e78
  	    }
Karsten Hopp f51e78
  #ifdef FEAT_MBYTE
Karsten Hopp f51e78
! 	    if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col) > 1)
Karsten Hopp f51e78
  	    {
Karsten Hopp f51e78
  		/* Double wide character. */
Karsten Hopp f51e78
  		if (shape_table[idx].shape != SHAPE_VER)
Karsten Hopp f51e78
--- 1080,1087 ----
Karsten Hopp f51e78
  		cur_width = gui.char_width;
Karsten Hopp f51e78
  	    }
Karsten Hopp f51e78
  #ifdef FEAT_MBYTE
Karsten Hopp f51e78
! 	    if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col,
Karsten Hopp f51e78
! 				    LineOffset[gui.row] + screen_Columns) > 1)
Karsten Hopp f51e78
  	    {
Karsten Hopp f51e78
  		/* Double wide character. */
Karsten Hopp f51e78
  		if (shape_table[idx].shape != SHAPE_VER)
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 1159,1165 ****
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  # if defined(FEAT_GUI_TABLINE) && (defined(FEAT_GUI_MSWIN) \
Karsten Hopp f51e78
!  	|| defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_MAC))
Karsten Hopp f51e78
      if (gui_has_tabline())
Karsten Hopp f51e78
  	text_area_y += gui.tabline_height;
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
--- 1160,1166 ----
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  # if defined(FEAT_GUI_TABLINE) && (defined(FEAT_GUI_MSWIN) \
Karsten Hopp f51e78
! 	|| defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_MAC))
Karsten Hopp f51e78
      if (gui_has_tabline())
Karsten Hopp f51e78
  	text_area_y += gui.tabline_height;
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
*** ../vim-7.1.092/src/mbyte.c	Sat Aug 11 13:57:31 2007
Karsten Hopp f51e78
--- src/mbyte.c	Thu Aug 30 13:48:30 2007
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 1310,1329 ****
Karsten Hopp f51e78
  /*
Karsten Hopp f51e78
   * mb_off2cells() function pointer.
Karsten Hopp f51e78
   * Return number of display cells for char at ScreenLines[off].
Karsten Hopp f51e78
!  * Caller must make sure "off" and "off + 1" are valid!
Karsten Hopp f51e78
   */
Karsten Hopp f51e78
  /*ARGSUSED*/
Karsten Hopp f51e78
      int
Karsten Hopp f51e78
! latin_off2cells(off)
Karsten Hopp f51e78
      unsigned	off;
Karsten Hopp f51e78
  {
Karsten Hopp f51e78
      return 1;
Karsten Hopp f51e78
  }
Karsten Hopp f51e78
  
Karsten Hopp f51e78
      int
Karsten Hopp f51e78
! dbcs_off2cells(off)
Karsten Hopp f51e78
      unsigned	off;
Karsten Hopp f51e78
  {
Karsten Hopp f51e78
      /* Number of cells is equal to number of bytes, except for euc-jp when
Karsten Hopp f51e78
       * the first byte is 0x8e. */
Karsten Hopp f51e78
      if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
Karsten Hopp f51e78
--- 1310,1335 ----
Karsten Hopp f51e78
  /*
Karsten Hopp f51e78
   * mb_off2cells() function pointer.
Karsten Hopp f51e78
   * Return number of display cells for char at ScreenLines[off].
Karsten Hopp f51e78
!  * We make sure that the offset used is less than "max_off".
Karsten Hopp f51e78
   */
Karsten Hopp f51e78
  /*ARGSUSED*/
Karsten Hopp f51e78
      int
Karsten Hopp f51e78
! latin_off2cells(off, max_off)
Karsten Hopp f51e78
      unsigned	off;
Karsten Hopp f51e78
+     unsigned	max_off;
Karsten Hopp f51e78
  {
Karsten Hopp f51e78
      return 1;
Karsten Hopp f51e78
  }
Karsten Hopp f51e78
  
Karsten Hopp f51e78
      int
Karsten Hopp f51e78
! dbcs_off2cells(off, max_off)
Karsten Hopp f51e78
      unsigned	off;
Karsten Hopp f51e78
+     unsigned	max_off;
Karsten Hopp f51e78
  {
Karsten Hopp f51e78
+     /* never check beyond end of the line */
Karsten Hopp f51e78
+     if (off >= max_off)
Karsten Hopp f51e78
+ 	return 1;
Karsten Hopp f51e78
+ 
Karsten Hopp f51e78
      /* Number of cells is equal to number of bytes, except for euc-jp when
Karsten Hopp f51e78
       * the first byte is 0x8e. */
Karsten Hopp f51e78
      if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 1332,1341 ****
Karsten Hopp f51e78
  }
Karsten Hopp f51e78
  
Karsten Hopp f51e78
      int
Karsten Hopp f51e78
! utf_off2cells(off)
Karsten Hopp f51e78
      unsigned	off;
Karsten Hopp f51e78
  {
Karsten Hopp f51e78
!     return ScreenLines[off + 1] == 0 ? 2 : 1;
Karsten Hopp f51e78
  }
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  /*
Karsten Hopp f51e78
--- 1338,1348 ----
Karsten Hopp f51e78
  }
Karsten Hopp f51e78
  
Karsten Hopp f51e78
      int
Karsten Hopp f51e78
! utf_off2cells(off, max_off)
Karsten Hopp f51e78
      unsigned	off;
Karsten Hopp f51e78
+     unsigned	max_off;
Karsten Hopp f51e78
  {
Karsten Hopp f51e78
!     return (off + 1 < max_off && ScreenLines[off + 1] == 0) ? 2 : 1;
Karsten Hopp f51e78
  }
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  /*
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 2899,2910 ****
Karsten Hopp f51e78
      if (composing_hangul)
Karsten Hopp f51e78
  	return TRUE;
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
!     if (enc_dbcs != 0)
Karsten Hopp f51e78
! 	return dbcs_off2cells(LineOffset[row] + col) > 1;
Karsten Hopp f51e78
!     if (enc_utf8)
Karsten Hopp f51e78
! 	return (col + 1 < Columns
Karsten Hopp f51e78
! 		&& ScreenLines[LineOffset[row] + col + 1] == 0);
Karsten Hopp f51e78
!     return FALSE;
Karsten Hopp f51e78
  }
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  # if defined(FEAT_CLIPBOARD) || defined(FEAT_GUI) || defined(FEAT_RIGHTLEFT) \
Karsten Hopp f51e78
--- 2906,2913 ----
Karsten Hopp f51e78
      if (composing_hangul)
Karsten Hopp f51e78
  	return TRUE;
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
!     return (*mb_off2cells)(LineOffset[row] + col,
Karsten Hopp f51e78
! 					LineOffset[row] + screen_Columns) > 1;
Karsten Hopp f51e78
  }
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  # if defined(FEAT_CLIPBOARD) || defined(FEAT_GUI) || defined(FEAT_RIGHTLEFT) \
Karsten Hopp f51e78
*** ../vim-7.1.092/src/proto/mbyte.pro	Sat May  5 20:02:52 2007
Karsten Hopp f51e78
--- src/proto/mbyte.pro	Wed Aug 29 20:49:02 2007
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 12,20 ****
Karsten Hopp f51e78
  int utf_ptr2cells __ARGS((char_u *p));
Karsten Hopp f51e78
  int dbcs_ptr2cells __ARGS((char_u *p));
Karsten Hopp f51e78
  int latin_char2cells __ARGS((int c));
Karsten Hopp f51e78
! int latin_off2cells __ARGS((unsigned off));
Karsten Hopp f51e78
! int dbcs_off2cells __ARGS((unsigned off));
Karsten Hopp f51e78
! int utf_off2cells __ARGS((unsigned off));
Karsten Hopp f51e78
  int latin_ptr2char __ARGS((char_u *p));
Karsten Hopp f51e78
  int utf_ptr2char __ARGS((char_u *p));
Karsten Hopp f51e78
  int mb_ptr2char_adv __ARGS((char_u **pp));
Karsten Hopp f51e78
--- 12,20 ----
Karsten Hopp f51e78
  int utf_ptr2cells __ARGS((char_u *p));
Karsten Hopp f51e78
  int dbcs_ptr2cells __ARGS((char_u *p));
Karsten Hopp f51e78
  int latin_char2cells __ARGS((int c));
Karsten Hopp f51e78
! int latin_off2cells __ARGS((unsigned off, unsigned max_off));
Karsten Hopp f51e78
! int dbcs_off2cells __ARGS((unsigned off, unsigned max_off));
Karsten Hopp f51e78
! int utf_off2cells __ARGS((unsigned off, unsigned max_off));
Karsten Hopp f51e78
  int latin_ptr2char __ARGS((char_u *p));
Karsten Hopp f51e78
  int utf_ptr2char __ARGS((char_u *p));
Karsten Hopp f51e78
  int mb_ptr2char_adv __ARGS((char_u **pp));
Karsten Hopp f51e78
*** ../vim-7.1.092/src/screen.c	Sun Aug  5 20:10:16 2007
Karsten Hopp f51e78
--- src/screen.c	Thu Aug 30 10:31:26 2007
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 1024,1030 ****
Karsten Hopp f51e78
  	    type = VALID;
Karsten Hopp f51e78
      }
Karsten Hopp f51e78
  
Karsten Hopp f51e78
!     /* Trick: we want to avoid clearning the screen twice.  screenclear() will
Karsten Hopp f51e78
       * set "screen_cleared" to TRUE.  The special value MAYBE (which is still
Karsten Hopp f51e78
       * non-zero and thus not FALSE) will indicate that screenclear() was not
Karsten Hopp f51e78
       * called. */
Karsten Hopp f51e78
--- 1024,1030 ----
Karsten Hopp f51e78
  	    type = VALID;
Karsten Hopp f51e78
      }
Karsten Hopp f51e78
  
Karsten Hopp f51e78
!     /* Trick: we want to avoid clearing the screen twice.  screenclear() will
Karsten Hopp f51e78
       * set "screen_cleared" to TRUE.  The special value MAYBE (which is still
Karsten Hopp f51e78
       * non-zero and thus not FALSE) will indicate that screenclear() was not
Karsten Hopp f51e78
       * called. */
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 4632,4638 ****
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  	/*
Karsten Hopp f51e78
  	 * At end of screen line and there is more to come: Display the line
Karsten Hopp f51e78
! 	 * so far.  If there is no more to display it is catched above.
Karsten Hopp f51e78
  	 */
Karsten Hopp f51e78
  	if ((
Karsten Hopp f51e78
  #ifdef FEAT_RIGHTLEFT
Karsten Hopp f51e78
--- 4632,4638 ----
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  	/*
Karsten Hopp f51e78
  	 * At end of screen line and there is more to come: Display the line
Karsten Hopp f51e78
! 	 * so far.  If there is no more to display it is caught above.
Karsten Hopp f51e78
  	 */
Karsten Hopp f51e78
  	if ((
Karsten Hopp f51e78
  #ifdef FEAT_RIGHTLEFT
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 4709,4717 ****
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
  #ifdef FEAT_MBYTE
Karsten Hopp f51e78
  			 && !(has_mbyte
Karsten Hopp f51e78
! 			     && ((*mb_off2cells)(LineOffset[screen_row]) == 2
Karsten Hopp f51e78
  				 || (*mb_off2cells)(LineOffset[screen_row - 1]
Karsten Hopp f51e78
! 							+ (int)Columns - 2) == 2))
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
  		   )
Karsten Hopp f51e78
  		{
Karsten Hopp f51e78
--- 4709,4721 ----
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
  #ifdef FEAT_MBYTE
Karsten Hopp f51e78
  			 && !(has_mbyte
Karsten Hopp f51e78
! 			     && ((*mb_off2cells)(LineOffset[screen_row],
Karsten Hopp f51e78
! 				     LineOffset[screen_row] + screen_Columns)
Karsten Hopp f51e78
! 									  == 2
Karsten Hopp f51e78
  				 || (*mb_off2cells)(LineOffset[screen_row - 1]
Karsten Hopp f51e78
! 							+ (int)Columns - 2,
Karsten Hopp f51e78
! 				     LineOffset[screen_row] + screen_Columns)
Karsten Hopp f51e78
! 									== 2))
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
  		   )
Karsten Hopp f51e78
  		{
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 4871,4876 ****
Karsten Hopp f51e78
--- 4875,4884 ----
Karsten Hopp f51e78
  {
Karsten Hopp f51e78
      unsigned	    off_from;
Karsten Hopp f51e78
      unsigned	    off_to;
Karsten Hopp f51e78
+ #ifdef FEAT_MBYTE
Karsten Hopp f51e78
+     unsigned	    max_off_from;
Karsten Hopp f51e78
+     unsigned	    max_off_to;
Karsten Hopp f51e78
+ #endif
Karsten Hopp f51e78
      int		    col = 0;
Karsten Hopp f51e78
  #if defined(FEAT_GUI) || defined(UNIX) || defined(FEAT_VERTSPLIT)
Karsten Hopp f51e78
      int		    hl;
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 4897,4902 ****
Karsten Hopp f51e78
--- 4905,4914 ----
Karsten Hopp f51e78
  
Karsten Hopp f51e78
      off_from = (unsigned)(current_ScreenLine - ScreenLines);
Karsten Hopp f51e78
      off_to = LineOffset[row] + coloff;
Karsten Hopp f51e78
+ #ifdef FEAT_MBYTE
Karsten Hopp f51e78
+     max_off_from = off_from + screen_Columns;
Karsten Hopp f51e78
+     max_off_to = LineOffset[row] + screen_Columns;
Karsten Hopp f51e78
+ #endif
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  #ifdef FEAT_RIGHTLEFT
Karsten Hopp f51e78
      if (rlflag)
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 4931,4937 ****
Karsten Hopp f51e78
      {
Karsten Hopp f51e78
  #ifdef FEAT_MBYTE
Karsten Hopp f51e78
  	if (has_mbyte && (col + 1 < endcol))
Karsten Hopp f51e78
! 	    char_cells = (*mb_off2cells)(off_from);
Karsten Hopp f51e78
  	else
Karsten Hopp f51e78
  	    char_cells = 1;
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
--- 4943,4949 ----
Karsten Hopp f51e78
      {
Karsten Hopp f51e78
  #ifdef FEAT_MBYTE
Karsten Hopp f51e78
  	if (has_mbyte && (col + 1 < endcol))
Karsten Hopp f51e78
! 	    char_cells = (*mb_off2cells)(off_from, max_off_from);
Karsten Hopp f51e78
  	else
Karsten Hopp f51e78
  	    char_cells = 1;
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 5008,5014 ****
Karsten Hopp f51e78
  		 * ScreenLinesUC[] is sufficient. */
Karsten Hopp f51e78
  		if (char_cells == 1
Karsten Hopp f51e78
  			&& col + 1 < endcol
Karsten Hopp f51e78
! 			&& (*mb_off2cells)(off_to) > 1)
Karsten Hopp f51e78
  		{
Karsten Hopp f51e78
  		    /* Writing a single-cell character over a double-cell
Karsten Hopp f51e78
  		     * character: need to redraw the next cell. */
Karsten Hopp f51e78
--- 5020,5026 ----
Karsten Hopp f51e78
  		 * ScreenLinesUC[] is sufficient. */
Karsten Hopp f51e78
  		if (char_cells == 1
Karsten Hopp f51e78
  			&& col + 1 < endcol
Karsten Hopp f51e78
! 			&& (*mb_off2cells)(off_to, max_off_to) > 1)
Karsten Hopp f51e78
  		{
Karsten Hopp f51e78
  		    /* Writing a single-cell character over a double-cell
Karsten Hopp f51e78
  		     * character: need to redraw the next cell. */
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 5017,5024 ****
Karsten Hopp f51e78
  		}
Karsten Hopp f51e78
  		else if (char_cells == 2
Karsten Hopp f51e78
  			&& col + 2 < endcol
Karsten Hopp f51e78
! 			&& (*mb_off2cells)(off_to) == 1
Karsten Hopp f51e78
! 			&& (*mb_off2cells)(off_to + 1) > 1)
Karsten Hopp f51e78
  		{
Karsten Hopp f51e78
  		    /* Writing the second half of a double-cell character over
Karsten Hopp f51e78
  		     * a double-cell character: need to redraw the second
Karsten Hopp f51e78
--- 5029,5036 ----
Karsten Hopp f51e78
  		}
Karsten Hopp f51e78
  		else if (char_cells == 2
Karsten Hopp f51e78
  			&& col + 2 < endcol
Karsten Hopp f51e78
! 			&& (*mb_off2cells)(off_to, max_off_to) == 1
Karsten Hopp f51e78
! 			&& (*mb_off2cells)(off_to + 1, max_off_to) > 1)
Karsten Hopp f51e78
  		{
Karsten Hopp f51e78
  		    /* Writing the second half of a double-cell character over
Karsten Hopp f51e78
  		     * a double-cell character: need to redraw the second
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 5037,5046 ****
Karsten Hopp f51e78
  	     * char over the left halve of an existing one. */
Karsten Hopp f51e78
  	    if (has_mbyte && col + char_cells == endcol
Karsten Hopp f51e78
  		    && ((char_cells == 1
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off_to) > 1)
Karsten Hopp f51e78
  			|| (char_cells == 2
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off_to) == 1
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off_to + 1) > 1)))
Karsten Hopp f51e78
  		clear_next = TRUE;
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
  
Karsten Hopp f51e78
--- 5049,5058 ----
Karsten Hopp f51e78
  	     * char over the left halve of an existing one. */
Karsten Hopp f51e78
  	    if (has_mbyte && col + char_cells == endcol
Karsten Hopp f51e78
  		    && ((char_cells == 1
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off_to, max_off_to) > 1)
Karsten Hopp f51e78
  			|| (char_cells == 2
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off_to, max_off_to) == 1
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off_to + 1, max_off_to) > 1)))
Karsten Hopp f51e78
  		clear_next = TRUE;
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
  
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 5180,5189 ****
Karsten Hopp f51e78
  			/* find previous character by counting from first
Karsten Hopp f51e78
  			 * column and get its width. */
Karsten Hopp f51e78
  			unsigned off = LineOffset[row];
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  			while (off < off_to)
Karsten Hopp f51e78
  			{
Karsten Hopp f51e78
! 			    prev_cells = (*mb_off2cells)(off);
Karsten Hopp f51e78
  			    off += prev_cells;
Karsten Hopp f51e78
  			}
Karsten Hopp f51e78
  		    }
Karsten Hopp f51e78
--- 5192,5202 ----
Karsten Hopp f51e78
  			/* find previous character by counting from first
Karsten Hopp f51e78
  			 * column and get its width. */
Karsten Hopp f51e78
  			unsigned off = LineOffset[row];
Karsten Hopp f51e78
+ 			unsigned max_off = LineOffset[row] + screen_Columns;
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  			while (off < off_to)
Karsten Hopp f51e78
  			{
Karsten Hopp f51e78
! 			    prev_cells = (*mb_off2cells)(off, max_off);
Karsten Hopp f51e78
  			    off += prev_cells;
Karsten Hopp f51e78
  			}
Karsten Hopp f51e78
  		    }
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 5369,5375 ****
Karsten Hopp f51e78
  static int skip_status_match_char __ARGS((expand_T *xp, char_u *s));
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  /*
Karsten Hopp f51e78
!  * Get the lenght of an item as it will be shown in the status line.
Karsten Hopp f51e78
   */
Karsten Hopp f51e78
      static int
Karsten Hopp f51e78
  status_match_len(xp, s)
Karsten Hopp f51e78
--- 5382,5388 ----
Karsten Hopp f51e78
  static int skip_status_match_char __ARGS((expand_T *xp, char_u *s));
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  /*
Karsten Hopp f51e78
!  * Get the length of an item as it will be shown in the status line.
Karsten Hopp f51e78
   */
Karsten Hopp f51e78
      static int
Karsten Hopp f51e78
  status_match_len(xp, s)
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 5435,5441 ****
Karsten Hopp f51e78
      int		row;
Karsten Hopp f51e78
      char_u	*buf;
Karsten Hopp f51e78
      int		len;
Karsten Hopp f51e78
!     int		clen;		/* lenght in screen cells */
Karsten Hopp f51e78
      int		fillchar;
Karsten Hopp f51e78
      int		attr;
Karsten Hopp f51e78
      int		i;
Karsten Hopp f51e78
--- 5448,5454 ----
Karsten Hopp f51e78
      int		row;
Karsten Hopp f51e78
      char_u	*buf;
Karsten Hopp f51e78
      int		len;
Karsten Hopp f51e78
!     int		clen;		/* length in screen cells */
Karsten Hopp f51e78
      int		fillchar;
Karsten Hopp f51e78
      int		attr;
Karsten Hopp f51e78
      int		i;
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 6187,6192 ****
Karsten Hopp f51e78
--- 6200,6206 ----
Karsten Hopp f51e78
      char_u	*ptr = text;
Karsten Hopp f51e78
      int		c;
Karsten Hopp f51e78
  #ifdef FEAT_MBYTE
Karsten Hopp f51e78
+     unsigned	max_off;
Karsten Hopp f51e78
      int		mbyte_blen = 1;
Karsten Hopp f51e78
      int		mbyte_cells = 1;
Karsten Hopp f51e78
      int		u8c = 0;
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 6203,6208 ****
Karsten Hopp f51e78
--- 6217,6225 ----
Karsten Hopp f51e78
  	return;
Karsten Hopp f51e78
  
Karsten Hopp f51e78
      off = LineOffset[row] + col;
Karsten Hopp f51e78
+ #ifdef FEAT_MBYTE
Karsten Hopp f51e78
+     max_off = LineOffset[row] + screen_Columns;
Karsten Hopp f51e78
+ #endif
Karsten Hopp f51e78
      while (col < screen_Columns
Karsten Hopp f51e78
  	    && (len < 0 || (int)(ptr - text) < len)
Karsten Hopp f51e78
  	    && *ptr != NUL)
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 6326,6344 ****
Karsten Hopp f51e78
  	    else if (has_mbyte
Karsten Hopp f51e78
  		    && (len < 0 ? ptr[mbyte_blen] == NUL
Karsten Hopp f51e78
  					     : ptr + mbyte_blen >= text + len)
Karsten Hopp f51e78
! 		    && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
Karsten Hopp f51e78
  			|| (mbyte_cells == 2
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off) == 1
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off + 1) > 1)))
Karsten Hopp f51e78
  		clear_next_cell = TRUE;
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  	    /* Make sure we never leave a second byte of a double-byte behind,
Karsten Hopp f51e78
  	     * it confuses mb_off2cells(). */
Karsten Hopp f51e78
  	    if (enc_dbcs
Karsten Hopp f51e78
! 		    && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
Karsten Hopp f51e78
  			|| (mbyte_cells == 2
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off) == 1
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off + 1) > 1)))
Karsten Hopp f51e78
  		ScreenLines[off + mbyte_blen] = 0;
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
  	    ScreenLines[off] = c;
Karsten Hopp f51e78
--- 6343,6361 ----
Karsten Hopp f51e78
  	    else if (has_mbyte
Karsten Hopp f51e78
  		    && (len < 0 ? ptr[mbyte_blen] == NUL
Karsten Hopp f51e78
  					     : ptr + mbyte_blen >= text + len)
Karsten Hopp f51e78
! 		    && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1)
Karsten Hopp f51e78
  			|| (mbyte_cells == 2
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off, max_off) == 1
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off + 1, max_off) > 1)))
Karsten Hopp f51e78
  		clear_next_cell = TRUE;
Karsten Hopp f51e78
  
Karsten Hopp f51e78
  	    /* Make sure we never leave a second byte of a double-byte behind,
Karsten Hopp f51e78
  	     * it confuses mb_off2cells(). */
Karsten Hopp f51e78
  	    if (enc_dbcs
Karsten Hopp f51e78
! 		    && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1)
Karsten Hopp f51e78
  			|| (mbyte_cells == 2
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off, max_off) == 1
Karsten Hopp f51e78
! 			    && (*mb_off2cells)(off + 1, max_off) > 1)))
Karsten Hopp f51e78
  		ScreenLines[off + mbyte_blen] = 0;
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
  	    ScreenLines[off] = c;
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 6924,6929 ****
Karsten Hopp f51e78
--- 6941,6949 ----
Karsten Hopp f51e78
  {
Karsten Hopp f51e78
      int		r, c;
Karsten Hopp f51e78
      int		off;
Karsten Hopp f51e78
+ #ifdef FEAT_MBYTE
Karsten Hopp f51e78
+     int		max_off;
Karsten Hopp f51e78
+ #endif
Karsten Hopp f51e78
  
Karsten Hopp f51e78
      /* Can't use ScreenLines unless initialized */
Karsten Hopp f51e78
      if (ScreenLines == NULL)
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 6934,6943 ****
Karsten Hopp f51e78
      for (r = row; r < row + height; ++r)
Karsten Hopp f51e78
      {
Karsten Hopp f51e78
  	off = LineOffset[r];
Karsten Hopp f51e78
  	for (c = col; c < col + width; ++c)
Karsten Hopp f51e78
  	{
Karsten Hopp f51e78
  #ifdef FEAT_MBYTE
Karsten Hopp f51e78
! 	    if (enc_dbcs != 0 && dbcs_off2cells(off + c) > 1)
Karsten Hopp f51e78
  	    {
Karsten Hopp f51e78
  		screen_char_2(off + c, r, c);
Karsten Hopp f51e78
  		++c;
Karsten Hopp f51e78
--- 6954,6966 ----
Karsten Hopp f51e78
      for (r = row; r < row + height; ++r)
Karsten Hopp f51e78
      {
Karsten Hopp f51e78
  	off = LineOffset[r];
Karsten Hopp f51e78
+ #ifdef FEAT_MBYTE
Karsten Hopp f51e78
+ 	max_off = off + screen_Columns;
Karsten Hopp f51e78
+ #endif
Karsten Hopp f51e78
  	for (c = col; c < col + width; ++c)
Karsten Hopp f51e78
  	{
Karsten Hopp f51e78
  #ifdef FEAT_MBYTE
Karsten Hopp f51e78
! 	    if (enc_dbcs != 0 && dbcs_off2cells(off + c, max_off) > 1)
Karsten Hopp f51e78
  	    {
Karsten Hopp f51e78
  		screen_char_2(off + c, r, c);
Karsten Hopp f51e78
  		++c;
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 6947,6953 ****
Karsten Hopp f51e78
  	    {
Karsten Hopp f51e78
  		screen_char(off + c, r, c);
Karsten Hopp f51e78
  #ifdef FEAT_MBYTE
Karsten Hopp f51e78
! 		if (utf_off2cells(off + c) > 1)
Karsten Hopp f51e78
  		    ++c;
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
  	    }
Karsten Hopp f51e78
--- 6970,6976 ----
Karsten Hopp f51e78
  	    {
Karsten Hopp f51e78
  		screen_char(off + c, r, c);
Karsten Hopp f51e78
  #ifdef FEAT_MBYTE
Karsten Hopp f51e78
! 		if (utf_off2cells(off + c, max_off) > 1)
Karsten Hopp f51e78
  		    ++c;
Karsten Hopp f51e78
  #endif
Karsten Hopp f51e78
  	    }
Karsten Hopp f51e78
*** ../vim-7.1.092/src/version.c	Thu Aug 30 12:50:00 2007
Karsten Hopp f51e78
--- src/version.c	Thu Aug 30 13:45:25 2007
Karsten Hopp f51e78
***************
Karsten Hopp f51e78
*** 668,669 ****
Karsten Hopp f51e78
--- 668,671 ----
Karsten Hopp f51e78
  {   /* Add new patch number below this line */
Karsten Hopp f51e78
+ /**/
Karsten Hopp f51e78
+     93,
Karsten Hopp f51e78
  /**/
Karsten Hopp f51e78
Karsten Hopp f51e78
-- 
Karsten Hopp f51e78
There is a fine line between courage and foolishness.
Karsten Hopp f51e78
Unfortunately, it's not a fence.
Karsten Hopp f51e78
Karsten Hopp f51e78
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp f51e78
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp f51e78
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp f51e78
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///