diff options
author | Karel Zak <kzak@redhat.com> | 2024-05-01 21:23:03 +0200 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2024-05-01 21:23:03 +0200 |
commit | e3192bfd1dd129c70f5416e1464135d8cd22c956 (patch) | |
tree | e14aedf94c9f451fda4c770b74c687ee1af707b1 | |
parent | f4975bf1bb864dfcb976d32fae49bbe48003b732 (diff) | |
parent | 28c7c29b2d57705fdc4ff486b38937c73b2d9b5d (diff) | |
download | util-linux-e3192bfd1dd129c70f5416e1464135d8cd22c956.tar.gz |
Merge branch 'PR/libsmartcols-reduce-fix' of github.com:karelzak/util-linux-work
* 'PR/libsmartcols-reduce-fix' of github.com:karelzak/util-linux-work:
libsmartcols: fix column reduction
-rw-r--r-- | libsmartcols/src/calculate.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libsmartcols/src/calculate.c b/libsmartcols/src/calculate.c index deabb0794c..86e1b27992 100644 --- a/libsmartcols/src/calculate.c +++ b/libsmartcols/src/calculate.c @@ -379,9 +379,14 @@ static int reduce_column(struct libscols_table *tb, /* columns are reduced in "bad first" way, be more * agresive for the the worst column */ reduce = 3; - if (cl->width - reduce < st->width_min) - reduce = cl->width - st->width_min; - cl->width -= reduce; + + if (cl->width < reduce) + reduce = cl->width; + + if (cl->width - reduce > st->width_min) + cl->width -= reduce; + else + cl->width = st->width_min; break; default: return -1; /* no more stages */ |