]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.1196 v7.3.1196
authorBram Moolenaar <Bram@vim.org>
Sat, 15 Jun 2013 13:09:50 +0000 (15:09 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 15 Jun 2013 13:09:50 +0000 (15:09 +0200)
Problem:    Old regexp engine does not match pattern with backref correctly.
            (Dominique Pelle)
Solution:   Fix setting status.  Test multi-line patterns better.

src/regexp.c
src/testdir/test64.in
src/testdir/test64.ok
src/version.c

index 0798f028b0a66f8357ae297fcac81c9fcc0dfc2d..fdcd9f41e3352c4a45b0cd2b2fb3befc2d0f0402 100644 (file)
@@ -5021,12 +5021,15 @@ regmatch(scan)
                        {
                            /* Messy situation: Need to compare between two
                             * lines. */
-                           status = match_with_backref(
+                           int r = match_with_backref(
                                            reg_startpos[no].lnum,
                                            reg_startpos[no].col,
                                            reg_endpos[no].lnum,
                                            reg_endpos[no].col,
                                            &len);
+
+                           if (r != RA_MATCH)
+                               status = r;
                        }
                    }
                }
index fe61ed3f26ef01d9c855cdc8b8c2afe8fea937e3..ad11c3c498a4346a44db59ce899e1a4a4fb5fe07 100644 (file)
@@ -377,6 +377,7 @@ STARTTEST
 :call add(tl, [2, '\(\i\+\) \1', 'xgoo goox', 'goo goo', 'goo'])
 :call add(tl, [2, '\(a\)\(b\)\(c\)\(dd\)\(e\)\(f\)\(g\)\(h\)\(i\)\1\2\3\4\5\6\7\8\9', 'xabcddefghiabcddefghix', 'abcddefghiabcddefghi', 'a', 'b', 'c', 'dd', 'e', 'f', 'g', 'h', 'i'])
 :call add(tl, [2, '\(\d*\)a \1b', ' a b ', 'a b', ''])
+:call add(tl, [2, '^.\(.\).\_..\1.', "aaa\naaa\nb", "aaa\naaa", 'a'])
 :"
 :"""" Look-behind with limit
 :call add(tl, [2, '<\@<=span.', 'xxspanxx<spanyyy', 'spany'])
@@ -453,17 +454,48 @@ STARTTEST
 :endfor
 :unlet t tl e l
 :"
+:"""""" multi-line tests
+:let tl = []
+:"
+:"""" back references
+:call add(tl, [2, '^.\(.\).\_..\1.', ['aaa', 'aaa', 'b'], ['XX', 'b']])
+:call add(tl, [2, '\v.*\/(.*)\n.*\/\1$', ['./Dir1/Dir2/zyxwvuts.txt', './Dir1/Dir2/abcdefgh.bat', '', './Dir1/Dir2/file1.txt', './OtherDir1/OtherDir2/file1.txt'], ['./Dir1/Dir2/zyxwvuts.txt', './Dir1/Dir2/abcdefgh.bat', '', 'XX']])
+:"
+:"""" line breaks
+:call add(tl, [2, '\S.*\nx', ['abc', 'def', 'ghi', 'xjk', 'lmn'], ['abc', 'def', 'XXjk', 'lmn']])
+:"
 :" Check that \_[0-9] matching EOL does not break a following \>
-:" This only works on a buffer line, not with expression evaluation
-/^Find this
-/\%#=0\<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\>
-y$Go\ep:"
-/^Find this
-/\%#=1\<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\>
-y$Go\ep:"
-/^Find this
-/\%#=2\<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\>
-y$Go\ep:"
+:call add(tl, [2, '\<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\>', ['', 'localnet/192.168.0.1', ''], ['', 'localnet/XX', '']])
+:"
+:" Check a pattern with a line break and ^ and $
+:call add(tl, [2, 'a\n^b$\n^c', ['a', 'b', 'c'], ['XX']])
+:"
+:"""" Run the multi-line tests
+:"
+:$put ='multi-line tests'
+:for t in tl
+:  let re = t[0]
+:  let pat = t[1]
+:  let before = t[2]
+:  let after = t[3]
+:  for engine in [0, 1, 2]
+:    if engine == 2 && re == 0 || engine == 1 && re ==1
+:      continue
+:    endif
+:    let &regexpengine = engine
+:    new
+:    call setline(1, before)
+:    exe '%s/' . pat . '/XX/'
+:    let result = getline(1, '$')
+:    q!
+:    if result != after
+:      $put ='ERROR: pat: \"' . pat . '\", text: \"' . string(before) . '\", expected: \"' . string(after) . '\", got: \"' . string(result) . '\"'
+:    else
+:      $put ='OK ' . engine . ' - ' . pat
+:    endif
+:  endfor
+:endfor
+:unlet t tl
 :"
 :" Check that using a pattern on two lines doesn't get messed up by using
 :" matchstr() with \ze in between.
