psql-table-whitespace.patch

text/x-patch

Filename: psql-table-whitespace.patch
Type: text/x-patch
Part: 0
Message: trailing whitespace in psql table output

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/bin/psql/print.c 8 4
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index e55404b..da23b7b 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -817,20 +817,24 @@ print_aligned_text(const printTableContent *cont, FILE *fout)
 						nbspace = width_wrap[i] - this_line->width;
 
 						/* centered */
-						fprintf(fout, "%-*s%s%-*s",
-								nbspace / 2, "", this_line->ptr, (nbspace + 1) / 2, "");
+						fprintf(fout, "%-*s%s",
+								nbspace / 2, "", this_line->ptr);
 
 						if (!(this_line + 1)->ptr)
 						{
 							more_col_wrapping--;
-							header_done[i] = 1;
+							header_done[i] = true;
 						}
+
+						if (i < cont->ncolumns - 1 || !header_done[i])
+							fprintf(fout, "%-*s",
+									(nbspace + 1) / 2, "");
 					}
 					else
 						fprintf(fout, "%*s", width_wrap[i], "");
 
 					if (opt_border != 0 || format->wrap_right_border == true)
-						fputs(!header_done[i] ? format->header_nl_right : " ",
+						fputs(!header_done[i] ? format->header_nl_right : (i < cont->ncolumns -1 ? " " : ""),
 							  fout);
 
 					if (opt_border != 0 && i < col_count - 1)