Re: pgindent complaint of the day

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pgindent complaint of the day
Date: 2004-10-07 02:26:20
Message-ID: 200410070226.i972QKq25554@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> This case in xlog.c is representative of a disease that pgindent has had
> for awhile:
>
> @@ -4276,7 +4300,8 @@ StartupXLOG(void)
> if (needNewTimeLine) /* stopped because of stop request */
> ereport(FATAL,
> (errmsg("requested recovery stop point is before end time of backup dump")));
> - else /* ran off end of WAL */
> + else
> +/* ran off end of WAL */
> ereport(FATAL,
> (errmsg("WAL ends before end time of backup dump")));
> }
>
> I'm not sure of all the triggering conditions, but every so often it
> decides to move a line-ending comment to its own line (which is a wrong
> policy in the first place IMHO) and forgets to indent it. I've mostly
> seen it on "else" lines but I'm not sure that's the only case.

You are correct that it only happens on comments on an else line. The
problem is that there is a BSD indent bug that will stop processing the
file in such cases so we have in pgindent:

# workaround for indent bug with 'else' handling
sed 's;\([} ]\)else[ ]*\(/\*.*\)$;\1else\
\2;g' |

and this does exactly as you describe by putting the comment on its own
line. I just changed it to:

# workaround for indent bug with 'else' handling
sed 's;\([} ]\)else\([ ]*\)\(/\*.*\)$;\1else\
\2\3;g' |

so that the new comment will have the same indenting as the else that
was input. It should help but will not be perfect.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marcos A Vaz Salles 2004-10-07 02:40:18 Hypothetical Indexes
Previous Message Euler Taveira de Oliveira 2004-10-07 01:42:06 initdb crash