Karsten Hopp 1cd335
To: vim_dev@googlegroups.com
Karsten Hopp 1cd335
Subject: Patch 7.4.551
Karsten Hopp 1cd335
Fcc: outbox
Karsten Hopp 1cd335
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 1cd335
Mime-Version: 1.0
Karsten Hopp 1cd335
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 1cd335
Content-Transfer-Encoding: 8bit
Karsten Hopp 1cd335
------------
Karsten Hopp 1cd335
Karsten Hopp 1cd335
Patch 7.4.551
Karsten Hopp 1cd335
Problem:    "ygn" may yank too much. (Fritzophrenic)  Issue 295.
Karsten Hopp 1cd335
Solution:   Check the width of the next match. (Christian Brabandt)
Karsten Hopp 1cd335
Files:      src/search.c, src/testdir/test53.in, src/testdir/test53.ok
Karsten Hopp 1cd335
Karsten Hopp 1cd335
Karsten Hopp 1cd335
*** ../vim-7.4.550/src/search.c	2014-12-13 20:11:29.582422289 +0100
Karsten Hopp 1cd335
--- src/search.c	2014-12-13 21:55:26.608363239 +0100
Karsten Hopp 1cd335
***************
Karsten Hopp 1cd335
*** 4441,4452 ****
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
  #endif /* FEAT_TEXTOBJ */
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
! static int is_one_char __ARGS((char_u *pattern));
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
  /*
Karsten Hopp 1cd335
   * Find next search match under cursor, cursor at end.
Karsten Hopp 1cd335
   * Used while an operator is pending, and in Visual mode.
Karsten Hopp 1cd335
-  * TODO: redo only works when used in operator pending mode
Karsten Hopp 1cd335
   */
Karsten Hopp 1cd335
      int
Karsten Hopp 1cd335
  current_search(count, forward)
Karsten Hopp 1cd335
--- 4441,4451 ----
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
  #endif /* FEAT_TEXTOBJ */
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
! static int is_one_char __ARGS((char_u *pattern, int move));
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
  /*
Karsten Hopp 1cd335
   * Find next search match under cursor, cursor at end.
Karsten Hopp 1cd335
   * Used while an operator is pending, and in Visual mode.
Karsten Hopp 1cd335
   */
Karsten Hopp 1cd335
      int
Karsten Hopp 1cd335
  current_search(count, forward)
Karsten Hopp 1cd335
***************
Karsten Hopp 1cd335
*** 4491,4497 ****
Karsten Hopp 1cd335
  	orig_pos = pos = start_pos = curwin->w_cursor;
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
      /* Is the pattern is zero-width? */
Karsten Hopp 1cd335
!     one_char = is_one_char(spats[last_idx].pat);
Karsten Hopp 1cd335
      if (one_char == -1)