@@ -474,24 +506,6 @@ y$Go\ep:"
 :.+1,.+2yank
 Go\ep:"
 :"
-:" Check a pattern with a line break matches in the right position.
-/^Multiline
-/\S.*\nx
-:.yank
-y$Go\ep:"
-:"
-:" Check a pattern with a line break and ^ and $
-/^Abc:
-/a\n^b$\n^c/e
-:.yank
-Go\ep:"
-:"
-:" Check using a backref matching in a previous line
-/^Backref:
-/\v.*\/(.*)\n.*\/\1$
-:.yank
-Go\ep:"
-:"
 :" Check a pattern with a look beind crossing a line boundary
 /^Behind:
 /\(<\_[xy]\+\)\@3<=start
@@ -553,32 +567,10 @@ yeGo\epA END\e:"
 :/\%#=1^Results/,$wq! test.out
 ENDTEST
 
-Find this:
-localnet/192.168.0.1
-
 Substitute here:
 <T="">Ta 5</Title>
 <T="">Ac 7</Title>
 
-Multiline:
-abc
-def
-ghi
-xjk
-lmn
-
-Abc:
-a
-b
-c
-
-Backref:
-./Dir1/Dir2/zyxwvuts.txt
-./Dir1/Dir2/abcdefgh.bat
-
-./Dir1/Dir2/file1.txt
-./OtherDir1/OtherDir2/file1.txt
-
 Behind:
 asdfasd<yyy
 xxstart1
index fe14fbd3ff88222feea1477d151e47d291b8add7..48694fb512ebacd989a461f8d06f65d832337bdf 100644 (file)
@@ -857,6 +857,9 @@ OK 2 - \(a\)\(b\)\(c\)\(dd\)\(e\)\(f\)\(g\)\(h\)\(i\)\1\2\3\4\5\6\7\8\9
 OK 0 - \(\d*\)a \1b
 OK 1 - \(\d*\)a \1b
 OK 2 - \(\d*\)a \1b
+OK 0 - ^.\(.\).\_..\1.
+OK 1 - ^.\(.\).\_..\1.
+OK 2 - ^.\(.\).\_..\1.
 OK 0 - <\@<=span.
 OK 1 - <\@<=span.
 OK 2 - <\@<=span.
@@ -910,17 +913,25 @@ OK 2 - \_[^a]\+
 OK 0 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
 OK 1 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
 OK 2 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
-192.168.0.1
-192.168.0.1
-192.168.0.1
+multi-line tests
+OK 0 - ^.\(.\).\_..\1.
+OK 1 - ^.\(.\).\_..\1.
+OK 2 - ^.\(.\).\_..\1.
+OK 0 - \v.*\/(.*)\n.*\/\1$
+OK 1 - \v.*\/(.*)\n.*\/\1$
+OK 2 - \v.*\/(.*)\n.*\/\1$
+OK 0 - \S.*\nx
+OK 1 - \S.*\nx
+OK 2 - \S.*\nx
+OK 0 - \<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\>
+OK 1 - \<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\>
+OK 2 - \<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\>
+OK 0 - a\n^b$\n^c
+OK 1 - a\n^b$\n^c
+OK 2 - a\n^b$\n^c
 
 <T="5">Ta 5</Title>
 <T="7">Ac 7</Title>
-ghi
-
-c
-
-./Dir1/Dir2/file1.txt
 
 xxstart3
 
index 1547d57dd7f64d0800ad346bc9841dd3262e4bf8..8fa7aace804994fb3de8eee7a52c4f812dea1292 100644 (file)
@@ -728,6 +728,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1196,
 /**/
     1195,
 /**/