To: vim_dev@googlegroups.com Subject: Patch 9.0.0407 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0407 (after 9.0.0228) Problem: matchstr() does match column offset. (Yasuhiro Matsumoto) Solution: Accept line number zero. (closes #10938) Files: src/regexp_bt.c, src/regexp_nfa.c, src/testdir/test_regexp_latin.vim *** ../vim-9.0.0406/src/regexp_bt.c 2022-08-19 13:59:19.472283589 +0100 --- src/regexp_bt.c 2022-09-07 18:12:29.037349337 +0100 *************** *** 3444,3450 **** linenr_T lnum = rex.reg_firstlnum + rex.lnum; long_u vcol = 0; ! 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)) --- 3444,3450 ---- linenr_T lnum = rex.reg_firstlnum + rex.lnum; long_u vcol = 0; ! 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)) *** ../vim-9.0.0406/src/regexp_nfa.c 2022-08-19 13:59:19.472283589 +0100 --- src/regexp_nfa.c 2022-09-07 18:10:20.265583908 +0100 *************** *** 6778,6784 **** linenr_T lnum = rex.reg_firstlnum + rex.lnum; long_u vcol = 0; ! if (lnum > 0 && lnum <= wp->w_buffer->b_ml.ml_line_count) vcol = (long_u)win_linetabsize(wp, lnum, rex.line, col); --- 6778,6784 ---- linenr_T lnum = rex.reg_firstlnum + rex.lnum; long_u vcol = 0; ! if (lnum >= 0 && lnum <= wp->w_buffer->b_ml.ml_line_count) vcol = (long_u)win_linetabsize(wp, lnum, rex.line, col); *** ../vim-9.0.0406/src/testdir/test_regexp_latin.vim 2022-08-19 13:59:19.472283589 +0100 --- src/testdir/test_regexp_latin.vim 2022-09-07 18:19:28.148557975 +0100 *************** *** 30,40 **** --- 30,42 ---- 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,72 **** --- 69,75 ---- let actual = matchlist('abc def', '\(abc\>\)\?\s*\(def\)') call assert_equal(expected, actual) endfor + set re=0 endfunc func Test_backref() *************** *** 1141,1144 **** --- 1144,1157 ---- 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 *** ../vim-9.0.0406/src/version.c 2022-09-07 17:28:05.849865176 +0100 --- src/version.c 2022-09-07 18:13:59.589181413 +0100 *************** *** 705,706 **** --- 705,708 ---- { /* Add new patch number below this line */ + /**/ + 407, /**/ -- Far back in the mists of ancient time, in the great and glorious days of the former Galactic Empire, life was wild, rich and largely tax free. Mighty starships plied their way between exotic suns, seeking adventure and reward among the furthest reaches of Galactic space. In those days, spirits were brave, the stakes were high, men were real men, women were real women and small furry creatures from Alpha Centauri were real small furry creatures from Alpha Centauri. And all dared to brave unknown terrors, to do mighty deeds, to boldly split infinitives that no man had split before -- and thus was the Empire forged. -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///