]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: fix padding for non-maxout output
authorKarel Zak <kzak@redhat.com>
Tue, 6 Sep 2016 11:34:07 +0000 (13:34 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 6 Sep 2016 11:34:07 +0000 (13:34 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/table_print.c

index 8981f821c474055d9c987e9e71ff40253041e63f..7c66d704c9c32d8c4b51820b885bd697659fa232 100644 (file)
@@ -243,12 +243,15 @@ static void print_empty_cell(struct libscols_table *tb,
                        }
                }
        }
+
+       if (!is_last_column(cl))
+               return;
+
        /* fill rest of cell with space */
        for(; len_pad < cl->width; ++len_pad)
                fputc(' ', tb->out);
 
-       if (!is_last_column(cl))
-               fputs(colsep(tb), tb->out);
+       fputs(colsep(tb), tb->out);
 }
 
 
@@ -377,12 +380,12 @@ static int print_pending_data(
                fputs(UL_COLOR_RESET, tb->out);
        free(data);
 
-       for (i = len; i < width; i++)
-               fputc(' ', tb->out);            /* padding */
-
        if (is_last_column(cl))
                return 0;
 
+       for (i = len; i < width; i++)
+               fputc(' ', tb->out);            /* padding */
+
        fputs(colsep(tb), tb->out);             /* columns separator */
        return 0;
 err:
@@ -452,8 +455,7 @@ static int print_data(struct libscols_table *tb,
        if (is_last_column(cl)
            && len < width
            && !scols_table_is_maxout(tb)
-           && !scols_column_is_right(cl)
-           && !scols_column_is_wrap(cl))
+           && !scols_column_is_right(cl))
                width = len;
 
        /* truncate data */