Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jbtrM-0004ZJ-RC for pgsql-hackers@arkaria.postgresql.org; Thu, 21 May 2020 22:40:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jbtrJ-0003Wj-OD for pgsql-hackers@arkaria.postgresql.org; Thu, 21 May 2020 22:40:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jbtrJ-0003Wc-Hz for pgsql-hackers@lists.postgresql.org; Thu, 21 May 2020 22:40:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jbtrG-0004S1-VH for pgsql-hackers@lists.postgresql.org; Thu, 21 May 2020 22:40:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 04LMe6vQ017362; Thu, 21 May 2020 18:40:07 -0400 From: Tom Lane To: Piotr Stefaniak cc: Thomas Munro , Alvaro Herrera , Pg Hackers Subject: Re: pgindent && weirdness In-reply-to: References: <20200114221814.GA19630@alvherre.pgsql> <6012.1579041021@sss.pgh.pa.us> Comments: In-reply-to Piotr Stefaniak message dated "Thu, 21 May 2020 23:33:16 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17360.1590100806.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 21 May 2020 18:40:06 -0400 Message-ID: <17361.1590100806@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Piotr Stefaniak 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=3Dpostgresql.git;a=3Dcommitdiff;h=3Df= a27dd40d5c5f56a1ee837a75c97549e992e32a4 and while certainly most of the diffs are around && or || operators, there are a fair number that are not, such as - dummy_lex.input =3D unconstify(char *, str) +1; + dummy_lex.input =3D unconstify(char *, str) + 1; or more interestingly - strncmp(text, "pg_", 3) !=3D0) + strncmp(text, "pg_", 3) !=3D 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