From: Tom Lane <tgl@sss.pgh.pa.us>
To: Piotr Stefaniak <postgres@piotr-stefaniak.me>
Cc: Thomas Munro <thomas.munro@gmail.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: pgindent && weirdness
Date: Thu, 21 May 2020 18:40:06 -0400
Message-ID: <17361.1590100806@sss.pgh.pa.us> (raw)
In-Reply-To: <VE1P192MB07504EB33625F9A23F41CCD0F2B70@VE1P192MB0750.EURP192.PROD.OUTLOOK.COM>
References: <20200114221814.GA19630@alvherre.pgsql>
<6012.1579041021@sss.pgh.pa.us>
<CA+hUKGLt44_RT=R1o18PiU9zPePzngd5mbLeHsuba6wkjxURvg@mail.gmail.com>
<VE1P192MB07504EB33625F9A23F41CCD0F2B70@VE1P192MB0750.EURP192.PROD.OUTLOOK.COM>
Piotr Stefaniak <postgres@piotr-stefaniak.me> <VE1P192MB07504EB33625F9A23F41CCD0F2B70@VE1P192MB0750.EURP192.PROD.OUTLOOK.COM> writes:
> On 16/01/2020 03.59, Thomas Munro wrote:
>> One way to fix that in the cases Alvaro is referring to is to tell
>> override the setting so that && (and likewise ||) are never considered
>> to be unary, though I haven't tested this much and there are surely
>> other ways to achieve this:
> I think this is a better approach then the one committed to
> pg_bsd_indent. It's ubiquitous that the operators are binary, except -
> as you mentioned - in a nonstandard GCC syntax. The alternative given
> has more disadvantages, with potential impact on FreeBSD code
> formatting, which it should support as well as everything else -- to a
> reasonable extent. sys/kern/ is usually a decent litmus test, but I
> don't claim it should show anything interesting in this particular case.
I think that the fix we chose is better, at least for our purposes.
You can see its effects on our source tree at
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=fa27dd40d5c5f56a1ee837a75c97549e9...
and while certainly most of the diffs are around && or || operators,
there are a fair number that are not, such as
- dummy_lex.input = unconstify(char *, str) +1;
+ dummy_lex.input = unconstify(char *, str) + 1;
or more interestingly
- strncmp(text, "pg_", 3) !=0)
+ strncmp(text, "pg_", 3) != 0)
where the previous misformatting is because "text" is a known typedef
name. So it appears to me that this change reduces the misformatting
cost of typedef names that chance to match field or variable names,
and that's actually quite a big issue for us. We have, ATM, 3574 known
typedefs in typedefs.list, a fair number of which are not under our
control (since they come from system headers on various platforms).
So it's inevitable that there are going to be collisions.
In short, I'm inclined to stick with the hack we've got. I'm sad that
it will result in further divergence from FreeBSD indent; but it does
useful stuff for us, and I don't want to give it up.
(That said, I don't see any penalty to carrying both changes; so we'll
probably also absorb the &&/|| change at some convenient time.)
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, postgres@piotr-stefaniak.me, thomas.munro@gmail.com, alvherre@2ndquadrant.com
Subject: Re: pgindent && weirdness
In-Reply-To: <17361.1590100806@sss.pgh.pa.us>
References: <20200114221814.GA19630@alvherre.pgsql> <6012.1579041021@sss.pgh.pa.us> <CA+hUKGLt44_RT=R1o18PiU9zPePzngd5mbLeHsuba6wkjxURvg@mail.gmail.com> <VE1P192MB07504EB33625F9A23F41CCD0F2B70@VE1P192MB0750.EURP192.PROD.OUTLOOK.COM> <17361.1590100806@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox