| From: | Andreas Karlsson <andreas(at)proxel(dot)se> |
|---|---|
| To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Improve pgindent's formatting named fields in struct literals and varidic functions |
| Date: | 2026-02-17 08:09:05 |
| Message-ID: | c3327be8-09e2-46a1-88b4-228a339d6916@proxel.se |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Make-pgindent-add-a-space-between-comma-and-perio.patch | text/x-patch | 1.0 KB |
| v1-0002-Run-pgindent-add-a-space-between-comma-and-period.patch | text/x-patch | 66.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrei Lepikhov | 2026-02-17 08:09:30 | Re: Add into REFRESH PUBLICATION parameter exception_behaviour |
| Previous Message | Zsolt Parragi | 2026-02-17 08:00:32 | Re: Fix uninitialized xl_running_xacts padding |