]> granicus.if.org Git - vim/commitdiff
patch 8.2.3033: no error when using alpha delimiter with :global v8.2.3033
authorBram Moolenaar <Bram@vim.org>
Mon, 21 Jun 2021 19:55:18 +0000 (21:55 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 21 Jun 2021 19:55:18 +0000 (21:55 +0200)
Problem:    No error when using alpha delimiter with :global.
Solution:   Check the delimiter like with :substitute. (closes #8415)

src/ex_cmds.c
src/testdir/test_global.vim
src/version.c

index 614d41d69fc9b79dabf07c4ac71235775e1acb4e..d8c5a12c72a2267824fbdeb6bab93188a8351553 100644 (file)
@@ -3643,6 +3643,17 @@ skip_substitute(char_u *start, int delimiter)
     return p;
 }
 
+    static int
+check_regexp_delim(int c)
+{
+    if (isalpha(c))
+    {
+       emsg(_("E146: Regular expressions can't be delimited by letters"));
+       return FAIL;
+    }
+    return OK;
+}
+
 /*
  * Perform a substitution from line eap->line1 to line eap->line2 using the
  * command pointed to by eap->arg which should be of the form:
@@ -3705,11 +3716,9 @@ ex_substitute(exarg_T *eap)
                && vim_strchr((char_u *)"0123456789cegriIp|\"", *cmd) == NULL)
     {
                                // don't accept alphanumeric for separator
-       if (isalpha(*cmd))
-       {
-           emsg(_("E146: Regular expressions can't be delimited by letters"));
+       if (check_regexp_delim(*cmd) == FAIL)
            return;
-       }
+
        /*
         * undocumented vi feature:
         *  "\/sub/" and "\?sub?" use last used search pattern (almost like
@@ -4909,6 +4918,10 @@ ex_global(exarg_T *eap)
        emsg(_("E148: Regular expression missing from global"));
        return;
     }
+    else if (check_regexp_delim(*cmd) == FAIL)
+    {
+       return;
+    }
     else
     {
        delim = *cmd;           // get the delimiter
index 4a01be4194578a0b448b09cf6ef54370c35c0a5a..48753cfcc8e884a667d1f11d7a95c2ebe986ed60 100644 (file)
@@ -83,4 +83,8 @@ func Test_global_newline()
   close!
 endfunc
 
+func Test_wrong_delimiter()
+  call assert_fails('g x^bxd', 'E146:')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index a6e483e05c7142abdad6dc4d3be55187d10f56b1..d8d033a2e0a6d5af4014f616ebbaaa2f39ff2eb4 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3033,
 /**/
     3032,
 /**/