]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0217: regexp: verymagic cannot match before/after a mark v9.1.0217
authorJulio B <julio.bacel@gmail.com>
Thu, 28 Mar 2024 09:23:37 +0000 (10:23 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 28 Mar 2024 09:23:37 +0000 (10:23 +0100)
Problem:  regexp: verymagic cannot match before/after a mark
Solution: Correctly check for the very magic check (Julio B)

Fix regexp parser for \v%>'m and \v%<'m
Currently \v%'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.bacel@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/regexp_bt.c
src/regexp_nfa.c
src/testdir/test_regexp_latin.vim

index 198946e0dcb63b8c0eed10d63a6a5752059e33fe..5d9450d8712b3f284ca6c23e341ce142e07a58a8 100644 (file)
@@ -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();
index ff54348905e7482ab6ce56e3c83405d09c709de4..359ce5b517c1b0f68d5e3e83067791b23d58e789 100644 (file)
@@ -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 :
index 9acb12b4af3875ac2e70c0009f67f72528b0df43..f8614e7d1813a1f363d317674b10ecbdb5fbffcb 100644 (file)
@@ -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