From 77a94efb5eaa0aadba2a45214131be81974bb45e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 6 Sep 2016 13:01:09 +0200 Subject: [PATCH] libsmartcols: fix padding for non-maxout output Signed-off-by: Karel Zak --- libsmartcols/src/table_print.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libsmartcols/src/table_print.c b/libsmartcols/src/table_print.c index 4d902b1d6a..32b9ddab15 100644 --- a/libsmartcols/src/table_print.c +++ b/libsmartcols/src/table_print.c @@ -242,12 +242,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); } @@ -386,12 +389,13 @@ static int print_pending_data( fputs(UL_COLOR_RESET, tb->out); free(data); + if (is_last_column(cl)) + return 0; + for (i = len; i < width; i++) fputc(' ', tb->out); /* padding */ - if (!is_last_column(cl)) - fputs(colsep(tb), tb->out); /* columns separator */ - + fputs(colsep(tb), tb->out); /* columns separator */ return 0; err: free(data); @@ -472,9 +476,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_wrapnl(cl)) + && !scols_column_is_right(cl)) width = len; /* truncate data */ -- 2.47.3