Karsten Hopp f83e59
To: vim_dev@googlegroups.com
Karsten Hopp f83e59
Subject: Patch 7.3.1275
Karsten Hopp f83e59
Fcc: outbox
Karsten Hopp f83e59
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp f83e59
Mime-Version: 1.0
Karsten Hopp f83e59
Content-Type: text/plain; charset=UTF-8
Karsten Hopp f83e59
Content-Transfer-Encoding: 8bit
Karsten Hopp f83e59
------------
Karsten Hopp f83e59
Karsten Hopp f83e59
Patch 7.3.1275
Karsten Hopp f83e59
Problem:    "gn" does not work when the match is a single character.
Karsten Hopp f83e59
Solution:   Fix it, add a test. (Christian Brabandt)
Karsten Hopp f83e59
Files:	    src/search.c, src/testdir/test53.in, src/testdir/test53.ok
Karsten Hopp f83e59
Karsten Hopp f83e59
Karsten Hopp f83e59
*** ../vim-7.3.1274/src/search.c	2013-06-08 18:19:40.000000000 +0200
Karsten Hopp f83e59
--- src/search.c	2013-06-30 14:41:48.000000000 +0200
Karsten Hopp f83e59
***************
Karsten Hopp f83e59
*** 4489,4495 ****
Karsten Hopp f83e59
  #endif /* FEAT_TEXTOBJ */
Karsten Hopp f83e59
  
Karsten Hopp f83e59
  #if defined(FEAT_VISUAL) || defined(PROTO)
Karsten Hopp f83e59
! static int is_zerowidth __ARGS((char_u *pattern));
Karsten Hopp f83e59
  
Karsten Hopp f83e59
  /*
Karsten Hopp f83e59
   * Find next search match under cursor, cursor at end.
Karsten Hopp f83e59
--- 4489,4495 ----
Karsten Hopp f83e59
  #endif /* FEAT_TEXTOBJ */
Karsten Hopp f83e59
  
Karsten Hopp f83e59
  #if defined(FEAT_VISUAL) || defined(PROTO)
Karsten Hopp f83e59
! static int is_one_char __ARGS((char_u *pattern));
Karsten Hopp f83e59
  
Karsten Hopp f83e59
  /*
Karsten Hopp f83e59
   * Find next search match under cursor, cursor at end.
Karsten Hopp f83e59
***************
Karsten Hopp f83e59
*** 4510,4516 ****
Karsten Hopp f83e59
      char_u	old_p_ws = p_ws;
Karsten Hopp f83e59
      int		flags = 0;
Karsten Hopp f83e59
      pos_T	save_VIsual;
Karsten Hopp f83e59
!     int		zerowidth = FALSE;
Karsten Hopp f83e59
  
Karsten Hopp f83e59
      /* wrapping should not occur */
Karsten Hopp f83e59
      p_ws = FALSE;
Karsten Hopp f83e59
--- 4510,4516 ----
Karsten Hopp f83e59
      char_u	old_p_ws = p_ws;
Karsten Hopp f83e59
      int		flags = 0;
Karsten Hopp f83e59
      pos_T	save_VIsual;
Karsten Hopp f83e59
!     int		one_char;
Karsten Hopp f83e59
  
Karsten Hopp f83e59
      /* wrapping should not occur */
Karsten Hopp f83e59
      p_ws = FALSE;
Karsten Hopp f83e59
***************
Karsten Hopp f83e59
*** 4540,4548 ****
Karsten Hopp f83e59
  	orig_pos = pos = start_pos = curwin->w_cursor;
Karsten Hopp f83e59
  
Karsten Hopp f83e59
      /* Is the pattern is zero-width? */
Karsten Hopp f83e59
!     zerowidth = is_zerowidth(spats[last_idx].pat);
Karsten Hopp f83e59
!     if (zerowidth == -1)
Karsten Hopp f83e59
! 	return FAIL;
Karsten Hopp f83e59
  
Karsten Hopp f83e59
      /*
Karsten Hopp f83e59
       * The trick is to first search backwards and then search forward again,
Karsten Hopp f83e59
--- 4540,4548 ----
Karsten Hopp f83e59
  	orig_pos = pos = start_pos = curwin->w_cursor;
Karsten Hopp f83e59
  
Karsten Hopp f83e59
      /* Is the pattern is zero-width? */
