Karsten Hopp 227cd3
To: vim_dev@googlegroups.com
Karsten Hopp 227cd3
Subject: Patch 7.3.1196
Karsten Hopp 227cd3
Fcc: outbox
Karsten Hopp 227cd3
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 227cd3
Mime-Version: 1.0
Karsten Hopp 227cd3
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 227cd3
Content-Transfer-Encoding: 8bit
Karsten Hopp 227cd3
------------
Karsten Hopp 227cd3
Karsten Hopp 227cd3
Patch 7.3.1196
Karsten Hopp 227cd3
Problem:    Old regexp engine does not match pattern with backref correctly.
Karsten Hopp 227cd3
	    (Dominique Pelle)
Karsten Hopp 227cd3
Solution:   Fix setting status.  Test multi-line patterns better.
Karsten Hopp 227cd3
Files:	    src/regexp.c, src/testdir/test64.in, src/testdir/test64.ok
Karsten Hopp 227cd3
Karsten Hopp 227cd3
Karsten Hopp 227cd3
*** ../vim-7.3.1195/src/regexp.c	2013-06-14 22:48:50.000000000 +0200
Karsten Hopp 227cd3
--- src/regexp.c	2013-06-15 14:09:21.000000000 +0200
Karsten Hopp 227cd3
***************
Karsten Hopp 227cd3
*** 5021,5032 ****
Karsten Hopp 227cd3
  			{
Karsten Hopp 227cd3
  			    /* Messy situation: Need to compare between two
Karsten Hopp 227cd3
  			     * lines. */
Karsten Hopp 227cd3
! 			    status = match_with_backref(
Karsten Hopp 227cd3
  					    reg_startpos[no].lnum,
Karsten Hopp 227cd3
  					    reg_startpos[no].col,
Karsten Hopp 227cd3
  					    reg_endpos[no].lnum,
Karsten Hopp 227cd3
  					    reg_endpos[no].col,
Karsten Hopp 227cd3
  					    &len;;
Karsten Hopp 227cd3
  			}
Karsten Hopp 227cd3
  		    }
Karsten Hopp 227cd3
  		}
Karsten Hopp 227cd3
--- 5021,5035 ----
Karsten Hopp 227cd3
  			{
Karsten Hopp 227cd3
  			    /* Messy situation: Need to compare between two
Karsten Hopp 227cd3
  			     * lines. */
Karsten Hopp 227cd3
! 			    int r = match_with_backref(
Karsten Hopp 227cd3
  					    reg_startpos[no].lnum,
Karsten Hopp 227cd3
  					    reg_startpos[no].col,
Karsten Hopp 227cd3
  					    reg_endpos[no].lnum,
Karsten Hopp 227cd3
  					    reg_endpos[no].col,
Karsten Hopp 227cd3
  					    &len;;
Karsten Hopp 227cd3
+ 
Karsten Hopp 227cd3
+ 			    if (r != RA_MATCH)
Karsten Hopp 227cd3
+ 				status = r;
Karsten Hopp 227cd3
  			}
Karsten Hopp 227cd3
  		    }
Karsten Hopp 227cd3
  		}
Karsten Hopp 227cd3
*** ../vim-7.3.1195/src/testdir/test64.in	2013-06-14 20:31:20.000000000 +0200
Karsten Hopp 227cd3
--- src/testdir/test64.in	2013-06-15 15:05:03.000000000 +0200
Karsten Hopp 227cd3
***************
Karsten Hopp 227cd3
*** 377,382 ****
Karsten Hopp 227cd3
--- 377,383 ----
Karsten Hopp 227cd3
  :call add(tl, [2, '\(\i\+\) \1', 'xgoo goox', 'goo goo', 'goo'])
Karsten Hopp 227cd3
  :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'])
Karsten Hopp 227cd3
  :call add(tl, [2, '\(\d*\)a \1b', ' a b ', 'a b', ''])
Karsten Hopp 227cd3
+ :call add(tl, [2, '^.\(.\).\_..\1.', "aaa\naaa\nb", "aaa\naaa", 'a'])
Karsten Hopp 227cd3
  :"
