genconf: fix path display (no slash at the end)
[libcmdline.git] / src / genconf / confnode.c
index ed5bd91..6a85953 100644 (file)
@@ -206,7 +206,7 @@ int confnode_dotconfig_write(const struct confnode *n, FILE *f)
        if (confnode_get_value(n, buf, sizeof(buf)) < 0)
                return -1;
        val = confnode_strvalue_to_boolvalue(n, buf);
-       if (val < 1)
+       if (val < 0)
                return -1;
 
        if (val == 0) {
@@ -468,21 +468,21 @@ void confnode_display_long(const struct confnode *n)
        confnode_check_deps(n, 1);
 }
 
-void __conf_display_path(const struct confnode *n)
+static void __conf_display_path(const struct confnode *n, int first)
 {
        if (n->parent)
-               __conf_display_path(n->parent);
+               __conf_display_path(n->parent, 0);
        if (n->flags & CONFNODE_F_IS_ROOT)
                printf("/");
        else if (!(n->flags & CONFNODE_F_INVISIBLE))
-               printf("%s/", n->name);
+               printf("%s%s", n->name, first ? "" : "/" );
 }
 
 /* show path: used by the 'pwd' command. Nodes like 'if' are
  * ignored. */
 void conf_display_path(const struct confnode *n)
 {
-       __conf_display_path(n);
+       __conf_display_path(n, 1);
        printf("\n");
 }