Karsten Hopp 135b3d
To: vim-dev@vim.org
Karsten Hopp 135b3d
Subject: Patch 7.1.258
Karsten Hopp 135b3d
Fcc: outbox
Karsten Hopp 135b3d
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 135b3d
Mime-Version: 1.0
Karsten Hopp 135b3d
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 135b3d
Content-Transfer-Encoding: 8bit
Karsten Hopp 135b3d
------------
Karsten Hopp 135b3d
Karsten Hopp 135b3d
Patch 7.1.258
Karsten Hopp 135b3d
Problem:    Crash when doing "d/\n/e" and 'virtualedit' is "all". (Andy Wokula)
Karsten Hopp 135b3d
Solution:   Avoid that the column becomes negative.  Also fixes other problems
Karsten Hopp 135b3d
	    with the end of a pattern match is in column zero. (A.Politz)
Karsten Hopp 135b3d
Files:	    src/search.c
Karsten Hopp 135b3d
Karsten Hopp 135b3d
Karsten Hopp 135b3d
*** ../vim-7.1.257/src/search.c	Sat Jan 26 21:15:00 2008
Karsten Hopp 135b3d
--- src/search.c	Wed Feb 20 13:22:23 2008
Karsten Hopp 135b3d
***************
Karsten Hopp 135b3d
*** 624,630 ****
Karsten Hopp 135b3d
  #ifdef FEAT_EVAL
Karsten Hopp 135b3d
  		    submatch = first_submatch(&regmatch);
Karsten Hopp 135b3d
  #endif
Karsten Hopp 135b3d
! 		    /* Line me be past end of buffer for "\n\zs". */
Karsten Hopp 135b3d
  		    if (lnum + matchpos.lnum > buf->b_ml.ml_line_count)
Karsten Hopp 135b3d
  			ptr = (char_u *)"";
Karsten Hopp 135b3d
  		    else
Karsten Hopp 135b3d
--- 624,630 ----
Karsten Hopp 135b3d
  #ifdef FEAT_EVAL
Karsten Hopp 135b3d
  		    submatch = first_submatch(&regmatch);
Karsten Hopp 135b3d
  #endif
Karsten Hopp 135b3d
! 		    /* "lnum" may be past end of buffer for "\n\zs". */
Karsten Hopp 135b3d
  		    if (lnum + matchpos.lnum > buf->b_ml.ml_line_count)
Karsten Hopp 135b3d
  			ptr = (char_u *)"";
Karsten Hopp 135b3d
  		    else
Karsten Hopp 135b3d
***************
Karsten Hopp 135b3d
*** 833,853 ****
Karsten Hopp 135b3d
  			    continue;
Karsten Hopp 135b3d
  		    }
Karsten Hopp 135b3d
  
Karsten Hopp 135b3d
! 		    if (options & SEARCH_END && !(options & SEARCH_NOOF))
Karsten Hopp 135b3d
  		    {
Karsten Hopp 135b3d
  			pos->lnum = lnum + endpos.lnum;
Karsten Hopp 135b3d
! 			pos->col = endpos.col - 1;
Karsten Hopp 135b3d
! #ifdef FEAT_MBYTE
Karsten Hopp 135b3d
! 			if (has_mbyte)
Karsten Hopp 135b3d
  			{
Karsten Hopp 135b3d
! 			    /* 'e' offset may put us just below the last line */
Karsten Hopp 135b3d
! 			    if (pos->lnum > buf->b_ml.ml_line_count)
Karsten Hopp 135b3d
! 				ptr = (char_u *)"";
Karsten Hopp 135b3d
! 			    else
Karsten Hopp 135b3d
! 				ptr = ml_get_buf(buf, pos->lnum, FALSE);
Karsten Hopp 135b3d
! 			    pos->col -= (*mb_head_off)(ptr, ptr + pos->col);
Karsten Hopp 135b3d
  			}
Karsten Hopp 135b3d
  #endif
Karsten Hopp 135b3d
  		    }
