astepano / rpms / vim

Forked from rpms/vim 6 years ago
Clone
7819ea7
To: vim_dev@googlegroups.com
7819ea7
Subject: Patch 7.4.184
7819ea7
Fcc: outbox
7819ea7
From: Bram Moolenaar <Bram@moolenaar.net>
7819ea7
Mime-Version: 1.0
7819ea7
Content-Type: text/plain; charset=UTF-8
7819ea7
Content-Transfer-Encoding: 8bit
7819ea7
------------
7819ea7
7819ea7
Patch 7.4.184
7819ea7
Problem:    match() does not work properly with a {count} argument.
7819ea7
Solution:   Compute the length once and update it.  Quit the loop when at the
7819ea7
            end. (Hirohito Higashi)
7819ea7
Files:      src/eval.c, src/testdir/test53.in, src/testdir/test53.ok
7819ea7
7819ea7
7819ea7
*** ../vim-7.4.183/src/eval.c	2014-02-05 22:13:02.366556787 +0100
7819ea7
--- src/eval.c	2014-02-22 22:13:26.644906020 +0100
7819ea7
***************
7819ea7
*** 8014,8020 ****
7819ea7
      {"log10",		1, 1, f_log10},
7819ea7
  #endif
7819ea7
  #ifdef FEAT_LUA
7819ea7
!     {"luaeval",         1, 2, f_luaeval},
7819ea7
  #endif
7819ea7
      {"map",		2, 2, f_map},
7819ea7
      {"maparg",		1, 4, f_maparg},
7819ea7
--- 8014,8020 ----
7819ea7
      {"log10",		1, 1, f_log10},
7819ea7
  #endif
7819ea7
  #ifdef FEAT_LUA
7819ea7
!     {"luaeval",		1, 2, f_luaeval},
7819ea7
  #endif
7819ea7
      {"map",		2, 2, f_map},
7819ea7
      {"maparg",		1, 4, f_maparg},
7819ea7
***************
7819ea7
*** 13905,13910 ****
7819ea7
--- 13905,13911 ----
7819ea7
      int		type;
7819ea7
  {
7819ea7
      char_u	*str = NULL;
7819ea7
+     long	len = 0;
7819ea7
      char_u	*expr = NULL;
7819ea7
      char_u	*pat;
7819ea7
      regmatch_T	regmatch;
7819ea7
***************
7819ea7
*** 13944,13950 ****
7819ea7
--- 13945,13954 ----
7819ea7
  	li = l->lv_first;
7819ea7
      }
7819ea7
      else
7819ea7
+     {
7819ea7
  	expr = str = get_tv_string(&argvars[0]);
7819ea7
+ 	len = (long)STRLEN(str);
7819ea7
+     }
7819ea7
  
7819ea7
      pat = get_tv_string_buf_chk(&argvars[1], patbuf);
7819ea7
      if (pat == NULL)
