patch 8.2.3694: cannot use quotes in the count of an Ex command
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)
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 6d2923c..523d8af 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2402,7 +2402,7 @@
&& (!(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 @@
*/
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 @@
}
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;
}