Re: pg_bsd_indent: implement -lps ("leave preprocessor space")

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_bsd_indent: implement -lps ("leave preprocessor space")
Date: 2017-02-08 19:01:03
Message-ID: 20170208190103.obudn4xxuo2guqw3@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2017-02-07 23:30:44 -0500, Tom Lane wrote:
> Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me> writes:
> > this is a patch that Andres asked me for. It makes pg_bsd_indent leave
> > preprocessor space alone, as in this example:
>
> > #if 0
> > # if 0
> > # if 0
> > # error
> > # endif
> > # endif
> > #else
> > # line 7
> > #endif

For context: I'd asked Piotr how dificult it'd be to add this.

> Um ... but the point of pgindent is to standardize spacing, not to let
> people invent their own style. If you wanted to have a discussion about
> whether pgindent should force preprocessor directives to look like the
> above, we could talk about that. But I do not want to be reading code that
> looks like the above in one place and code that does not ten lines away.

I don't think that's something easily done in an automatic
manner. Because you'd e.g. obviously not want to indent everything
within include guards. I don't really buy the danger of large
divergances in code nearby - this seems mostly useful when writing a bit
more complicated macros, and I don't think they'll be that frequently
added in existing files.

I do think this makes the nesting for #ifdefs a *lot* more readable, and
we have plenty of cases where it's currently really hard to discern what
"branch" one is currently reading. Allowing to opt-in into the "newer"
formatting in places where it makes sense, seems reasonable to me.

Regards,

Andres

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tobias Bussmann 2017-02-08 19:08:07 Re: Press Release Draft - 2016-02-09 Cumulative Update
Previous Message Dean Rasheed 2017-02-08 18:40:43 Re: multivariate statistics (v19)