Skip to content

Commit 75a115e

Browse files
committed
patch 9.0.0407: matchstr() does match column offset
Problem: matchstr() does match column offset. (Yasuhiro Matsumoto) Solution: Accept line number zero. (closes #10938)
1 parent 9667b2c commit 75a115e

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/regexp_bt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3444,7 +3444,7 @@ regmatch(
34443444
linenr_T lnum = rex.reg_firstlnum + rex.lnum;
34453445
long_u vcol = 0;
34463446

3447-
if (lnum > 0 && lnum <= wp->w_buffer->b_ml.ml_line_count)
3447+
if (lnum >= 0 && lnum <= wp->w_buffer->b_ml.ml_line_count)
34483448
vcol = (long_u)win_linetabsize(wp, lnum, rex.line,
34493449
(colnr_T)(rex.input - rex.line));
34503450
if (!re_num_cmp(vcol + 1, scan))

src/regexp_nfa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6778,7 +6778,7 @@ nfa_regmatch(
67786778
linenr_T lnum = rex.reg_firstlnum + rex.lnum;
67796779
long_u vcol = 0;
67806780

6781-
if (lnum > 0
6781+
if (lnum >= 0
67826782
&& lnum <= wp->w_buffer->b_ml.ml_line_count)
67836783
vcol = (long_u)win_linetabsize(wp, lnum,
67846784
rex.line, col);

src/testdir/test_regexp_latin.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ endfunc
3030
func Test_equivalence_re1()
3131
set re=1
3232
call s:equivalence_test()
33+
set re=0
3334
endfunc
3435

3536
func Test_equivalence_re2()
3637
set re=2
3738
call s:equivalence_test()
39+
set re=0
3840
endfunc
3941

4042
func Test_recursive_substitute()
@@ -67,6 +69,7 @@ func Test_eow_with_optional()
6769
let actual = matchlist('abc def', '\(abc\>\)\?\s*\(def\)')
6870
call assert_equal(expected, actual)
6971
endfor
72+
set re=0
7073
endfunc
7174

7275
func Test_backref()
@@ -1141,4 +1144,14 @@ def Test_compare_columns()
11411144
prop_type_delete('name')
11421145
enddef
11431146

1147+
def Test_compare_column_matchstr()
1148+
enew
1149+
set re=1
1150+
call assert_equal('aaa', matchstr('aaaaaaaaaaaaaaaaaaaa', '.*\%<5v'))
1151+
set re=2
1152+
call assert_equal('aaa', matchstr('aaaaaaaaaaaaaaaaaaaa', '.*\%<5v'))
1153+
set re=0
1154+
enddef
1155+
1156+
11441157
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

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

704704
static int included_patches[] =
705705
{ /* Add new patch number below this line */
706+
/**/
707+
407,
706708
/**/
707709
406,
708710
/**/

0 commit comments

Comments
 (0)