public inbox for [email protected]
help / color / mirror / Atom feedFrom: Bruce Momjian <[email protected]>
To: Jelte Fennema <[email protected]>
Cc: Magnus Hagander <[email protected]>
Cc: Alvaro Herrera <[email protected]>
Cc: Stephen Frost <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: Noah Misch <[email protected]>
Cc: Jesse Zhang <[email protected]>
Cc: Andres Freund <[email protected]>
Cc: PostgreSQL-development <[email protected]>
Subject: Re: run pgindent on a regular basis / scripted manner
Date: Sat, 21 Jan 2023 12:30:32 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAGECzQQs+hz4uQSmD_8oRLr74GtxpE0iXuYE85+RHAzvkF_yvQ@mail.gmail.com>
References: <CABUevExkB=+FX5Ht2sU6Tmk1fF0h8LqugW5camQ-r00ftPZoSg@mail.gmail.com>
<[email protected]>
<CABUevEwGPPaUtObrDywO+vhpFDTJXO+-aeWJd7D46uXTE2sQpA@mail.gmail.com>
<CAGECzQQs+hz4uQSmD_8oRLr74GtxpE0iXuYE85+RHAzvkF_yvQ@mail.gmail.com>
On Fri, Jan 20, 2023 at 10:43:50AM +0100, Jelte Fennema wrote:
> Side-question: What's the reason why pgindent is used instead of some
> more "modern" code formatter that doesn't require keeping
> typedefs.list up to date for good looking output? (e.g. uncrustify or
> clang-format) Because that would also allow for easy editor
> integration.
One reason the typedef list is required is a quirk of the C syntax.
Most languages have a lexer/scanner, which tokenizes, and a parser,
which parses. The communication is usually one-way, lexer to parser.
For C, typedefs require the parser to feed new typedefs back into the
lexer:
http://calculist.blogspot.com/2009/02/c-typedef-parsing-problem.html
BSD indent doesn't have that feedback mechanism, probably because it
doesn't fully parse the C file. Therefore, we have to supply typedefs
manually, and for Postgres we pull them from debug-enabled binaries in
our buildfarm. The problem with that is you often import typedefs from
system headers, and the typedefs apply to all C files, not just the ones
were the typdefs are visible.
I don't see uncrustify or clang-format supporting typedef lists so maybe
they implemented this feedback loop. It would be good to see if we can
get either of these tools to match our formatting.
--
Bruce Momjian <[email protected]> https://momjian.us
EDB https://enterprisedb.com
Embrace your flaws. They make you human, rather than perfect,
which you will never be.
view thread (11+ messages) latest in thread
reply
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: run pgindent on a regular basis / scripted manner
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox