From 57f932a33b9be4558f7b16c5643526fee9b5cced Mon Sep 17 00:00:00 2001 From: rofl0r Date: Fri, 9 Oct 2020 01:26:50 +0100 Subject: [PATCH] conf: skip leading whitespace instead of adding it to each regex --- src/conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf.c b/src/conf.c index 2ce1b2c..f6af384 100644 --- a/src/conf.c +++ b/src/conf.c @@ -142,7 +142,7 @@ static void config_free_regex (void); * do not follow the pattern above. This macro is for convenience * only. */ -#define STDCONF(d, re, func) [CD_ ## d] = { BEGIN WS re END, func, NULL } +#define STDCONF(d, re, func) [CD_ ## d] = { BEGIN re END, func, NULL } /* * Holds the regular expression used to match the configuration directive, @@ -318,7 +318,7 @@ static int check_match (struct config_s *conf, const char *line, */ static int config_parse (struct config_s *conf, FILE * f) { - char buffer[LINE_MAX], *p, *q, c; + char buffer[LINE_MAX], *p, *q; const struct config_directive_entry *e; unsigned long lineno = 1; @@ -329,10 +329,10 @@ static int config_parse (struct config_s *conf, FILE * f) if(!*p) continue; q = p; while(!isspace(*q))q++; - c = *q; *q = 0; e = config_directive_find(p, strlen(p)); - *q = c; + ++q; + while(isspace(*q))++q; if (!e || e->value == CD_NIL || check_match (conf, q, lineno, e->value)) { fprintf (stderr, "ERROR: Syntax error on line %lu\n", lineno); return 1;