summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/column.c
diff options
context:
space:
mode:
authorIgor Gnatenko2016-01-16 22:51:52 +0100
committerIgor Gnatenko2016-01-17 09:44:09 +0100
commitd10fa7e6dd2b936edcfc5e6ab78687e60e57b46a (patch)
treeedcff3a9bca0f529f89cf53b0d3632cde3af9226 /libsmartcols/src/column.c
parentfstrim: add reference to blkdiscard (diff)
downloadkernel-qcow2-util-linux-d10fa7e6dd2b936edcfc5e6ab78687e60e57b46a.tar.gz
kernel-qcow2-util-linux-d10fa7e6dd2b936edcfc5e6ab78687e60e57b46a.tar.xz
kernel-qcow2-util-linux-d10fa7e6dd2b936edcfc5e6ab78687e60e57b46a.zip
libsmartcols: reflect changinging SCOLS_FL_TREE after adding to table
When scols_column_set_flags() is called we will compare before & after status of SCOLS_FL_TREE flag and appropriately handle tb->ntreecols. Reference: https://github.com/karelzak/util-linux/issues/254 Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Diffstat (limited to 'libsmartcols/src/column.c')
-rw-r--r--libsmartcols/src/column.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libsmartcols/src/column.c b/libsmartcols/src/column.c
index 269ceea0c..b31b39063 100644
--- a/libsmartcols/src/column.c
+++ b/libsmartcols/src/column.c
@@ -157,6 +157,13 @@ int scols_column_set_flags(struct libscols_column *cl, int flags)
if (!cl)
return -EINVAL;
+ if (cl->table) {
+ if (!(cl->flags & SCOLS_FL_TREE) && (flags & SCOLS_FL_TREE))
+ cl->table->ntreecols++;
+ else if ((cl->flags & SCOLS_FL_TREE) && !(flags & SCOLS_FL_TREE))
+ cl->table->ntreecols--;
+ }
+
cl->flags = flags;
return 0;
}