@@ -692,7 +692,7 @@ print_aligned_text(const printTableContent *cont, FILE *fout)
692692 if (opt_border == 0 )
693693 width_total = col_count ;
694694 else if (opt_border == 1 )
695- width_total = col_count * 3 - 1 ;
695+ width_total = col_count * 3 - (( col_count > 0 ) ? 1 : 0 ) ;
696696 else
697697 width_total = col_count * 3 + 1 ;
698698 total_header_width = width_total ;
@@ -928,7 +928,7 @@ print_aligned_text(const printTableContent *cont, FILE *fout)
928928 fputs (!header_done [i ] ? format -> header_nl_right : " " ,
929929 fout );
930930
931- if (opt_border != 0 && i < col_count - 1 )
931+ if (opt_border != 0 && col_count > 0 && i < col_count - 1 )
932932 fputs (dformat -> midvrule , fout );
933933 }
934934 curr_nl_line ++ ;
@@ -983,7 +983,8 @@ print_aligned_text(const printTableContent *cont, FILE *fout)
983983 struct lineptr * this_line = & col_lineptrs [j ][curr_nl_line [j ]];
984984 int bytes_to_output ;
985985 int chars_to_output = width_wrap [j ];
986- bool finalspaces = (opt_border == 2 || j < col_count - 1 );
986+ bool finalspaces = (opt_border == 2 ||
987+ (col_count > 0 && j < col_count - 1 ));
987988
988989 /* Print left-hand wrap or newline mark */
989990 if (opt_border != 0 )
@@ -1077,11 +1078,11 @@ print_aligned_text(const printTableContent *cont, FILE *fout)
10771078 fputs (format -> wrap_right , fout );
10781079 else if (wrap [j ] == PRINT_LINE_WRAP_NEWLINE )
10791080 fputs (format -> nl_right , fout );
1080- else if (opt_border == 2 || j < col_count - 1 )
1081+ else if (opt_border == 2 || ( col_count > 0 && j < col_count - 1 ) )
10811082 fputc (' ' , fout );
10821083
10831084 /* Print column divider, if not the last column */
1084- if (opt_border != 0 && j < col_count - 1 )
1085+ if (opt_border != 0 && ( col_count > 0 && j < col_count - 1 ) )
10851086 {
10861087 if (wrap [j + 1 ] == PRINT_LINE_WRAP_WRAP )
10871088 fputs (format -> midvrule_wrap , fout );
@@ -1236,8 +1237,18 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout)
12361237 if (cont -> cells [0 ] == NULL && cont -> opt -> start_table &&
12371238 cont -> opt -> stop_table )
12381239 {
1239- if (!opt_tuples_only && cont -> opt -> default_footer )
1240- fprintf (fout , _ ("(No rows)\n" ));
1240+ printTableFooter * footers = footers_with_default (cont );
1241+
1242+ if (!opt_tuples_only && !cancel_pressed && footers )
1243+ {
1244+ printTableFooter * f ;
1245+
1246+ for (f = footers ; f ; f = f -> next )
1247+ fprintf (fout , "%s\n" , f -> data );
1248+ }
1249+
1250+ fputc ('\n' , fout );
1251+
12411252 return ;
12421253 }
12431254
0 commit comments