Re: Run pgindent now?

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Andres Freund <andres(at)anarazel(dot)de>, Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Run pgindent now?
Date: 2015-05-27 00:25:24
Message-ID: 55650EF4.9040300@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 5/25/15 7:15 PM, Andres Freund wrote:
> On 2015-05-25 19:01:28 -0400, Bruce Momjian wrote:
>>> A longer-term fix would be to make pgindent less stupid about this sort
>>> of usage, but nobody's yet volunteered to dig into the guts of that code.
>>
>> I assume a typedefs list is going to be a requirement of any decent C
>> indenting tool.
>
> Maybe I'm missing something major here, but why? Afaict it's just only
> used for formatting decisions that could be made without it just as well?

AFAICT, the main reason is to decide whether * and & are binary infix or
unary prefix operators. Otherwise, it wouldn't know whether to write

char * foo;

or the more customary

char *foo;

Now, running pgindent without a typedefs list also makes it do things like

static int32
-makepol(QPRS_STATE *state)
+makepol(QPRS_STATE * state)

which, one might argue, it could figure out without a typedefs list.
But then the formatting would be inconsistent between prototypes and
variable declarations, which might drive people crazy. I don't know
whether there is a better way than living with it, one way or the other
(i.e., requiring a types list, or accepting slightly odd formatting).

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2015-05-27 00:31:07 Re: Run pgindent now?
Previous Message Jeff Janes 2015-05-27 00:19:31 Re: optimizing vacuum truncation scans