Re: [HACKERS] Running pgindent - Mailing list pgsql-hackers

From Thomas G. Lockhart
Subject Re: [HACKERS] Running pgindent
Date
Msg-id 34ECF9C0.70C7BFC2@alumni.caltech.edu
Whole thread Raw
In response to Re: [HACKERS] Running pgindent  (Bruce Momjian <maillist@candle.pha.pa.us>)
Responses Re: [HACKERS] Running pgindent  (Bruce Momjian <maillist@candle.pha.pa.us>)
Re: [HACKERS] Running pgindent  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
Bruce Momjian wrote:

> >
> > Bruce Momjian wrote:
> >
> > > I want to run pgindent before the final release.  Who has outstanding
> > > patches they are sitting on that would be affected by this?  Only places
> > > where we have added non-conforming code would be affected.
> >
> > Ack! Can you make at least three changes to pgindent before doing this?
> >
> > 1) for functions which look like
> >   datetime *
> >   abstime_datetime(int4 x)
> >   {
> >   ...
> > do not put a tab (or extra spaces) between "datetime" and "*".
> >
> > For the end of functions which look like
> >   ...
> >   } /* abstime_datetime() */
> >
> > do not put any tabs (or just one) between the "{" and the comment.
> >
> > Also, some comments get wrapped to the next line, making some ugly sources;
> > perhaps pgindent should not touch comment lines at all? Or at least keep
> > things on the same line, messing with the tabbing only??
>
> Well, that is what indent does.  I can try and work around it, but I am
> afraid I will mess it up somehow.  Right now, all the stuff is indented
> consistently, and running it again will only make the changed stuff look
> like the rest.
>
> Making a change will change all the code, even the unchanged stuff.
> Also, for comments, it will not change comments that are block-style.
> See the indent manual page and the flags I use for help.  Keep in mind I
> use BSD indent, which does not have the bugs in GNU indent.

Well, *&^*^#$! I wasted hours cleaning up some of what I considered damage from
the last pass through.
Would it be possible to pass back through (i.e. pipe indent output to a filter)
and fix at least points (1) and (2)? _That_ would be pretty easy to automate
since the heuristics can be pretty simple:

if (first char is nonwhitespace) && (next word is "*") && (next line starts with
word+paren)
then compress whitespace

else if (first char is "}") && (next word is "/*")
then compress whitespace

else
write line as-is

I'll write the perl if you would be willing to use it?

                                               - Tom


pgsql-hackers by date:

Previous
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] atttypmod
Next
From: The Hermit Hacker
Date:
Subject: Re: [HACKERS] atttypmod