Improve pgindent's formatting named fields in struct literals and varidic functions

Andreas Karlsson <andreas@proxel.se>

From: Andreas Karlsson <andreas@proxel.se>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-02-17T08:09:05Z
Lists: pgsql-hackers

Attachments

Hi,

A personal pet peeve of mine has been how pgindent formats struct 
literals with named fields, for example the below:

static RBTNode sentinel =
{
     .color = RBTBLACK,.left = RBTNIL,.right = RBTNIL,.parent = NULL
};

The attached patch fixes the formatting to be nicer:

static RBTNode sentinel =
{
     .color = RBTBLACK, .left = RBTNIL, .right = RBTNIL, .parent = NULL
};

It is currently the only example but I mainly think that is because the 
current formatting looks ugly so we avoid putting struct literals on a 
single line. Plus I have seen this formatting in PostgreSQL extensions.

While fixing this personal annoyance I noticed that my fix also would 
fix the formatting of varidic functions. For example:

-errdetail(const char *fmt,...)
+errdetail(const char *fmt, ...)

What do you think? I think both are clear improvements to the 
readability and that the churn is not big enough to be an issue.

Andreas

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Make pg_bsd_indent add a space between comma and period.