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/charset.c b/src/charset.c
index 2c46f7a..0c17140 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1748,7 +1748,7 @@
}
/*
- * Getdigits: Get a number from a string and skip over it.
+ * Get a number from a string and skip over it.
* Note: the argument is a pointer to a char_u pointer!
*/
long
@@ -1767,6 +1767,38 @@
}
/*
+ * Like getdigits() but allow for embedded single quotes.
+ */
+ long
+getdigits_quoted(char_u **pp)
+{
+ char_u *p = *pp;
+ long retval = 0;
+
+ if (*p == '-')
+ ++p;
+ while (VIM_ISDIGIT(*p))
+ {
+ if (retval >= LONG_MAX / 10 - 10)
+ retval = LONG_MAX;
+ else
+ retval = retval * 10 - '0' + *p;
+ ++p;
+ if (in_vim9script() && *p == '\'' && VIM_ISDIGIT(p[1]))
+ ++p;
+ }
+ if (**pp == '-')
+ {
+ if (retval == LONG_MAX)
+ retval = LONG_MIN;
+ else
+ retval = -retval;
+ }
+ *pp = p;
+ return retval;
+}
+
+/*
* Return TRUE if "lbuf" is empty or only contains blanks.
*/
int