summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarel Zak2011-07-15 15:35:48 +0200
committerKarel Zak2011-07-15 15:35:48 +0200
commit24563aea022cf94d1589c22f694f636a8dd2078d (patch)
tree349ce520c5a84a18d411e24bcf7cce84af39a9cc /lib
parentlsblk: add state attribute (diff)
downloadkernel-qcow2-util-linux-24563aea022cf94d1589c22f694f636a8dd2078d.tar.gz
kernel-qcow2-util-linux-24563aea022cf94d1589c22f694f636a8dd2078d.tar.xz
kernel-qcow2-util-linux-24563aea022cf94d1589c22f694f636a8dd2078d.zip
include: [tt.c] always truncate if TT_FL_TRUNC
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/tt.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/tt.c b/lib/tt.c
index 1929a48cf..576d2b36a 100644
--- 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--;
}