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 <br...@momjian.us> https://momjian.us EDB https://enterprisedb.com Embrace your flaws. They make you human, rather than perfect, which you will never be.