]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: set minimal column width to 1
authorKarel Zak <kzak@redhat.com>
Thu, 15 Feb 2018 10:58:41 +0000 (11:58 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 15 Feb 2018 11:20:17 +0000 (12:20 +0100)
The default is to use header width or relative width setting as the
minimal column width. The problem are columns where is no header or
relative width. Let's set minimal width to 1 in this case.

Addresses: https://github.com/karelzak/util-linux/pull/577
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/table_print.c

index b0b5b6c81f6660ed9fe7510a571abdf308cf083b..5d61732991fffc941e29775705c798bb149d9506 100644 (file)
@@ -1068,6 +1068,8 @@ static int count_column_width(struct libscols_table *tb,
                        size_t len = mbs_safe_width(scols_cell_get_data(&cl->header));
                        cl->width_min = max(cl->width_min, len);
                }
+               if (!cl->width_min)
+                       cl->width_min = 1;
        }
 
        scols_reset_iter(&itr, SCOLS_ITER_FORWARD);