]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libsmartcols: introduce default sort column
authorKarel Zak <kzak@redhat.com>
Wed, 24 Mar 2021 11:43:17 +0000 (12:43 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 24 Mar 2021 11:43:17 +0000 (12:43 +0100)
commit529b51706ef06611a8165023f14e6593e06901de
treeddb1a3e65d0ba5445fa72db72b4826e49a8be360
parentc59d442809ebb51b6bde17c541e51253fc2cba5b
libsmartcols: introduce default sort column

* add default sort column, set by scols_sort_table()

* sort tree according to default sort column also in scols_sort_table_by_tree()

The function scols_sort_table() does not sort tree branches if tree
is not enabled. The function scols_sort_table_by_tree() does not care
if tree is enabled and it always follows parent->child relations. For
scols_sort_table_by_tree() we need to follow order in branches if
previously scols_sort_table() has been called.

For example lsblk calls

scols_sort_table(tb, cl);
scols_sort_table_by_tree(tb);

for list-like output (for example lsblk -P) and users assume the
same order as for tree (lsblk --tree).

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1940607
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/smartcolsP.h
libsmartcols/src/table.c