]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include: [tt.c] always truncate if TT_FL_TRUNC
authorKarel Zak <kzak@redhat.com>
Fri, 15 Jul 2011 13:35:48 +0000 (15:35 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 15 Jul 2011 13:35:48 +0000 (15:35 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/tt.c

index 1929a48cfe5e51ee8d3c736a2c51819f79422880..576d2b36a7b661a4964d91a6504c06f4f0d32eaf 100644 (file)
--- a/lib/tt.c
+++ b/lib/tt.c
@@ -414,7 +414,7 @@ static void recount_widths(struct tt *tb, char *buf, size_t bufsz)
 
                        if (width <= tb->termwidth)
                                break;
-                       if (cl->width_hint > 1)
+                       if (cl->width_hint > 1 && !(cl->flags & TT_FL_TRUNC))
                                continue;       /* never truncate columns with absolute sizes */
                        if (cl->flags & TT_FL_TREE)
                                continue;       /* never truncate the tree */
@@ -422,7 +422,15 @@ static void recount_widths(struct tt *tb, char *buf, size_t bufsz)
                                continue;
                        if (cl->width == cl->width_min)
                                continue;
-                       if (cl->width > cl->width_hint * tb->termwidth) {
+
+                       /* truncate column with relative sizes */
+                       if (cl->width_hint < 1 &&
+                           cl->width > cl->width_hint * tb->termwidth) {
+                               cl->width--;
+                               width--;
+                       }
+                       /* truncate column with absolute size */
+                       if (cl->width_hint > 1 && !trunc_only) {
                                cl->width--;
                                width--;
                        }