Karsten Hopp 227cd3
  :"""" Look-behind with limit
Karsten Hopp 227cd3
  :call add(tl, [2, '<\@<=span.', 'xxspanxx
Karsten Hopp 227cd3
***************
Karsten Hopp 227cd3
*** 453,469 ****
Karsten Hopp 227cd3
  :endfor
Karsten Hopp 227cd3
  :unlet t tl e l
Karsten Hopp 227cd3
  :"
Karsten Hopp 227cd3
  :" Check that \_[0-9] matching EOL does not break a following \>
Karsten Hopp 227cd3
! :" This only works on a buffer line, not with expression evaluation
Karsten Hopp 227cd3
! /^Find this
Karsten Hopp 227cd3
! /\%#=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]\?\)\>
Karsten Hopp 227cd3
! y$Go?p:"
Karsten Hopp 227cd3
! /^Find this
Karsten Hopp 227cd3
! /\%#=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]\?\)\>
Karsten Hopp 227cd3
! y$Go?p:"
Karsten Hopp 227cd3
! /^Find this
Karsten Hopp 227cd3
! /\%#=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]\?\)\>
Karsten Hopp 227cd3
! y$Go?p:"
Karsten Hopp 227cd3
  :"
Karsten Hopp 227cd3
  :" Check that using a pattern on two lines doesn't get messed up by using
Karsten Hopp 227cd3
  :" matchstr() with \ze in between.
Karsten Hopp 227cd3
--- 454,501 ----
Karsten Hopp 227cd3
  :endfor
Karsten Hopp 227cd3
  :unlet t tl e l
Karsten Hopp 227cd3
  :"
Karsten Hopp 227cd3
+ :"""""" multi-line tests
Karsten Hopp 227cd3
+ :let tl = []
Karsten Hopp 227cd3
+ :"
Karsten Hopp 227cd3
+ :"""" back references
Karsten Hopp 227cd3
+ :call add(tl, [2, '^.\(.\).\_..\1.', ['aaa', 'aaa', 'b'], ['XX', 'b']])
Karsten Hopp 227cd3
+ :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']])
Karsten Hopp 227cd3
+ :"
Karsten Hopp 227cd3
+ :"""" line breaks
Karsten Hopp 227cd3
+ :call add(tl, [2, '\S.*\nx', ['abc', 'def', 'ghi', 'xjk', 'lmn'], ['abc', 'def', 'XXjk', 'lmn']])
Karsten Hopp 227cd3
+ :"
Karsten Hopp 227cd3
  :" Check that \_[0-9] matching EOL does not break a following \>
Karsten Hopp 227cd3
! :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', '']])
Karsten Hopp 227cd3
! :"
Karsten Hopp 227cd3
! :" Check a pattern with a line break and ^ and $
Karsten Hopp 227cd3
! :call add(tl, [2, 'a\n^b$\n^c', ['a', 'b', 'c'], ['XX']])
Karsten Hopp 227cd3
! :"
Karsten Hopp 227cd3
! :"""" Run the multi-line tests
Karsten Hopp 227cd3
! :"
Karsten Hopp 227cd3
! :$put ='multi-line tests'
Karsten Hopp 227cd3
! :for t in tl
Karsten Hopp 227cd3
! :  let re = t[0]
Karsten Hopp 227cd3
! :  let pat = t[1]
Karsten Hopp 227cd3
! :  let before = t[2]
Karsten Hopp 227cd3
! :  let after = t[3]
Karsten Hopp 227cd3
! :  for engine in [0, 1, 2]
Karsten Hopp 227cd3
! :    if engine == 2 && re == 0 || engine == 1 && re ==1
Karsten Hopp 227cd3
! :      continue
Karsten Hopp 227cd3
! :    endif
Karsten Hopp 227cd3
! :    let &regexpengine = engine
Karsten Hopp 227cd3
! :    new
Karsten Hopp 227cd3
! :    call setline(1, before)
Karsten Hopp 227cd3
! :    exe '%s/' . pat . '/XX/'
Karsten Hopp 227cd3
! :    let result = getline(1, '$')
Karsten Hopp 227cd3
! :    q!
Karsten Hopp 227cd3
! :    if result != after
Karsten Hopp 227cd3
! :      $put ='ERROR: pat: \"' . pat . '\", text: \"' . string(before) . '\", expected: \"' . string(after) . '\", got: \"' . string(result) . '\"'
Karsten Hopp 227cd3
! :    else
Karsten Hopp 227cd3
! :      $put ='OK ' . engine . ' - ' . pat
Karsten Hopp 227cd3
! :    endif
Karsten Hopp 227cd3
! :  endfor
Karsten Hopp 227cd3
! :endfor
Karsten Hopp 227cd3
! :unlet t tl
Karsten Hopp 227cd3
  :"