Karsten Hopp 1cd335
      {
Karsten Hopp 1cd335
  	p_ws = old_p_ws;
Karsten Hopp 1cd335
--- 4490,4496 ----
Karsten Hopp 1cd335
  	orig_pos = pos = start_pos = curwin->w_cursor;
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
      /* Is the pattern is zero-width? */
Karsten Hopp 1cd335
!     one_char = is_one_char(spats[last_idx].pat, TRUE);
Karsten Hopp 1cd335
      if (one_char == -1)
Karsten Hopp 1cd335
      {
Karsten Hopp 1cd335
  	p_ws = old_p_ws;
Karsten Hopp 1cd335
***************
Karsten Hopp 1cd335
*** 4550,4555 ****
Karsten Hopp 1cd335
--- 4549,4558 ----
Karsten Hopp 1cd335
      start_pos = pos;
Karsten Hopp 1cd335
      flags = forward ? SEARCH_END : 0;
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
+     /* Check again from the current cursor position,
Karsten Hopp 1cd335
+      * since the next match might actually by only one char wide */
Karsten Hopp 1cd335
+     one_char = is_one_char(spats[last_idx].pat, FALSE);
Karsten Hopp 1cd335
+ 
Karsten Hopp 1cd335
      /* move to match, except for zero-width matches, in which case, we are
Karsten Hopp 1cd335
       * already on the next match */
Karsten Hopp 1cd335
      if (!one_char)
Karsten Hopp 1cd335
***************
Karsten Hopp 1cd335
*** 4599,4624 ****
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
  /*
Karsten Hopp 1cd335
   * Check if the pattern is one character or zero-width.
Karsten Hopp 1cd335
   * Returns TRUE, FALSE or -1 for failure.
Karsten Hopp 1cd335
   */
Karsten Hopp 1cd335
      static int
Karsten Hopp 1cd335
! is_one_char(pattern)
Karsten Hopp 1cd335
      char_u	*pattern;
Karsten Hopp 1cd335
  {
Karsten Hopp 1cd335
      regmmatch_T	regmatch;
Karsten Hopp 1cd335
      int		nmatched = 0;
Karsten Hopp 1cd335
      int		result = -1;
Karsten Hopp 1cd335
      pos_T	pos;
Karsten Hopp 1cd335
      int		save_called_emsg = called_emsg;
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
      if (search_regcomp(pattern, RE_SEARCH, RE_SEARCH,
Karsten Hopp 1cd335
  					      SEARCH_KEEP, &regmatch) == FAIL)
Karsten Hopp 1cd335
  	return -1;
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
      /* move to match */
Karsten Hopp 1cd335
!     clearpos(&pos;;
Karsten Hopp 1cd335
      if (searchit(curwin, curbuf, &pos, FORWARD, spats[last_idx].pat, 1,
Karsten Hopp 1cd335
! 				     SEARCH_KEEP, RE_SEARCH, 0, NULL) != FAIL)
Karsten Hopp 1cd335
      {
Karsten Hopp 1cd335
  	/* Zero-width pattern should match somewhere, then we can check if
Karsten Hopp 1cd335
  	 * start and end are in the same position. */
Karsten Hopp 1cd335
--- 4602,4639 ----
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
  /*
Karsten Hopp 1cd335
   * Check if the pattern is one character or zero-width.
Karsten Hopp 1cd335
+  * If move is TRUE, check from the beginning of the buffer, else from the
Karsten Hopp 1cd335
+  * current cursor position.
Karsten Hopp 1cd335
   * Returns TRUE, FALSE or -1 for failure.
Karsten Hopp 1cd335
   */
Karsten Hopp 1cd335
      static int
Karsten Hopp 1cd335
! is_one_char(pattern, move)
Karsten Hopp 1cd335
      char_u	*pattern;
Karsten Hopp 1cd335
+     int		move;
Karsten Hopp 1cd335
  {
Karsten Hopp 1cd335
      regmmatch_T	regmatch;
Karsten Hopp 1cd335
      int		nmatched = 0;
Karsten Hopp 1cd335
      int		result = -1;
Karsten Hopp 1cd335
      pos_T	pos;
Karsten Hopp 1cd335
      int		save_called_emsg = called_emsg;
Karsten Hopp 1cd335
+     int		flag = 0;
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
      if (search_regcomp(pattern, RE_SEARCH, RE_SEARCH,
Karsten Hopp 1cd335
  					      SEARCH_KEEP, &regmatch) == FAIL)
Karsten Hopp 1cd335
  	return -1;
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
      /* move to match */
Karsten Hopp 1cd335
!     if (move)
Karsten Hopp 1cd335
! 	clearpos(&pos)
Karsten Hopp 1cd335
!     else
Karsten Hopp 1cd335
!     {
Karsten Hopp 1cd335
! 	pos = curwin->w_cursor;
Karsten Hopp 1cd335
! 	/* accept a match at the cursor position */
Karsten Hopp 1cd335
! 	flag = SEARCH_START;
Karsten Hopp 1cd335
!     }
Karsten Hopp 1cd335
! 
Karsten Hopp 1cd335
      if (searchit(curwin, curbuf, &pos, FORWARD, spats[last_idx].pat, 1,
Karsten Hopp 1cd335
! 			      SEARCH_KEEP + flag, RE_SEARCH, 0, NULL) != FAIL)
Karsten Hopp 1cd335
      {
Karsten Hopp 1cd335
  	/* Zero-width pattern should match somewhere, then we can check if
Karsten Hopp 1cd335
  	 * start and end are in the same position. */
Karsten Hopp 1cd335
*** ../vim-7.4.550/src/testdir/test53.in	2014-02-22 22:18:39.536905522 +0100
Karsten Hopp 1cd335
--- src/testdir/test53.in	2014-12-13 21:52:43.314091440 +0100
Karsten Hopp 1cd335
***************
Karsten Hopp 1cd335
*** 79,84 ****
Karsten Hopp 1cd335
--- 79,86 ----
Karsten Hopp 1cd335
  :" test repeating gUgn
Karsten Hopp 1cd335
  /^Depp
Karsten Hopp 1cd335
  gggUgn.
Karsten Hopp 1cd335
+ gg/a:0\@!\zs\d\+
Karsten Hopp 1cd335
+ nygno?p
Karsten Hopp 1cd335
  :/^start:/,/^end:/wq! test.out
Karsten Hopp 1cd335
  ENDTEST
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
***************
Karsten Hopp 1cd335
*** 108,113 ****
Karsten Hopp 1cd335
--- 110,120 ----
Karsten Hopp 1cd335
  uniquepattern uniquepattern
Karsten Hopp 1cd335
  my very excellent mother just served us nachos
Karsten Hopp 1cd335
  for (i=0; i<=10; i++)
Karsten Hopp 1cd335
+ a:10
Karsten Hopp 1cd335
+ 
Karsten Hopp 1cd335
+ a:1
Karsten Hopp 1cd335
+ 
Karsten Hopp 1cd335
+ a:20
Karsten Hopp 1cd335
  Y
Karsten Hopp 1cd335
  text
Karsten Hopp 1cd335
  Y
Karsten Hopp 1cd335
*** ../vim-7.4.550/src/testdir/test53.ok	2014-02-22 22:18:39.536905522 +0100
Karsten Hopp 1cd335
--- src/testdir/test53.ok	2014-12-13 21:52:43.314091440 +0100
Karsten Hopp 1cd335
***************
Karsten Hopp 1cd335
*** 49,54 ****
Karsten Hopp 1cd335
--- 49,60 ----
Karsten Hopp 1cd335
   uniquepattern
Karsten Hopp 1cd335
  my very excellent mongoose just served us nachos
Karsten Hopp 1cd335
  for (j=0; i<=10; i++)
Karsten Hopp 1cd335
+ a:10
Karsten Hopp 1cd335
+ 
Karsten Hopp 1cd335
+ a:1
Karsten Hopp 1cd335
+ 1
Karsten Hopp 1cd335
+ 
Karsten Hopp 1cd335
+ a:20
Karsten Hopp 1cd335
  
Karsten Hopp 1cd335
  text
Karsten Hopp 1cd335
  Y
Karsten Hopp 1cd335
*** ../vim-7.4.550/src/version.c	2014-12-13 21:09:53.721226911 +0100
Karsten Hopp 1cd335
--- src/version.c	2014-12-13 21:52:20.346334198 +0100
Karsten Hopp 1cd335
***************
Karsten Hopp 1cd335
*** 743,744 ****
Karsten Hopp 1cd335
--- 743,746 ----
Karsten Hopp 1cd335
  {   /* Add new patch number below this line */
Karsten Hopp 1cd335
+ /**/
Karsten Hopp 1cd335
+     551,
Karsten Hopp 1cd335
  /**/
Karsten Hopp 1cd335
Karsten Hopp 1cd335
-- 
Karsten Hopp 1cd335
While it's true that many normal people whould prefer not to _date_ an
Karsten Hopp 1cd335
engineer, most normal people harbor an intense desire to _mate_ with them,
Karsten Hopp 1cd335
thus producing engineerlike children who will have high-paying jobs long
Karsten Hopp 1cd335
before losing their virginity.
Karsten Hopp 1cd335
				(Scott Adams - The Dilbert principle)
Karsten Hopp 1cd335
Karsten Hopp 1cd335
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 1cd335
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 1cd335
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 1cd335
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///