Karsten Hopp f83e59
!     one_char = is_one_char(spats[last_idx].pat);
Karsten Hopp f83e59
!     if (one_char == -1)
Karsten Hopp f83e59
! 	return FAIL;  /* invalid pattern */
Karsten Hopp f83e59
  
Karsten Hopp f83e59
      /*
Karsten Hopp f83e59
       * The trick is to first search backwards and then search forward again,
Karsten Hopp f83e59
***************
Karsten Hopp f83e59
*** 4557,4563 ****
Karsten Hopp f83e59
  	    dir = !i;
Karsten Hopp f83e59
  
Karsten Hopp f83e59
  	flags = 0;
Karsten Hopp f83e59
! 	if (!dir && !zerowidth)
Karsten Hopp f83e59
  	    flags = SEARCH_END;
Karsten Hopp f83e59
  
Karsten Hopp f83e59
  	result = searchit(curwin, curbuf, &pos, (dir ? FORWARD : BACKWARD),
Karsten Hopp f83e59
--- 4557,4563 ----
Karsten Hopp f83e59
  	    dir = !i;
Karsten Hopp f83e59
  
Karsten Hopp f83e59
  	flags = 0;
Karsten Hopp f83e59
! 	if (!dir && !one_char)
Karsten Hopp f83e59
  	    flags = SEARCH_END;
Karsten Hopp f83e59
  
Karsten Hopp f83e59
  	result = searchit(curwin, curbuf, &pos, (dir ? FORWARD : BACKWARD),
Karsten Hopp f83e59
***************
Karsten Hopp f83e59
*** 4598,4604 ****
Karsten Hopp f83e59
  
Karsten Hopp f83e59
      /* move to match, except for zero-width matches, in which case, we are
Karsten Hopp f83e59
       * already on the next match */
Karsten Hopp f83e59
!     if (!zerowidth)
Karsten Hopp f83e59
  	result = searchit(curwin, curbuf, &pos, (forward ? FORWARD : BACKWARD),
Karsten Hopp f83e59
  	    spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0, NULL);
Karsten Hopp f83e59
  
Karsten Hopp f83e59
--- 4598,4604 ----
Karsten Hopp f83e59
  
Karsten Hopp f83e59
      /* move to match, except for zero-width matches, in which case, we are
Karsten Hopp f83e59
       * already on the next match */
Karsten Hopp f83e59
!     if (!one_char)
Karsten Hopp f83e59
  	result = searchit(curwin, curbuf, &pos, (forward ? FORWARD : BACKWARD),
Karsten Hopp f83e59
  	    spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0, NULL);
Karsten Hopp f83e59
  
Karsten Hopp f83e59
***************
Karsten Hopp f83e59
*** 4645,4655 ****
Karsten Hopp f83e59
  }
Karsten Hopp f83e59
  
Karsten Hopp f83e59
  /*
Karsten Hopp f83e59
!  * Check if the pattern is zero-width.
Karsten Hopp f83e59
   * Returns TRUE, FALSE or -1 for failure.
Karsten Hopp f83e59
   */
Karsten Hopp f83e59
      static int
Karsten Hopp f83e59
! is_zerowidth(pattern)
Karsten Hopp f83e59
      char_u	*pattern;
Karsten Hopp f83e59
  {
Karsten Hopp f83e59
      regmmatch_T	regmatch;
Karsten Hopp f83e59
--- 4645,4655 ----
Karsten Hopp f83e59
  }
Karsten Hopp f83e59
  
Karsten Hopp f83e59
  /*
Karsten Hopp f83e59
!  * Check if the pattern is one character or zero-width.
Karsten Hopp f83e59
   * Returns TRUE, FALSE or -1 for failure.
Karsten Hopp f83e59
   */
Karsten Hopp f83e59
      static int
Karsten Hopp f83e59
! is_one_char(pattern)
Karsten Hopp f83e59
      char_u	*pattern;
