]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: move some code around
authorOndrej Oprala <ooprala@redhat.com>
Tue, 25 Mar 2014 09:24:13 +0000 (10:24 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 3 Apr 2014 10:29:18 +0000 (12:29 +0200)
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
libsmartcols/src/libsmartcols.h.in
libsmartcols/src/table.c

index 54a623c43080d553ba83f10d04222429ff4320f1..8130d62dccf3dd5c2227e6b22af405422f23ab53 100644 (file)
@@ -129,7 +129,7 @@ extern int scols_table_set_tree(struct libscols_table *tb, int enable);
 extern struct libscols_table *scols_new_table(struct libscols_symbols *syms);
 extern void scols_ref_table(struct libscols_table *tb);
 extern void scols_unref_table(struct libscols_table *tb);
-extern int scols_table_add_column(struct libscols_table *tb, struct libscols_column *cl);
+extern int scols_table_add_column(struct libscols_table *tb, struct libscols_column *cl, int flags);
 extern int scols_table_remove_column(struct libscols_table *tb, struct libscols_column *cl);
 extern int scols_table_remove_columns(struct libscols_table *tb);
 extern struct libscols_column *scols_table_new_column(struct libscols_table *tb, const char *name, double whint, int flags);
index bbbd5a59def23225703c47e09250df67bee88cb3..6b4d9673eb4af0572daa10299537284ecd8720ec 100644 (file)
@@ -73,7 +73,7 @@ void scols_unref_table(struct libscols_table *tb)
        }
 }
 
-int scols_table_add_column(struct libscols_table *tb, struct libscols_column *cl)
+int scols_table_add_column(struct libscols_table *tb, struct libscols_column *cl, int flags)
 {
        assert(tb);
        assert(cl);
@@ -81,6 +81,9 @@ int scols_table_add_column(struct libscols_table *tb, struct libscols_column *cl
        if (!tb || !cl || !list_empty(&tb->tb_lines))
                return -EINVAL;
 
+       if (flags & SCOLS_FL_TREE)
+               scols_table_set_tree(tb, 1);
+
        list_add_tail(&cl->cl_columns, &tb->tb_columns);
        cl->seqnum = tb->ncols++;
        scols_ref_column(cl);
@@ -182,10 +185,7 @@ struct libscols_column *scols_table_new_column(struct libscols_table *tb,
        scols_column_set_whint(cl, whint);
        scols_column_set_flags(cl, flags);
 
-       if (flags & SCOLS_FL_TREE)
-               scols_table_set_tree(tb, 1);
-
-       if (scols_table_add_column(tb, cl))     /* this increments column ref-counter */
+       if (scols_table_add_column(tb, cl, flags))      /* this increments column ref-counter */
                goto err;
 
        scols_unref_column(cl);
@@ -453,7 +453,7 @@ struct libscols_table *scols_copy_table(struct libscols_table *tb)
                cl = scols_copy_column(cl);
                if (!cl)
                        goto err;
-               if (scols_table_add_column(ret, cl))
+               if (scols_table_add_column(ret, cl, tb->tree ? SCOLS_FL_TREE : 0))
                        goto err;
                scols_unref_column(cl);
        }