summaryrefslogtreecommitdiff
path: root/src/ex_docmd.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-11-29 12:12:43 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-29 12:12:43 +0000
commitaf377e34b01ba00f9520d2b9de1f911e72db0114 (patch)
treee3863b6aeb06509afdd60fa7448163268f24aca1 /src/ex_docmd.c
parent293eb9ba4669b1500370502397d399681e7098f0 (diff)
downloadvim-git-af377e34b01ba00f9520d2b9de1f911e72db0114.tar.gz
patch 8.2.3694: cannot use quotes in the count of an Ex commandv8.2.3694
Problem: Cannot use quotes in the count of an Ex command. Solution: Add getdigits_quoted(). Give an error when misplacing a quote in a range. (closes #9240)
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r--src/ex_docmd.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 6d2923ccb..523d8af30 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2402,7 +2402,7 @@ do_one_cmd(
&& (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg + 1)) == NUL
|| VIM_ISWHITE(*p)))
{
- n = getdigits(&ea.arg);
+ n = getdigits_quoted(&ea.arg);
ea.arg = skipwhite(ea.arg);
if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0)
{
@@ -3950,10 +3950,11 @@ excmd_get_argt(cmdidx_T idx)
*/
char_u *
skip_range(
- char_u *cmd,
+ char_u *cmd_start,
int skip_star, // skip "*" used for Visual range
int *ctx) // pointer to xp_context or NULL
{
+ char_u *cmd = cmd_start;
unsigned delim;
while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;\\", *cmd) != NULL)
@@ -3967,6 +3968,17 @@ skip_range(
}
else if (*cmd == '\'')
{
+ char_u *p = cmd;
+
+ // a quote is only valid at the start or after a separator
+ while (p > cmd_start)
+ {
+ --p;
+ if (!VIM_ISWHITE(*p))
+ break;
+ }
+ if (cmd > cmd_start && !VIM_ISWHITE(*p) && *p != ',' && *p != ';')
+ break;
if (*++cmd == NUL && ctx != NULL)
*ctx = EXPAND_NOTHING;
}