commit 9f92341c844a24e51bafa1353fa9fbff7133a0d9
parent 3357712928eacef97f8aa404a7949dafc6dec22a
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 3 Mar 2020 16:21:47 +0100
tweaks: check for a starting quote in one place instead of three
Diffstat:
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -557,6 +557,11 @@ char *parse_argument(char *ptr)
* null-terminate it, and return a pointer to the /next/ word. */
char *parse_next_regex(char *ptr)
{
+ if (*(ptr - 1) != '"') {
+ jot_error(N_("Regex strings must begin and end with a \" character"));
+ return NULL;
+ }
+
/* Continue until the end of line, or until a " followed by a
* blank character or the end of line. */
while (*ptr != '\0' && (*ptr != '"' ||
@@ -1062,13 +1067,9 @@ void parse_rule(char *ptr, int rex_flags)
expectend = TRUE;
}
- if (*ptr != '"') {
- jot_error(N_("Regex strings must begin and end with a \" character"));
- return;
- }
-
regexstring = ++ptr;
ptr = parse_next_regex(ptr);
+
if (ptr == NULL)
return;
@@ -1107,14 +1108,9 @@ void parse_rule(char *ptr, int rex_flags)
return;
}
- ptr += 4;
- if (*ptr != '"') {
- jot_error(N_("Regex strings must begin and end with a \" character"));
- return;
- }
+ regexstring = ptr + 5;
+ ptr = parse_next_regex(ptr + 5);
- regexstring = ++ptr;
- ptr = parse_next_regex(ptr);
if (ptr == NULL)
return;
@@ -1184,13 +1180,9 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
const char *regexstring;
regexlisttype *newthing;
- if (*ptr != '"') {
- jot_error(N_("Regex strings must begin and end with a \" character"));
- return;
- }
-
regexstring = ++ptr;
ptr = parse_next_regex(ptr);
+
if (ptr == NULL)
return;