summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-06-21 21:55:18 +0200
committerBram Moolenaar <Bram@vim.org>2021-06-21 21:55:18 +0200
commit419a40ac9657e39646b2e0f3f71d7736b0c459d1 (patch)
tree09a74d258eb68cfab3f27bcd205f3ba3021d6e8b
parent226b28b96150e59375d2bff44e0aadd382b0c3f1 (diff)
patch 8.2.3033: no error when using alpha delimiter with :globalv8.2.3033
Problem: No error when using alpha delimiter with :global. Solution: Check the delimiter like with :substitute. (closes #8415)
-rw-r--r--src/ex_cmds.c21
-rw-r--r--src/testdir/test_global.vim4
-rw-r--r--src/version.c2
3 files changed, 23 insertions, 4 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 614d41d69f..d8c5a12c72 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -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
diff --git a/src/testdir/test_global.vim b/src/testdir/test_global.vim
index 4a01be4194..48753cfcc8 100644
--- a/src/testdir/test_global.vim
+++ b/src/testdir/test_global.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index a6e483e05c..d8d033a2e0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3033,
+/**/
3032,
/**/
3031,