Skip to content

Commit fe116bb

Browse files
committed
updated for version 7.4.101
Problem: Using \1 in pattern goes one line too far. (Bohr Shaw, John Little) Solution: Only advance the match end for the matched characters in the last line.
1 parent 58a9816 commit fe116bb

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

src/regexp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6455,7 +6455,8 @@ re_num_cmp(val, scan)
64556455
/*
64566456
* Check whether a backreference matches.
64576457
* Returns RA_FAIL, RA_NOMATCH or RA_MATCH.
6458-
* If "bytelen" is not NULL, it is set to the bytelength of the whole match.
6458+
* If "bytelen" is not NULL, it is set to the byte length of the match in the
6459+
* last line.
64596460
*/
64606461
static int
64616462
match_with_backref(start_lnum, start_col, end_lnum, end_col, bytelen)
@@ -6511,6 +6512,8 @@ match_with_backref(start_lnum, start_col, end_lnum, end_col, bytelen)
65116512

65126513
/* Advance to next line. */
65136514
reg_nextline();
6515+
if (bytelen != NULL)
6516+
*bytelen = 0;
65146517
++clnum;
65156518
ccol = 0;
65166519
if (got_int)

src/testdir/test64.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ STARTTEST
507507
:" Check a pattern with a line break and ^ and $
508508
:call add(tl, [2, 'a\n^b$\n^c', ['a', 'b', 'c'], ['XX']])
509509
:"
510+
:call add(tl, [2, '\(^.\+\n\)\1', [' dog', ' dog', 'asdf'], ['XXasdf']])
511+
:"
510512
:"""" Run the multi-line tests
511513
:"
512514
:$put ='multi-line tests'

src/testdir/test64.ok

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,9 @@ OK 2 - \<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25
10311031
OK 0 - a\n^b$\n^c
10321032
OK 1 - a\n^b$\n^c
10331033
OK 2 - a\n^b$\n^c
1034+
OK 0 - \(^.\+\n\)\1
1035+
OK 1 - \(^.\+\n\)\1
1036+
OK 2 - \(^.\+\n\)\1
10341037

10351038
<T="5">Ta 5</Title>
10361039
<T="7">Ac 7</Title>

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
101,
741743
/**/
742744
100,
743745
/**/

0 commit comments

Comments
 (0)