]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: fix right-aligned logic for last column
authorKarel Zak <kzak@redhat.com>
Mon, 7 Dec 2015 14:10:23 +0000 (15:10 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 7 Dec 2015 14:10:23 +0000 (15:10 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/table_print.c

index 91234b16a3b4e6974fb00b4ce6e4db0bbe8cfecb..d275ad640e328c8726bb8161cc43c1c3009e2061 100644 (file)
@@ -324,7 +324,10 @@ static int print_data(struct libscols_table *tb,
        width = cl->width;
        bytes = strlen(data);
 
-       if (is_last_column(tb, cl) && len < width && !scols_table_is_maxout(tb))
+       if (is_last_column(tb, cl)
+           && len < width
+           && !scols_table_is_maxout(tb)
+           && !scols_column_is_right(cl))
                width = len;
 
        /* truncate data */
@@ -340,7 +343,6 @@ static int print_data(struct libscols_table *tb,
 
        if (data) {
                if (scols_column_is_right(cl)) {
-                       size_t xw = cl->width;
                        if (color)
                                fputs(color, tb->out);
                        for (i = len; i < width; i++)
@@ -348,8 +350,7 @@ static int print_data(struct libscols_table *tb,
                        fputs(data, tb->out);
                        if (color)
                                fputs(UL_COLOR_RESET, tb->out);
-                       if (len < xw)
-                               len = xw;
+                       len = width;
                } else if (color) {
                        char *p = data;
                        size_t art = buffer_get_safe_art_size(buf);