From a67a21ef3c17d32af95373e921138429a7fc507e Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 15 Mar 2004 18:05:41 +0000 Subject: [PATCH] Eat trailing whitespace in config files. --- src/conf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/conf.c b/src/conf.c index d0a2d2df..369a5fbc 100644 --- a/src/conf.c +++ b/src/conf.c @@ -321,7 +321,7 @@ int read_config_file(avl_tree_t *config_tree, const char *fname) int err = -2; /* Parse error */ FILE *fp; char *buffer, *line; - char *variable, *value; + char *variable, *value, *eol; int lineno = 0; int len; bool ignore = false; @@ -372,6 +372,10 @@ int read_config_file(avl_tree_t *config_tree, const char *fname) variable = value = line; + eol = line + strlen(line); + while(strchr("\t ", *--eol)) + *eol = '\0'; + len = strcspn(value, "\t ="); value += len; value += strspn(value, "\t "); @@ -381,6 +385,7 @@ int read_config_file(avl_tree_t *config_tree, const char *fname) } variable[len] = '\0'; + if(!*value) { logger(LOG_ERR, _("No value for variable `%s' on line %d while reading config file %s"), variable, lineno, fname); -- 2.39.5