Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Aleksander Alekseev <aleksander(at)tigerdata(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Arseniy Mukhin <arseniy(dot)mukhin(dot)dev(at)gmail(dot)com>
Subject: Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments
Date: 2025-12-21 22:33:15
Message-ID: aUh1q5twC8WqXATK@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 19, 2025 at 03:02:12PM -0500, Bruce Momjian wrote:
> On Fri, Dec 12, 2025 at 11:17:01AM -0500, Tom Lane wrote:
>> =?utf-8?Q?=C3=81lvaro?= Herrera <alvherre(at)kurilemu(dot)de> writes:
>>> It's strange to see this thread go on about messing with the Perl script
>>> because we're too afraid of pg_bsd_indent. Maybe we should take
>>> ownership of that code -- improve its own indentation to our
>>> conventions, add comments, rename unclear variables, and so on until we
>>> have something we can work with, and fix these weird bugs and
>>> idiosincratic behaviors we don't like. I just found out this code dates
>>> back from 1976.
>>
>> I've worked with that code a little bit, and it's mostly unreadable
>> spaghetti :-(. If somebody wants to make an effort to make it not
>> so awful, that'd be great, but I fear it's a very nontrivial project.
>
> Yes, this is why we had to wrap the pg_bsd_indent call in Perl.

Removing one layer, finishing with only a C function or a perl script
would be really nice. I am wondering if removing the perl script
would not be the way to go, just owning the portion of the code we
care about, which is already in the tree anyway.

From what I can see, we rely on a set of options through $indent_opts,
it seems like one would enter a fail-and-retry repeat loop until
things get rather right:
- Remove as much code from pg_bsd_indent as possible.
- Integrate some of the options in the perl script into the binary.

If the binary gets slim enough and more understandable, perhaps we
could even keep both, we have all the pgtypedef business which is
specific to the Postgres tree as well.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-12-21 22:48:54 Re: [PATCH] O_CLOEXEC not honored on Windows - handle inheritance chain
Previous Message Michael Paquier 2025-12-21 22:22:25 Re: [PATCH v1] Fixed a spelling error in the comments in gininsert.c