Mercurial > vim
changeset 24992:026718ffbfa8 v8.2.3033
patch 8.2.3033: no error when using alpha delimiter with :global
Commit: https://github.com/vim/vim/commit/419a40ac9657e39646b2e0f3f71d7736b0c459d1
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 21 21:55:18 2021 +0200
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 https://github.com/vim/vim/issues/8415)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 21 Jun 2021 22:00:04 +0200 |
parents | 8b207ff7091e |
children | 909f6cd6b9a3 |
files | src/ex_cmds.c src/testdir/test_global.vim src/version.c |
diffstat | 3 files changed, 23 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -3643,6 +3643,17 @@ skip_substitute(char_u *start, int delim 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