Karsten Hopp 135b3d
  		    else
Karsten Hopp 135b3d
  		    {
Karsten Hopp 135b3d
--- 833,870 ----
Karsten Hopp 135b3d
  			    continue;
Karsten Hopp 135b3d
  		    }
Karsten Hopp 135b3d
  
Karsten Hopp 135b3d
! 		    /* With the SEARCH_END option move to the last character
Karsten Hopp 135b3d
! 		     * of the match.  Don't do it for an empty match, end
Karsten Hopp 135b3d
! 		     * should be same as start then. */
Karsten Hopp 135b3d
! 		    if (options & SEARCH_END && !(options & SEARCH_NOOF)
Karsten Hopp 135b3d
! 			    && !(matchpos.lnum == endpos.lnum
Karsten Hopp 135b3d
! 				&& matchpos.col == endpos.col))
Karsten Hopp 135b3d
  		    {
Karsten Hopp 135b3d
+ 			/* For a match in the first column, set the position
Karsten Hopp 135b3d
+ 			 * on the NUL in the previous line. */
Karsten Hopp 135b3d
  			pos->lnum = lnum + endpos.lnum;
Karsten Hopp 135b3d
! 			pos->col = endpos.col;
Karsten Hopp 135b3d
! 			if (endpos.col == 0)
Karsten Hopp 135b3d
  			{
Karsten Hopp 135b3d
! 			    if (pos->lnum > 1)  /* just in case */
Karsten Hopp 135b3d
! 			    {
Karsten Hopp 135b3d
! 				--pos->lnum;
Karsten Hopp 135b3d
! 				pos->col = (colnr_T)STRLEN(ml_get_buf(buf,
Karsten Hopp 135b3d
! 							   pos->lnum, FALSE));
Karsten Hopp 135b3d
! 			    }
Karsten Hopp 135b3d
  			}
Karsten Hopp 135b3d
+ 			else
Karsten Hopp 135b3d
+ 			{
Karsten Hopp 135b3d
+ 			    --pos->col;
Karsten Hopp 135b3d
+ #ifdef FEAT_MBYTE
Karsten Hopp 135b3d
+ 			    if (has_mbyte
Karsten Hopp 135b3d
+ 				    && pos->lnum <= buf->b_ml.ml_line_count)
Karsten Hopp 135b3d
+ 			    {
Karsten Hopp 135b3d
+ 				ptr = ml_get_buf(buf, pos->lnum, FALSE);
Karsten Hopp 135b3d
+ 				pos->col -= (*mb_head_off)(ptr, ptr + pos->col);
Karsten Hopp 135b3d
+ 			    }
Karsten Hopp 135b3d
  #endif
Karsten Hopp 135b3d
+ 			}
Karsten Hopp 135b3d
  		    }
Karsten Hopp 135b3d
  		    else
Karsten Hopp 135b3d
  		    {
Karsten Hopp 135b3d
*** ../vim-7.1.257/src/version.c	Wed Feb 20 12:43:05 2008
Karsten Hopp 135b3d
--- src/version.c	Wed Feb 20 13:37:32 2008
Karsten Hopp 135b3d
***************
Karsten Hopp 135b3d
*** 668,669 ****
Karsten Hopp 135b3d
--- 668,671 ----
Karsten Hopp 135b3d
  {   /* Add new patch number below this line */
Karsten Hopp 135b3d
+ /**/
Karsten Hopp 135b3d
+     258,
Karsten Hopp 135b3d
  /**/
Karsten Hopp 135b3d
Karsten Hopp 135b3d
-- 
Karsten Hopp 135b3d
Micro$oft: where do you want to go today?
Karsten Hopp 135b3d
    Linux: where do you want to go tomorrow?
Karsten Hopp 135b3d
  FreeBSD: are you guys coming, or what?
Karsten Hopp 135b3d
Karsten Hopp 135b3d
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 135b3d
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 135b3d
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 135b3d
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///