v2-0001-Make-pgindent-add-a-space-between-comma-and-perio.patch

text/x-patch

Filename: v2-0001-Make-pgindent-add-a-space-between-comma-and-perio.patch
Type: text/x-patch
Part: 0
Message: Re: Improve pgindent's formatting named fields in struct literals and varidic functions

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: format-patch
Series: patch v2-0001
Subject: Make pgindent add a space between comma and period
File+
src/tools/pg_bsd_indent/indent.c 2 0
From 2e78d6b114c7276e4560edae72bfdc56830b0749 Mon Sep 17 00:00:00 2001
From: Andreas Karlsson <andreas@proxel.se>
Date: Tue, 17 Feb 2026 09:04:01 +0100
Subject: [PATCH v2 1/2] Make pgindent add a space between comma and period

Formatting of varidic functions and struct literals with named field
used to be ugly due to pgindent treaing period as always being binary
operator for struct access, but after comma it has a different meaning.
---
 src/tools/pg_bsd_indent/indent.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/tools/pg_bsd_indent/indent.c b/src/tools/pg_bsd_indent/indent.c
index 421592db928..58fa04293d9 100644
--- a/src/tools/pg_bsd_indent/indent.c
+++ b/src/tools/pg_bsd_indent/indent.c
@@ -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;	/* dont put a blank after a period */
 	    break;
-- 
2.47.3