Karsten Hopp 227cd3
  :" Check that using a pattern on two lines doesn't get messed up by using
Karsten Hopp 227cd3
  :" matchstr() with \ze in between.
Karsten Hopp 227cd3
***************
Karsten Hopp 227cd3
*** 474,497 ****
Karsten Hopp 227cd3
  :.+1,.+2yank
Karsten Hopp 227cd3
  Go?p:"
Karsten Hopp 227cd3
  :"
Karsten Hopp 227cd3
- :" Check a pattern with a line break matches in the right position.
Karsten Hopp 227cd3
- /^Multiline
Karsten Hopp 227cd3
- /\S.*\nx
Karsten Hopp 227cd3
- :.yank
Karsten Hopp 227cd3
- y$Go?p:"
Karsten Hopp 227cd3
- :"
Karsten Hopp 227cd3
- :" Check a pattern with a line break and ^ and $
Karsten Hopp 227cd3
- /^Abc:
Karsten Hopp 227cd3
- /a\n^b$\n^c/e
Karsten Hopp 227cd3
- :.yank
Karsten Hopp 227cd3
- Go?p:"
Karsten Hopp 227cd3
- :"
Karsten Hopp 227cd3
- :" Check using a backref matching in a previous line
Karsten Hopp 227cd3
- /^Backref:
Karsten Hopp 227cd3
- /\v.*\/(.*)\n.*\/\1$
Karsten Hopp 227cd3
- :.yank
Karsten Hopp 227cd3
- Go?p:"
Karsten Hopp 227cd3
- :"
Karsten Hopp 227cd3
  :" Check a pattern with a look beind crossing a line boundary
Karsten Hopp 227cd3
  /^Behind:
Karsten Hopp 227cd3
  /\(<\_[xy]\+\)\@3<=start
Karsten Hopp 227cd3
--- 506,511 ----
Karsten Hopp 227cd3
***************
Karsten Hopp 227cd3
*** 553,584 ****
Karsten Hopp 227cd3
  :/\%#=1^Results/,$wq! test.out
Karsten Hopp 227cd3
  ENDTEST
Karsten Hopp 227cd3
  
Karsten Hopp 227cd3
- Find this:
Karsten Hopp 227cd3
- localnet/192.168.0.1
Karsten Hopp 227cd3
- 
Karsten Hopp 227cd3
  Substitute here:
Karsten Hopp 227cd3
  <T="">Ta 5</Title>
Karsten Hopp 227cd3
  <T="">Ac 7</Title>
Karsten Hopp 227cd3
  
Karsten Hopp 227cd3
- Multiline:
Karsten Hopp 227cd3
- abc
Karsten Hopp 227cd3
- def
Karsten Hopp 227cd3
- ghi
Karsten Hopp 227cd3
- xjk
Karsten Hopp 227cd3
- lmn
Karsten Hopp 227cd3
- 
Karsten Hopp 227cd3
- Abc:
Karsten Hopp 227cd3
- a
Karsten Hopp 227cd3
- b
Karsten Hopp 227cd3
- c
Karsten Hopp 227cd3
- 
Karsten Hopp 227cd3
- Backref:
Karsten Hopp 227cd3
- ./Dir1/Dir2/zyxwvuts.txt
Karsten Hopp 227cd3
- ./Dir1/Dir2/abcdefgh.bat
Karsten Hopp 227cd3
- 
Karsten Hopp 227cd3
- ./Dir1/Dir2/file1.txt
Karsten Hopp 227cd3
- ./OtherDir1/OtherDir2/file1.txt
Karsten Hopp 227cd3
- 
Karsten Hopp 227cd3
  Behind:
Karsten Hopp 227cd3
  asdfasd
Karsten Hopp 227cd3
  xxstart1
Karsten Hopp 227cd3
--- 567,576 ----
Karsten Hopp 227cd3
*** ../vim-7.3.1195/src/testdir/test64.ok	2013-06-14 20:31:20.000000000 +0200
Karsten Hopp 227cd3
--- src/testdir/test64.ok	2013-06-15 15:05:06.000000000 +0200
Karsten Hopp 227cd3
***************
Karsten Hopp 227cd3
*** 857,862 ****
Karsten Hopp 227cd3
--- 857,865 ----
Karsten Hopp 227cd3
  OK 0 - \(\d*\)a \1b
Karsten Hopp 227cd3
  OK 1 - \(\d*\)a \1b
