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>
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;
}
struct libscols_cell header;
struct list_head cl_columns;
+
+ struct libscols_table *table;
};
/*
DBG(TAB, ul_debugobj(tb, "add column %p", cl));
list_add_tail(&cl->cl_columns, &tb->tb_columns);
cl->seqnum = tb->ncols++;
+ cl->table = tb;
scols_ref_column(cl);
/* TODO:
DBG(TAB, ul_debugobj(tb, "remove column %p", cl));
list_del_init(&cl->cl_columns);
tb->ncols--;
+ cl->table = NULL;
scols_unref_column(cl);
return 0;
}