0
0
mirror of https://github.com/vim/vim.git synced 2025-09-28 04:24:06 -04:00

patch 8.2.3033: no error when using alpha delimiter with :global

Problem:    No error when using alpha delimiter with :global.
Solution:   Check the delimiter like with :substitute. (closes #8415)
This commit is contained in:
Bram Moolenaar
2021-06-21 21:55:18 +02:00
parent 226b28b961
commit 419a40ac96
3 changed files with 23 additions and 4 deletions

View File

@@ -3643,6 +3643,17 @@ skip_substitute(char_u *start, int delimiter)
return p; 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 * 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: * 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) && vim_strchr((char_u *)"0123456789cegriIp|\"", *cmd) == NULL)
{ {
// don't accept alphanumeric for separator // don't accept alphanumeric for separator
if (isalpha(*cmd)) if (check_regexp_delim(*cmd) == FAIL)
{
emsg(_("E146: Regular expressions can't be delimited by letters"));
return; return;
}
/* /*
* undocumented vi feature: * undocumented vi feature:
* "\/sub/" and "\?sub?" use last used search pattern (almost like * "\/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")); emsg(_("E148: Regular expression missing from global"));
return; return;
} }
else if (check_regexp_delim(*cmd) == FAIL)
{
return;
}
else else
{ {
delim = *cmd; // get the delimiter delim = *cmd; // get the delimiter

View File

@@ -83,4 +83,8 @@ func Test_global_newline()
close! close!
endfunc endfunc
func Test_wrong_delimiter()
call assert_fails('g x^bxd', 'E146:')
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3033,
/**/ /**/
3032, 3032,
/**/ /**/