From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Jelte Fennema <postgres(at)jeltef(dot)nl> |
Cc: | Magnus Hagander <magnus(at)hagander(dot)net>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, Jesse Zhang <sbjesse(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: run pgindent on a regular basis / scripted manner |
Date: | 2023-01-21 17:30:32 |
Message-ID: | Y8whOD51K2ZlcaFz@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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 <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com
Embrace your flaws. They make you human, rather than perfect,
which you will never be.
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2023-01-21 17:37:30 | Re: Unicode grapheme clusters |
Previous Message | Tom Lane | 2023-01-21 16:30:08 | Re: Unicode grapheme clusters |