Eat trailing whitespace in config files.
authorGuus Sliepen <guus@tinc-vpn.org>
Mon, 15 Mar 2004 18:05:41 +0000 (18:05 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Mon, 15 Mar 2004 18:05:41 +0000 (18:05 +0000)
src/conf.c

index d0a2d2d..369a5fb 100644 (file)
@@ -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);