]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Make pg_bsd_indent add a space between comma and period.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 13 May 2026 14:17:57 +0000 (10:17 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 13 May 2026 14:17:57 +0000 (10:17 -0400)
Formatting of variadic functions and struct literals with named fields
used to be ugly due to pg_bsd_indent treating period as always being a
binary operator.  After a comma, it's not that, so insert a space.

Bump pg_bsd_indent's version so that people who use out-of-tree
copies will know they need to update.  (This also covers the other
pg_bsd_indent behavioral change introduced in a3e6beba6.)

Author: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/c3327be8-09e2-46a1-88b4-228a339d6916@proxel.se

src/tools/pg_bsd_indent/args.c
src/tools/pg_bsd_indent/indent.c
src/tools/pg_bsd_indent/tests/declarations.0.stdout
src/tools/pg_bsd_indent/tests/struct.0
src/tools/pg_bsd_indent/tests/struct.0.stdout
src/tools/pgindent/pgindent

index 5fa7e6b038cc761a46fc89a9cde2af1551d8abfd..763a03a23b5bf74a7e855fc66d6c0cfe2f9ac1eb 100644 (file)
@@ -51,7 +51,7 @@ static char sccsid[] = "@(#)args.c    8.1 (Berkeley) 6/6/93";
 #include "indent_globs.h"
 #include "indent.h"
 
-#define INDENT_VERSION "2.1.2"
+#define INDENT_VERSION "2.1.3"
 
 /* profile types */
 #define        PRO_SPECIAL     1       /* special case */
index 736f350f145c47f891756046c40ebb2239c0e993..1a29409173b235dacad7cc331be35fbef02f657d 100644 (file)
@@ -1013,6 +1013,8 @@ check_type:
 
        case period:            /* treat a period kind of like a binary
                                 * operation */
+           if (ps.want_blank && ps.last_token == comma)
+               *e_code++ = ' ';
            *e_code++ = '.';    /* move the period into line */
            ps.want_blank = false;      /* don't put a blank after a period */
            break;
index ab5a447a8bc99672b252979587f6bbf586852685..baa6bb55c78737316c6e916b5f587c4320ddf755 100644 (file)
@@ -54,7 +54,7 @@ int_create(void)
 static
 _attribute_printf(1, 2)
 void
-print_error(const char *fmt,...)
+print_error(const char *fmt, ...)
 {
 
 }
index 83142bfb19729b9c0bd9e4790b20aec48585f55a..6f65e461331aec802c9a66ac8a6d65a71436e01e 100644 (file)
@@ -19,3 +19,5 @@ void u(struct x a) {
        int b;
        struct y c = (struct y *)&a;
 }
+
+static struct foo f = { .a = 1,.b=2 };
index 38613128654fb5d9e4dfead631fff3fa4bae9f07..69e321ca05fb342025a6a2c928169951f30983da 100644 (file)
@@ -21,3 +21,5 @@ u(struct x a)
        int             b;
        struct y        c = (struct y *)&a;
 }
+
+static struct foo f = {.a = 1, .b = 2};
index b2ec5e2914becfea5d136cae6de0cf5751c64c36..d035b53699bfd8fcd0a625a389f8c15cc0ef95f1 100755 (executable)
@@ -35,7 +35,7 @@ my $bak_to_cleanup;
 END { unlink $bak_to_cleanup if defined $bak_to_cleanup; }
 
 # Update for pg_bsd_indent version
-my $INDENT_VERSION = "2.1.2";
+my $INDENT_VERSION = "2.1.3";
 
 # Our standard indent settings
 my $indent_opts =