From 45ca7d4a62d9d6275339e9d9c0a4930448592712 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 5 Nov 2022 11:17:10 +0800 Subject: vim-patch:8.2.0502: Vim9: some code is not tested Problem: Vim9: some code is not tested. Solution: Add more tests. Fix uncovered problems. https://github.com/vim/vim/commit/e8c4abbbd711af8fd3ed85ea69e9ac3d63a0d879 Co-authored-by: Bram Moolenaar --- src/nvim/regexp.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/nvim/regexp.c') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index d6f207a248..4ae7fc7578 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -484,10 +484,17 @@ static char_u *skip_anyof(char *p) /// Stop at end of "startp" or where "dirc" is found ('/', '?', etc). /// Take care of characters with a backslash in front of it. /// Skip strings inside [ and ]. +char *skip_regexp(char *startp, int dirc, int magic) +{ + return skip_regexp_ex(startp, dirc, magic, NULL, NULL); +} + +/// skip_regexp() with extra arguments: /// When "newp" is not NULL and "dirc" is '?', make an allocated copy of the /// expression and change "\?" to "?". If "*newp" is not NULL the expression /// is changed in-place. -char *skip_regexp(char *startp, int dirc, int magic, char **newp) +/// If a "\?" is changed to "?" then "dropped" is incremented, unless NULL. +char *skip_regexp_ex(char *startp, int dirc, int magic, char **newp, int *dropped) { int mymagic; char *p = startp; @@ -516,6 +523,9 @@ char *skip_regexp(char *startp, int dirc, int magic, char **newp) *newp = xstrdup(startp); p = *newp + (p - startp); } + if (dropped != NULL) { + (*dropped)++; + } STRMOVE(p, p + 1); } else { p++; // skip next character -- cgit From 199c7c28989a3c36447ef56b71c7b84756950a11 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 5 Nov 2022 11:27:28 +0800 Subject: vim-patch:8.2.0612: Vim9: no check for space before #comment Problem: Vim9: no check for space before #comment. Solution: Add space checks. https://github.com/vim/vim/commit/2c5ed4e3300378ce76c8d9c3818d6f73e5119f68 Omit ends_excmd2(): the same as ends_excmd() in legacy Vim script. Co-authored-by: Bram Moolenaar --- src/nvim/regexp.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/nvim/regexp.c') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 4ae7fc7578..68ffc70457 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -481,12 +481,25 @@ static char_u *skip_anyof(char *p) } /// Skip past regular expression. -/// Stop at end of "startp" or where "dirc" is found ('/', '?', etc). +/// Stop at end of "startp" or where "delim" is found ('/', '?', etc). /// Take care of characters with a backslash in front of it. /// Skip strings inside [ and ]. -char *skip_regexp(char *startp, int dirc, int magic) +char *skip_regexp(char *startp, int delim, int magic) { - return skip_regexp_ex(startp, dirc, magic, NULL, NULL); + return skip_regexp_ex(startp, delim, magic, NULL, NULL); +} + +/// Call skip_regexp() and when the delimiter does not match give an error and +/// return NULL. +char *skip_regexp_err(char *startp, int delim, int magic) +{ + char *p = skip_regexp(startp, delim, magic); + + if (*p != delim) { + semsg(_("E654: missing delimiter after search pattern: %s"), startp); + return NULL; + } + return p; } /// skip_regexp() with extra arguments: -- cgit