Eat trailing whitespace in config files.
This commit is contained in:
parent
4350704d65
commit
a67a21ef3c
1 changed files with 6 additions and 1 deletions
|
@ -321,7 +321,7 @@ int read_config_file(avl_tree_t *config_tree, const char *fname)
|
||||||
int err = -2; /* Parse error */
|
int err = -2; /* Parse error */
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *buffer, *line;
|
char *buffer, *line;
|
||||||
char *variable, *value;
|
char *variable, *value, *eol;
|
||||||
int lineno = 0;
|
int lineno = 0;
|
||||||
int len;
|
int len;
|
||||||
bool ignore = false;
|
bool ignore = false;
|
||||||
|
@ -372,6 +372,10 @@ int read_config_file(avl_tree_t *config_tree, const char *fname)
|
||||||
|
|
||||||
variable = value = line;
|
variable = value = line;
|
||||||
|
|
||||||
|
eol = line + strlen(line);
|
||||||
|
while(strchr("\t ", *--eol))
|
||||||
|
*eol = '\0';
|
||||||
|
|
||||||
len = strcspn(value, "\t =");
|
len = strcspn(value, "\t =");
|
||||||
value += len;
|
value += len;
|
||||||
value += strspn(value, "\t ");
|
value += strspn(value, "\t ");
|
||||||
|
@ -381,6 +385,7 @@ int read_config_file(avl_tree_t *config_tree, const char *fname)
|
||||||
}
|
}
|
||||||
variable[len] = '\0';
|
variable[len] = '\0';
|
||||||
|
|
||||||
|
|
||||||
if(!*value) {
|
if(!*value) {
|
||||||
logger(LOG_ERR, _("No value for variable `%s' on line %d while reading config file %s"),
|
logger(LOG_ERR, _("No value for variable `%s' on line %d while reading config file %s"),
|
||||||
variable, lineno, fname);
|
variable, lineno, fname);
|
||||||
|
|
Loading…
Reference in a new issue