From: Karel Zak Date: Tue, 20 Mar 2012 09:42:03 +0000 (+0100) Subject: lib/tt: work more sensitive with large columns X-Git-Tag: v2.22-rc1~640 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6318686396e651f2b722a09940897f5b0120e8a;p=thirdparty%2Futil-linux.git lib/tt: work more sensitive with large columns Signed-off-by: Karel Zak --- diff --git a/lib/tt.c b/lib/tt.c index 16a0098bfd..8d5f7ab64f 100644 --- a/lib/tt.c +++ b/lib/tt.c @@ -448,7 +448,7 @@ static void recount_widths(struct tt *tb, char *buf, size_t bufsz) } if (width < tb->termwidth) { - /* cool, use the extra space for the extreme columns or/and last column + /* try to found extreme column which fits into available space */ if (extremes) { /* enlarge the first extreme column */ @@ -459,6 +459,12 @@ static void recount_widths(struct tt *tb, char *buf, size_t bufsz) if (!cl->is_extreme) continue; + + if (cl->width_max - cl->width > + (tb->termwidth - width)) + /* this column is tooo large, ignore */ + continue; + add = tb->termwidth - width; if (add && cl->width + add > cl->width_max) add = cl->width_max - cl->width;