Skip to content

Commit 419a40a

Browse files
committed
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)
1 parent 226b28b commit 419a40a

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

src/ex_cmds.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3643,6 +3643,17 @@ skip_substitute(char_u *start, int delimiter)
36433643
return p;
36443644
}
36453645

3646+
static int
3647+
check_regexp_delim(int c)
3648+
{
3649+
if (isalpha(c))
3650+
{
3651+
emsg(_("E146: Regular expressions can't be delimited by letters"));
3652+
return FAIL;
3653+
}
3654+
return OK;
3655+
}
3656+
36463657
/*
36473658
* Perform a substitution from line eap->line1 to line eap->line2 using the
36483659
* command pointed to by eap->arg which should be of the form:
@@ -3705,11 +3716,9 @@ ex_substitute(exarg_T *eap)
37053716
&& vim_strchr((char_u *)"0123456789cegriIp|\"", *cmd) == NULL)
37063717
{
37073718
// don't accept alphanumeric for separator
3708-
if (isalpha(*cmd))
3709-
{
3710-
emsg(_("E146: Regular expressions can't be delimited by letters"));
3719+
if (check_regexp_delim(*cmd) == FAIL)
37113720
return;
3712-
}
3721+
37133722
/*
37143723
* undocumented vi feature:
37153724
* "\/sub/" and "\?sub?" use last used search pattern (almost like
@@ -4909,6 +4918,10 @@ ex_global(exarg_T *eap)
49094918
emsg(_("E148: Regular expression missing from global"));
49104919
return;
49114920
}
4921+
else if (check_regexp_delim(*cmd) == FAIL)
4922+
{
4923+
return;
4924+
}
49124925
else
49134926
{
49144927
delim = *cmd; // get the delimiter

src/testdir/test_global.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,8 @@ func Test_global_newline()
8383
close!
8484
endfunc
8585

86+
func Test_wrong_delimiter()
87+
call assert_fails('g x^bxd', 'E146:')
88+
endfunc
89+
8690
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3033,
758760
/**/
759761
3032,
760762
/**/

0 commit comments

Comments
 (0)