Karsten Hopp 227cd3
  OK 2 - \(\d*\)a \1b
Karsten Hopp 227cd3
+ OK 0 - ^.\(.\).\_..\1.
Karsten Hopp 227cd3
+ OK 1 - ^.\(.\).\_..\1.
Karsten Hopp 227cd3
+ OK 2 - ^.\(.\).\_..\1.
Karsten Hopp 227cd3
  OK 0 - <\@<=span.
Karsten Hopp 227cd3
  OK 1 - <\@<=span.
Karsten Hopp 227cd3
  OK 2 - <\@<=span.
Karsten Hopp 227cd3
***************
Karsten Hopp 227cd3
*** 910,926 ****
Karsten Hopp 227cd3
  OK 0 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
Karsten Hopp 227cd3
  OK 1 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
Karsten Hopp 227cd3
  OK 2 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
Karsten Hopp 227cd3
! 192.168.0.1
Karsten Hopp 227cd3
! 192.168.0.1
Karsten Hopp 227cd3
! 192.168.0.1
Karsten Hopp 227cd3
  
Karsten Hopp 227cd3
  <T="5">Ta 5</Title>
Karsten Hopp 227cd3
  <T="7">Ac 7</Title>
Karsten Hopp 227cd3
- ghi
Karsten Hopp 227cd3
- 
Karsten Hopp 227cd3
- c
Karsten Hopp 227cd3
- 
Karsten Hopp 227cd3
- ./Dir1/Dir2/file1.txt
Karsten Hopp 227cd3
  
Karsten Hopp 227cd3
  xxstart3
Karsten Hopp 227cd3
  
Karsten Hopp 227cd3
--- 913,937 ----
Karsten Hopp 227cd3
  OK 0 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
Karsten Hopp 227cd3
  OK 1 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
Karsten Hopp 227cd3
  OK 2 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
Karsten Hopp 227cd3
! multi-line tests
Karsten Hopp 227cd3
! OK 0 - ^.\(.\).\_..\1.
Karsten Hopp 227cd3
! OK 1 - ^.\(.\).\_..\1.
Karsten Hopp 227cd3
! OK 2 - ^.\(.\).\_..\1.
Karsten Hopp 227cd3
! OK 0 - \v.*\/(.*)\n.*\/\1$
Karsten Hopp 227cd3
! OK 1 - \v.*\/(.*)\n.*\/\1$
Karsten Hopp 227cd3
! OK 2 - \v.*\/(.*)\n.*\/\1$
Karsten Hopp 227cd3
! OK 0 - \S.*\nx
Karsten Hopp 227cd3
! OK 1 - \S.*\nx
Karsten Hopp 227cd3
! OK 2 - \S.*\nx
Karsten Hopp 227cd3
! 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]\?\)\>
Karsten Hopp 227cd3
! 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]\?\)\>
Karsten Hopp 227cd3
! 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]\?\)\>
Karsten Hopp 227cd3
! OK 0 - a\n^b$\n^c
Karsten Hopp 227cd3
! OK 1 - a\n^b$\n^c
Karsten Hopp 227cd3
! OK 2 - a\n^b$\n^c
Karsten Hopp 227cd3
  
Karsten Hopp 227cd3
  <T="5">Ta 5</Title>
Karsten Hopp 227cd3
  <T="7">Ac 7</Title>
Karsten Hopp 227cd3
  
Karsten Hopp 227cd3
  xxstart3
Karsten Hopp 227cd3
  
Karsten Hopp 227cd3
*** ../vim-7.3.1195/src/version.c	2013-06-14 22:48:50.000000000 +0200
Karsten Hopp 227cd3
--- src/version.c	2013-06-15 14:12:46.000000000 +0200
Karsten Hopp 227cd3
***************
Karsten Hopp 227cd3
*** 730,731 ****
Karsten Hopp 227cd3
--- 730,733 ----
Karsten Hopp 227cd3
  {   /* Add new patch number below this line */
Karsten Hopp 227cd3
+ /**/
Karsten Hopp 227cd3
+     1196,
Karsten Hopp 227cd3
  /**/
Karsten Hopp 227cd3
Karsten Hopp 227cd3
-- 
Karsten Hopp 227cd3
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 227cd3
213. Your kids start referring to you as "that guy in front of the monitor."
Karsten Hopp 227cd3
Karsten Hopp 227cd3
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 227cd3
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 227cd3
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 227cd3
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///