]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/tt: work more sensitive with large columns
authorKarel Zak <kzak@redhat.com>
Tue, 20 Mar 2012 09:42:03 +0000 (10:42 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 20 Mar 2012 09:42:03 +0000 (10:42 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/tt.c

index 16a0098bfd2151cf9af91fe73b9e53496dd11bfe..8d5f7ab64fd46b352994b3c4486d9c454381c035 100644 (file)
--- 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;