Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3f9d2ed

Browse files
committed
Restore previous psql behavior of not printing useless trailing spaces
after the data in the last column on a line.
1 parent 07bae9c commit 3f9d2ed

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/bin/psql/print.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.82 2006/02/10 22:29:06 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.83 2006/02/12 02:56:21 tgl Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "common.h"
@@ -573,11 +573,15 @@ print_aligned_text(const char *title, const char *const * headers,
573573
for (j = 0; j < col_count; j++)
574574
{
575575
struct lineptr *this_line = col_lineptrs[j] + line_count;
576+
bool finalspaces = (opt_border == 2 || j != col_count-1);
577+
576578
if (complete[j]) /* Just print spaces... */
577-
fprintf(fout, "%*s", widths[j], "");
579+
{
580+
if (finalspaces)
581+
fprintf(fout, "%*s", widths[j], "");
582+
}
578583
else
579584
{
580-
581585
/* content */
582586
if (opt_align[j] == 'r')
583587
{
@@ -602,7 +606,7 @@ print_aligned_text(const char *title, const char *const * headers,
602606
}
603607
else
604608
fprintf(fout, "%-s%*s", this_line->ptr,
605-
widths[j] - this_line->width, "");
609+
finalspaces ? (widths[j] - this_line->width) : 0, "");
606610
/* If at the right height, done this col */
607611
if (line_count == heights[j]-1 || !this_line[1].ptr)
608612
{

0 commit comments

Comments
 (0)