diff options
author | Ondrej Oprala <ooprala@redhat.com> | 2014-03-25 10:24:13 +0100 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2014-04-03 12:29:18 +0200 |
commit | b72b824d06a03785494f026196241aa119e63c15 (patch) | |
tree | f08fdb7f5b9cb3ec90863bc7c2f530eb21af5c98 /libsmartcols | |
parent | 8b992cb5719e7632dd8bc904cb5bfb3720207739 (diff) | |
download | util-linux-b72b824d06a03785494f026196241aa119e63c15.tar.gz |
libsmartcols: move some code around
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Diffstat (limited to 'libsmartcols')
-rw-r--r-- | libsmartcols/src/libsmartcols.h.in | 2 | ||||
-rw-r--r-- | libsmartcols/src/table.c | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/libsmartcols/src/libsmartcols.h.in b/libsmartcols/src/libsmartcols.h.in index 54a623c43..8130d62dc 100644 --- a/libsmartcols/src/libsmartcols.h.in +++ b/libsmartcols/src/libsmartcols.h.in @@ -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); diff --git a/libsmartcols/src/table.c b/libsmartcols/src/table.c index bbbd5a59d..6b4d9673e 100644 --- a/libsmartcols/src/table.c +++ b/libsmartcols/src/table.c @@ -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); } |