]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.184 v7.4.184
authorBram Moolenaar <Bram@vim.org>
Sat, 22 Feb 2014 21:18:47 +0000 (22:18 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 22 Feb 2014 21:18:47 +0000 (22:18 +0100)
Problem:    match() does not work properly with a {count} argument.
Solution:   Compute the length once and update it.  Quit the loop when at the
            end. (Hirohito Higashi)

src/eval.c
src/testdir/test53.in
src/testdir/test53.ok
src/version.c

index 65a947bbd43970f6746299cabb1fc735027ce7c8..80fc337061e592bf29b29629d390b8b4dd41b681 100644 (file)
@@ -8014,7 +8014,7 @@ static struct fst
     {"log10",          1, 1, f_log10},
 #endif
 #ifdef FEAT_LUA
-    {"luaeval",         1, 2, f_luaeval},
+    {"luaeval",                1, 2, f_luaeval},
 #endif
     {"map",            2, 2, f_map},
     {"maparg",         1, 4, f_maparg},
@@ -13905,6 +13905,7 @@ find_some_match(argvars, rettv, type)
     int                type;
 {
     char_u     *str = NULL;
+    long       len = 0;
     char_u     *expr = NULL;
     char_u     *pat;
     regmatch_T regmatch;
@@ -13944,7 +13945,10 @@ find_some_match(argvars, rettv, type)
        li = l->lv_first;
     }
     else
+    {
        expr = str = get_tv_string(&argvars[0]);
+       len = (long)STRLEN(str);
+    }
 
     pat = get_tv_string_buf_chk(&argvars[1], patbuf);
     if (pat == NULL)
@@ -13968,7 +13972,7 @@ find_some_match(argvars, rettv, type)
        {
            if (start < 0)
                start = 0;
-           if (start > (long)STRLEN(str))
+           if (start > len)
                goto theend;
            /* When "count" argument is there ignore matches before "start",
             * otherwise skip part of the string.  Differs when pattern is "^"
@@ -13976,7 +13980,10 @@ find_some_match(argvars, rettv, type)
            if (argvars[3].v_type != VAR_UNKNOWN)
                startcol = start;
            else
+           {
                str += start;
+               len -= start;
+           }
        }
 
        if (argvars[3].v_type != VAR_UNKNOWN)
@@ -14026,6 +14033,12 @@ find_some_match(argvars, rettv, type)
 #else
                startcol = (colnr_T)(regmatch.startp[0] + 1 - str);
 #endif
+               if (startcol > (colnr_T)len
+                                     || str + startcol <= regmatch.startp[0])
+               {
+                   match = FALSE;
+                   break;
+               }
            }
        }
 
index 47cf6f562f9c47a96bb3b3a0dc28bf5746373b8e..011c9ae39da6e42da3b5e9595ca91a1b6ba4004b 100644 (file)
@@ -4,6 +4,8 @@ Note that the end-of-line moves the cursor to the next test line.
 
 Also test match() and matchstr()
 
+Also test the gn command and repeating it.
+
 STARTTEST
 :so small.vim
 /^start:/
@@ -28,6 +30,28 @@ fXdat
 :put =matchstr(\"abcd\", \".\", 0, -1) " a
 :put =match(\"abcd\", \".\", 0, 5) " -1
 :put =match(\"abcd\", \".\", 0, -1) " 0
+:put =match('abc', '.', 0, 1) " 0
+:put =match('abc', '.', 0, 2) " 1
+:put =match('abc', '.', 0, 3) " 2
+:put =match('abc', '.', 0, 4) " -1
+:put =match('abc', '.', 1, 1) " 1
+:put =match('abc', '.', 2, 1) " 2
+:put =match('abc', '.', 3, 1) " -1
+:put =match('abc', '$', 0, 1) " 3
+:put =match('abc', '$', 0, 2) " -1
+:put =match('abc', '$', 1, 1) " 3
+:put =match('abc', '$', 2, 1) " 3
+:put =match('abc', '$', 3, 1) " 3
+:put =match('abc', '$', 4, 1) " -1
+:put =match('abc', '\zs', 0, 1) " 0
+:put =match('abc', '\zs', 0, 2) " 1
+:put =match('abc', '\zs', 0, 3) " 2
+:put =match('abc', '\zs', 0, 4) " 3
+:put =match('abc', '\zs', 0, 5) " -1
+:put =match('abc', '\zs', 1, 1) " 1
+:put =match('abc', '\zs', 2, 1) " 2
+:put =match('abc', '\zs', 3, 1) " 3
+:put =match('abc', '\zs', 4, 1) " -1
 /^foobar
 gncsearchmatch\e/one\_s*two\_s
 :1
@@ -49,6 +73,12 @@ cgnj\e
 :" Make sure there is no other match y uppercase.
 /\16x59
 gggnd
+:" test repeating dgn
+/^Johnny
+ggdgn.
+:" test repeating gUgn
+/^Depp
+gggUgn.
 :/^start:/,/^end:/wq! test.out
 ENDTEST
 
@@ -81,4 +111,13 @@ for (i=0; i<=10; i++)
 Y
 text
 Y
+--1
+Johnny
+--2
+Johnny
+--3
+Depp
+--4
+Depp
+--5
 end:
index e469869abb95e6bccf783c643158c97d4949bfea..d7ffa6bc516a53791c803584ff8d60fa308d6ec6 100644 (file)
@@ -18,6 +18,28 @@ c
 a
 -1
 0
+0
+1
+2
+-1
+1
+2
+-1
+3
+-1
+3
+3
+3
+-1
+0
+1
+2
+3
+-1
+1
+2
+3
+-1
 SEARCH:
 searchmatch
 abcdx |  | abcdx
@@ -30,4 +52,13 @@ for (j=0; i<=10; i++)
 
 text
 Y
+--1
+
+--2
+
+--3
+DEPP
+--4
+DEPP
+--5
 end:
index 9f37a7489b627020cee9561ddf9e0a46cfa6ba6c..40deff6da5ffeebee3438cdfa44afb4c47ff5e08 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    184,
 /**/
     183,
 /**/