7819ea7
***************
7819ea7
*** 13968,13974 ****
7819ea7
  	{
7819ea7
  	    if (start < 0)
7819ea7
  		start = 0;
7819ea7
! 	    if (start > (long)STRLEN(str))
7819ea7
  		goto theend;
7819ea7
  	    /* When "count" argument is there ignore matches before "start",
7819ea7
  	     * otherwise skip part of the string.  Differs when pattern is "^"
7819ea7
--- 13972,13978 ----
7819ea7
  	{
7819ea7
  	    if (start < 0)
7819ea7
  		start = 0;
7819ea7
! 	    if (start > len)
7819ea7
  		goto theend;
7819ea7
  	    /* When "count" argument is there ignore matches before "start",
7819ea7
  	     * otherwise skip part of the string.  Differs when pattern is "^"
7819ea7
***************
7819ea7
*** 13976,13982 ****
7819ea7
--- 13980,13989 ----
7819ea7
  	    if (argvars[3].v_type != VAR_UNKNOWN)
7819ea7
  		startcol = start;
7819ea7
  	    else
7819ea7
+ 	    {
7819ea7
  		str += start;
7819ea7
+ 		len -= start;
7819ea7
+ 	    }
7819ea7
  	}
7819ea7
  
7819ea7
  	if (argvars[3].v_type != VAR_UNKNOWN)
7819ea7
***************
7819ea7
*** 14026,14031 ****
7819ea7
--- 14033,14044 ----
7819ea7
  #else
7819ea7
  		startcol = (colnr_T)(regmatch.startp[0] + 1 - str);
7819ea7
  #endif
7819ea7
+ 		if (startcol > (colnr_T)len
7819ea7
+ 				      || str + startcol <= regmatch.startp[0])
7819ea7
+ 		{
7819ea7
+ 		    match = FALSE;
7819ea7
+ 		    break;
7819ea7
+ 		}
7819ea7
  	    }
7819ea7
  	}
7819ea7
  
7819ea7
*** ../vim-7.4.183/src/testdir/test53.in	2013-10-02 21:54:57.000000000 +0200
7819ea7
--- src/testdir/test53.in	2014-02-22 22:08:24.260906501 +0100
7819ea7
***************
7819ea7
*** 4,9 ****
7819ea7
--- 4,11 ----
7819ea7
  
7819ea7
  Also test match() and matchstr()
7819ea7
  
7819ea7
+ Also test the gn command and repeating it.
7819ea7
+ 
7819ea7
  STARTTEST
7819ea7
  :so small.vim
7819ea7
  /^start:/
7819ea7
***************
7819ea7
*** 28,33 ****
7819ea7
--- 30,57 ----
7819ea7
  :put =matchstr(\"abcd\", \".\", 0, -1) " a
7819ea7
  :put =match(\"abcd\", \".\", 0, 5) " -1
7819ea7
  :put =match(\"abcd\", \".\", 0, -1) " 0
7819ea7
+ :put =match('abc', '.', 0, 1) " 0
7819ea7
+ :put =match('abc', '.', 0, 2) " 1
7819ea7
+ :put =match('abc', '.', 0, 3) " 2
7819ea7
+ :put =match('abc', '.', 0, 4) " -1
7819ea7
+ :put =match('abc', '.', 1, 1) " 1
7819ea7
+ :put =match('abc', '.', 2, 1) " 2
7819ea7
+ :put =match('abc', '.', 3, 1) " -1
7819ea7
+ :put =match('abc', '$', 0, 1) " 3
7819ea7
+ :put =match('abc', '$', 0, 2) " -1
7819ea7
+ :put =match('abc', '$', 1, 1) " 3
7819ea7
+ :put =match('abc', '$', 2, 1) " 3
7819ea7
+ :put =match('abc', '$', 3, 1) " 3
7819ea7
+ :put =match('abc', '$', 4, 1) " -1
7819ea7
+ :put =match('abc', '\zs', 0, 1) " 0
7819ea7
+ :put =match('abc', '\zs', 0, 2) " 1
7819ea7
+ :put =match('abc', '\zs', 0, 3) " 2
7819ea7
+ :put =match('abc', '\zs', 0, 4) " 3
7819ea7
+ :put =match('abc', '\zs', 0, 5) " -1
7819ea7
+ :put =match('abc', '\zs', 1, 1) " 1
7819ea7
+ :put =match('abc', '\zs', 2, 1) " 2
7819ea7
+ :put =match('abc', '\zs', 3, 1) " 3
7819ea7
+ :put =match('abc', '\zs', 4, 1) " -1
7819ea7
  /^foobar
7819ea7
  gncsearchmatch?/one\_s*two\_s
7819ea7
  :1
7819ea7
***************
7819ea7
*** 49,54 ****
7819ea7
--- 73,84 ----
7819ea7
  :" Make sure there is no other match y uppercase.
7819ea7
  /?x59
7819ea7
  gggnd
7819ea7
+ :" test repeating dgn
7819ea7
+ /^Johnny
7819ea7
+ ggdgn.
7819ea7
+ :" test repeating gUgn
7819ea7
+ /^Depp
7819ea7
+ gggUgn.
7819ea7
  :/^start:/,/^end:/wq! test.out
7819ea7
  ENDTEST
7819ea7
  
7819ea7
***************
7819ea7
*** 81,84 ****
7819ea7
--- 111,123 ----
7819ea7
  Y
7819ea7
  text
7819ea7
  Y
7819ea7
+ --1
7819ea7
+ Johnny
7819ea7
+ --2
7819ea7
+ Johnny
7819ea7
+ --3
7819ea7
+ Depp
7819ea7
+ --4
7819ea7
+ Depp
7819ea7
+ --5
7819ea7
  end:
7819ea7
*** ../vim-7.4.183/src/testdir/test53.ok	2013-10-02 21:54:57.000000000 +0200
7819ea7
--- src/testdir/test53.ok	2014-02-22 22:08:24.264906501 +0100
7819ea7
***************
7819ea7
*** 18,23 ****
7819ea7
--- 18,45 ----
7819ea7
  a
7819ea7
  -1
7819ea7
  0
7819ea7
+ 0
7819ea7
+ 1
7819ea7
+ 2
7819ea7
+ -1
7819ea7
+ 1
7819ea7
+ 2
7819ea7
+ -1
7819ea7
+ 3
7819ea7
+ -1
7819ea7
+ 3
7819ea7
+ 3
7819ea7
+ 3
7819ea7
+ -1
7819ea7
+ 0
7819ea7
+ 1
7819ea7
+ 2
7819ea7
+ 3
7819ea7
+ -1
7819ea7
+ 1
7819ea7
+ 2
7819ea7
+ 3
7819ea7
+ -1
7819ea7
  SEARCH:
7819ea7
  searchmatch
7819ea7
  abcdx |  | abcdx
7819ea7
***************
7819ea7
*** 30,33 ****
7819ea7
--- 52,64 ----
7819ea7
  
7819ea7
  text
7819ea7
  Y
7819ea7
+ --1
7819ea7
+ 
7819ea7
+ --2
7819ea7
+ 
7819ea7
+ --3
7819ea7
+ DEPP
7819ea7
+ --4
7819ea7
+ DEPP
7819ea7
+ --5
7819ea7
  end:
7819ea7
*** ../vim-7.4.183/src/version.c	2014-02-15 19:47:46.685882910 +0100
7819ea7
--- src/version.c	2014-02-22 22:10:49.604906270 +0100
7819ea7
***************
7819ea7
*** 740,741 ****
7819ea7
--- 740,743 ----
7819ea7
  {   /* Add new patch number below this line */
7819ea7
+ /**/
7819ea7
+     184,
7819ea7
  /**/
7819ea7
7819ea7
-- 
7819ea7
WOMAN:   I didn't know we had a king. I thought we were an autonomous
7819ea7
         collective.
7819ea7
DENNIS:  You're fooling yourself.  We're living in a dictatorship.  A
7819ea7
         self-perpetuating autocracy in which the working classes--
7819ea7
WOMAN:   Oh there you go, bringing class into it again.
7819ea7
DENNIS:  That's what it's all about if only people would--
7819ea7
                                  The Quest for the Holy Grail (Monty Python)
7819ea7
7819ea7
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
7819ea7
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
7819ea7
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
7819ea7
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///