aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/regexp.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-09-13 19:32:06 -0700
committerGitHub <noreply@github.com>2019-09-13 19:32:06 -0700
commit9cf8cf605d85ec043d4e39f73ac42c7482c6f901 (patch)
treeb0a8ec8985c5bdfb1882ee847ff64b42c98d3e0a /src/nvim/regexp.c
parent427cf16e44d047c14e0ca1b95eb09fc8b8eb2f3d (diff)
parent6aae0e7c943267d2109ae20ec5086791c3b94a5e (diff)
downloadrneovim-9cf8cf605d85ec043d4e39f73ac42c7482c6f901.tar.gz
rneovim-9cf8cf605d85ec043d4e39f73ac42c7482c6f901.tar.bz2
rneovim-9cf8cf605d85ec043d4e39f73ac42c7482c6f901.zip
Merge #11015 from justinmk/getdigits
getdigits: introduce `strict`, `def` parameters
Diffstat (limited to 'src/nvim/regexp.c')
-rw-r--r--src/nvim/regexp.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 37d71699dd..9bc7ef07eb 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -3105,23 +3105,26 @@ static int read_limits(long *minval, long *maxval)
long tmp;
if (*regparse == '-') {
- /* Starts with '-', so reverse the range later */
+ // Starts with '-', so reverse the range later.
regparse++;
reverse = TRUE;
}
first_char = regparse;
- *minval = getdigits_long(&regparse);
- if (*regparse == ',') { /* There is a comma */
- if (ascii_isdigit(*++regparse))
- *maxval = getdigits_long(&regparse);
- else
+ *minval = getdigits_long(&regparse, false, 0);
+ if (*regparse == ',') { // There is a comma.
+ if (ascii_isdigit(*++regparse)) {
+ *maxval = getdigits_long(&regparse, false, MAX_LIMIT);
+ } else {
*maxval = MAX_LIMIT;
- } else if (ascii_isdigit(*first_char))
- *maxval = *minval; /* It was \{n} or \{-n} */
- else
- *maxval = MAX_LIMIT; /* It was \{} or \{-} */
- if (*regparse == '\\')
- regparse++; /* Allow either \{...} or \{...\} */
+ }
+ } else if (ascii_isdigit(*first_char)) {
+ *maxval = *minval; // It was \{n} or \{-n}
+ } else {
+ *maxval = MAX_LIMIT; // It was \{} or \{-}
+ }
+ if (*regparse == '\\') {
+ regparse++; // Allow either \{...} or \{...\}
+ }
if (*regparse != '}') {
sprintf((char *)IObuff, _("E554: Syntax error in %s{...}"),
reg_magic == MAGIC_ALL ? "" : "\\");