patch 9.1.0217: regexp: verymagic cannot match before/after a mark Commit: https://github.com/vim/vim/commit/46fa3c7e271eb2abb05a0d9e6dbc9c36c2b2da02 Author: Julio B <julio.ba...@gmail.com> Date: Thu Mar 28 10:23:37 2024 +0100
patch 9.1.0217: regexp: verymagic cannot match before/after a mark Problem: regexp: verymagic cannot match before/after a mark Solution: Correctly check for the very magic check (Julio B) Fix regexp parser for %>'m and %<'m Currently %'m works fine, but it is unable to match before or after the position of mark m. closes: #14309 Signed-off-by: Julio B <julio.ba...@gmail.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/regexp_bt.c b/src/regexp_bt.c index 198946e0d..5d9450d87 100644 --- a/src/regexp_bt.c +++ b/src/regexp_bt.c @@ -1641,7 +1641,7 @@ regatom(int *flagp) n = n * 10 + (c - '0'); c = getchr(); } - if (c == '\'' && n == 0) + if (no_Magic(c) == '\'' && n == 0) { // "\%'m", "\%<'m" and "\%>'m": Mark c = getchr(); diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index ff5434890..359ce5b51 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -1733,7 +1733,7 @@ nfa_regatom(void) EMIT((int)n); break; } - else if (c == '\'' && n == 0) + else if (no_Magic(c) == '\'' && n == 0) { // \%'m \%<'m \%>'m EMIT(cmp == '<' ? NFA_MARK_LT : diff --git a/src/testdir/test_regexp_latin.vim b/src/testdir/test_regexp_latin.vim index 9acb12b4a..f8614e7d1 100644 --- a/src/testdir/test_regexp_latin.vim +++ b/src/testdir/test_regexp_latin.vim @@ -874,12 +874,26 @@ func Regex_Mark() %d endfunc +" Same test as abobe, but use verymagic +func Regex_Mark_Verymagic() + call append(0, ['', '', '', 'Marks:', 'asdfSasdfsadfEasdf', 'asdfSas', + \ 'dfsadfEasdf', '', '', '', '', '']) + call cursor(4, 1) + exe "normal jfSmsfEme:.-4,.+6s/\v.%>'s.*%<'e../here/\<CR>" + exe "normal jfSmsj0fEme:.-4,.+6s/\v.%>'s\_.*%<'e../again/\<CR>" + call assert_equal(['', '', '', 'Marks:', 'asdfhereasdf', 'asdfagainasdf', + \ '', '', '', '', '', ''], getline(1, '$')) + %d +endfunc + func Test_matching_marks() new set regexpengine=1 call Regex_Mark() + call Regex_Mark_Verymagic() set regexpengine=2 call Regex_Mark() + call Regex_Mark_Verymagic() bwipe! endfunc -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/E1rpm5E-00ApIh-Hs%40256bit.org.