Karsten Hopp f83e59
  {
Karsten Hopp f83e59
      regmmatch_T	regmatch;
Karsten Hopp f83e59
***************
Karsten Hopp f83e59
*** 4677,4682 ****
Karsten Hopp f83e59
--- 4677,4685 ----
Karsten Hopp f83e59
  	    result = (nmatched != 0
Karsten Hopp f83e59
  		&& regmatch.startpos[0].lnum == regmatch.endpos[0].lnum
Karsten Hopp f83e59
  		&& regmatch.startpos[0].col == regmatch.endpos[0].col);
Karsten Hopp f83e59
+ 
Karsten Hopp f83e59
+ 	if (!result && incl(&pos) == 0 && pos.col == regmatch.endpos[0].col)
Karsten Hopp f83e59
+ 	    result  = TRUE;
Karsten Hopp f83e59
      }
Karsten Hopp f83e59
  
Karsten Hopp f83e59
      called_emsg |= save_called_emsg;
Karsten Hopp f83e59
*** ../vim-7.3.1274/src/testdir/test53.in	2012-10-11 03:35:38.000000000 +0200
Karsten Hopp f83e59
--- src/testdir/test53.in	2013-06-30 14:31:56.000000000 +0200
Karsten Hopp f83e59
***************
Karsten Hopp f83e59
*** 44,50 ****
Karsten Hopp f83e59
  vlgnd
Karsten Hopp f83e59
  /mother
Karsten Hopp f83e59
  :set selection=exclusive
Karsten Hopp f83e59
! $cgNmongoose?
Karsten Hopp f83e59
  :/^start:/,/^end:/wq! test.out
Karsten Hopp f83e59
  ENDTEST
Karsten Hopp f83e59
  
Karsten Hopp f83e59
--- 44,51 ----
Karsten Hopp f83e59
  vlgnd
Karsten Hopp f83e59
  /mother
Karsten Hopp f83e59
  :set selection=exclusive
Karsten Hopp f83e59
! $cgNmongoose?/i
Karsten Hopp f83e59
! cgnj?
Karsten Hopp f83e59
  :/^start:/,/^end:/wq! test.out
Karsten Hopp f83e59
  ENDTEST
Karsten Hopp f83e59
  
Karsten Hopp f83e59
***************
Karsten Hopp f83e59
*** 73,76 ****
Karsten Hopp f83e59
--- 74,78 ----
Karsten Hopp f83e59
  delete first and last chars
Karsten Hopp f83e59
  uniquepattern uniquepattern
Karsten Hopp f83e59
  my very excellent mother just served us nachos
Karsten Hopp f83e59
+ for (i=0; i<=10; i++)
Karsten Hopp f83e59
  end:
Karsten Hopp f83e59
*** ../vim-7.3.1274/src/testdir/test53.ok	2012-10-11 03:35:38.000000000 +0200
Karsten Hopp f83e59
--- src/testdir/test53.ok	2013-06-30 14:31:56.000000000 +0200
Karsten Hopp f83e59
***************
Karsten Hopp f83e59
*** 26,29 ****
Karsten Hopp f83e59
--- 26,30 ----
Karsten Hopp f83e59
  elete first and last char
Karsten Hopp f83e59
   uniquepattern
Karsten Hopp f83e59
  my very excellent mongoose just served us nachos
Karsten Hopp f83e59
+ for (j=0; i<=10; i++)
Karsten Hopp f83e59
  end:
Karsten Hopp f83e59
*** ../vim-7.3.1274/src/version.c	2013-06-30 13:57:40.000000000 +0200
Karsten Hopp f83e59
--- src/version.c	2013-06-30 14:31:32.000000000 +0200
Karsten Hopp f83e59
***************
Karsten Hopp f83e59
*** 730,731 ****
Karsten Hopp f83e59
--- 730,733 ----
Karsten Hopp f83e59
  {   /* Add new patch number below this line */
Karsten Hopp f83e59
+ /**/
Karsten Hopp f83e59
+     1275,
Karsten Hopp f83e59
  /**/
Karsten Hopp f83e59
Karsten Hopp f83e59
-- 
Karsten Hopp f83e59
There are 2 kinds of people in my world: those who know Unix, Perl, Vim, GNU,
Karsten Hopp f83e59
Linux, etc, and those who know COBOL.  It gets very difficult for me at
Karsten Hopp f83e59
parties, not knowing which group to socialise with :-)
Karsten Hopp f83e59
						Sitaram Chamarty
Karsten Hopp f83e59
Karsten Hopp f83e59
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp f83e59
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp f83e59
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp f83e59
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///