From: Guus Sliepen Date: Mon, 15 Mar 2004 18:05:41 +0000 (+0000) Subject: Eat trailing whitespace in config files. X-Git-Tag: release-1.0.3~37^2~7 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a67a21ef3c17d32af95373e921138429a7fc507e;p=oweals%2Ftinc.git Eat trailing whitespace in config files. --- diff --git a/src/conf.c b/src/conf.c index d0a2d2d..369a5fb 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);