]> granicus.if.org Git - vim/commitdiff
patch 9.0.0407: matchstr() does match column offset v9.0.0407
authorBram Moolenaar <Bram@vim.org>
Wed, 7 Sep 2022 17:21:24 +0000 (18:21 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 7 Sep 2022 17:21:24 +0000 (18:21 +0100)
Problem:    matchstr() does match column offset. (Yasuhiro Matsumoto)
Solution:   Accept line number zero. (closes #10938)

src/regexp_bt.c
src/regexp_nfa.c
src/testdir/test_regexp_latin.vim
src/version.c

index cf484e0bab35f2e863ffbbf7e16b79d7590db4b8..e3e7a18016b2034dfcb76f02be736186675c3605 100644 (file)
@@ -3444,7 +3444,7 @@ regmatch(
                linenr_T    lnum = rex.reg_firstlnum + rex.lnum;
                long_u      vcol = 0;
 
-               if (lnum > 0 && lnum <= wp->w_buffer->b_ml.ml_line_count)
+               if (lnum >= 0 && lnum <= wp->w_buffer->b_ml.ml_line_count)
                    vcol = (long_u)win_linetabsize(wp, lnum, rex.line,
                                              (colnr_T)(rex.input - rex.line));
                if (!re_num_cmp(vcol + 1, scan))
index f8717f5b1ab3b8e9968a8a22aa263e10ea1a8401..b39848927298836aeeb2cd3905105256267740d7 100644 (file)
@@ -6778,7 +6778,7 @@ nfa_regmatch(
                        linenr_T    lnum = rex.reg_firstlnum + rex.lnum;
                        long_u      vcol = 0;
 
-                       if (lnum > 0
+                       if (lnum >= 0
                                   && lnum <= wp->w_buffer->b_ml.ml_line_count)
                            vcol = (long_u)win_linetabsize(wp, lnum,
                                                                rex.line, col);
index bc08439d15daefc569d18bf32e0c2c742e1c723b..6f3ffe23ff26edd5df9fafdb6b9b1a20e3118518 100644 (file)
@@ -30,11 +30,13 @@ endfunc
 func Test_equivalence_re1()
   set re=1
   call s:equivalence_test()
+  set re=0
 endfunc
 
 func Test_equivalence_re2()
   set re=2
   call s:equivalence_test()
+  set re=0
 endfunc
 
 func Test_recursive_substitute()
@@ -67,6 +69,7 @@ func Test_eow_with_optional()
     let actual = matchlist('abc def', '\(abc\>\)\?\s*\(def\)')
     call assert_equal(expected, actual)
   endfor
+  set re=0
 endfunc
 
 func Test_backref()
@@ -1141,4 +1144,14 @@ def Test_compare_columns()
   prop_type_delete('name')
 enddef
 
+def Test_compare_column_matchstr()
+  enew
+  set re=1
+  call assert_equal('aaa', matchstr('aaaaaaaaaaaaaaaaaaaa', '.*\%<5v'))
+  set re=2
+  call assert_equal('aaa', matchstr('aaaaaaaaaaaaaaaaaaaa', '.*\%<5v'))
+  set re=0
+enddef
+
+
 " vim: shiftwidth=2 sts=2 expandtab
index e4b0b09a2dcf083cc30039e2246cf9b7bac86af1..92fd7e7c83fe1d5b70904abcc210c3464665fc45 100644 (file)
@@ -703,6 +703,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    407,
 /**/
     406,
 /**/