diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 19:22:57 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 19:22:57 +0000 |
commit | ce95875445c67808caa5d4fb0e6f80dbdaef0cb7 (patch) | |
tree | 6da8cbc66ef15086c9d295e4abe733b24818551e /libsmartcols/src/calculate.c | |
parent | Adding upstream version 2.40. (diff) | |
download | util-linux-4bbfa975b02931d2db389907a671eb006656a1d4.tar.xz util-linux-4bbfa975b02931d2db389907a671eb006656a1d4.zip |
Adding upstream version 2.40.1.upstream/2.40.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libsmartcols/src/calculate.c')
-rw-r--r-- | libsmartcols/src/calculate.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/libsmartcols/src/calculate.c b/libsmartcols/src/calculate.c index 84198da..86e1b27 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 */ @@ -413,10 +418,8 @@ int __scols_calculate(struct libscols_table *tb, struct ul_buffer *buf) size_t colsepsz; int sorted = 0; - DBG(TAB, ul_debugobj(tb, "-----calculate-(termwidth=%zu)-----", tb->termwidth)); tb->is_dummy_print = 1; - colsepsz = scols_table_is_noencoding(tb) ? mbs_width(colsep(tb)) : mbs_safe_width(colsep(tb)); @@ -430,6 +433,11 @@ int __scols_calculate(struct libscols_table *tb, struct ul_buffer *buf) while (scols_table_next_column(tb, &itr, &cl) == 0) { int is_last; + memset(&cl->wstat, 0, sizeof(cl->wstat)); + cl->width = 0; + cl->width_treeart = 0; + scols_column_reset_wrap(cl); + if (scols_column_is_hidden(cl)) continue; |