]> granicus.if.org Git - vim/commitdiff
patch 8.2.4693: new regexp does not accept pattern "\%>0v" v8.2.4693
authorBram Moolenaar <Bram@vim.org>
Tue, 5 Apr 2022 13:00:32 +0000 (14:00 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 5 Apr 2022 13:00:32 +0000 (14:00 +0100)
Problem:    new regexp does not accept pattern "\%>0v".
Solution:   Do accept digit zero.

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

index 0b3487fa0ac50c2391099e474604149a97e8f04b..18bad80548158d0d28c628450dec849462c58f4c 100644 (file)
@@ -1617,6 +1617,7 @@ regatom(int *flagp)
                              long_u    n = 0;
                              int       cmp;
                              int       cur = FALSE;
+                             int       got_digit = FALSE;
 
                              cmp = c;
                              if (cmp == '<' || cmp == '>')
@@ -1628,6 +1629,7 @@ regatom(int *flagp)
                              }
                              while (VIM_ISDIGIT(c))
                              {
+                                 got_digit = TRUE;
                                  n = n * 10 + (c - '0');
                                  c = getchr();
                              }
@@ -1645,7 +1647,8 @@ regatom(int *flagp)
                                  }
                                  break;
                              }
-                             else if (c == 'l' || c == 'c' || c == 'v')
+                             else if ((c == 'l' || c == 'c' || c == 'v')
+                                         && (cur || got_digit))
                              {
                                  if (cur && n)
                                  {
index d658a6bd78599cb07aa24b639c9ced5bd02ccc96..2c79a49e499ea0caa13f78d3abe476add22c4221 100644 (file)
@@ -1640,6 +1640,7 @@ nfa_regatom(void)
                        long_u  n = 0;
                        int     cmp = c;
                        int     cur = FALSE;
+                       int     got_digit = FALSE;
 
                        if (c == '<' || c == '>')
                            c = getchr();
@@ -1668,12 +1669,13 @@ nfa_regatom(void)
                            }
                            n = tmp;
                            c = getchr();
+                           got_digit = TRUE;
                        }
                        if (c == 'l' || c == 'c' || c == 'v')
                        {
                            long_u limit = INT_MAX;
 
-                           if (!cur && n == 0)
+                           if (!cur && !got_digit)
                            {
                                semsg(_(e_nfa_regexp_missing_value_in_chr),
                                                                  no_Magic(c));
index dfb367b5f1d8fad5f797220e0c203dfc5c7112fd..0b288f69fd586117d1ff9b8fa9163e017286fcec 100644 (file)
@@ -91,16 +91,29 @@ func Test_multi_failure()
   set re=0
 endfunc
 
-func Test_column_failure()
+func Test_column_success_failure()
+  new
+  call setline(1, 'xbar')
+
   set re=1
+  %s/\%>0v./A/
+  call assert_equal('Abar', getline(1))
   call assert_fails('/\%v', 'E71:')
+  call assert_fails('/\%>v', 'E71:')
   call assert_fails('/\%c', 'E71:')
+  call assert_fails('/\%<c', 'E71:')
   call assert_fails('/\%l', 'E71:')
   set re=2
+  %s/\%>0v./B/
+  call assert_equal('Bbar', getline(1))
   call assert_fails('/\%v', 'E1273:')
+  call assert_fails('/\%>v', 'E1273:')
   call assert_fails('/\%c', 'E1273:')
+  call assert_fails('/\%<c', 'E1273:')
   call assert_fails('/\%l', 'E1273:')
+
   set re=0
+  bwipe!
 endfunc
 
 func Test_recursive_addstate()
index 4451f7d91e3a0b568ad15d175814ad52be40e96d..203b9472b85c6350c34eb551f8a6aeb75f40b6ce 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4693,
 /**/
     4692,
 /**/