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