Thread: Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

From
Bruce Momjian
Date:
On Fri, Jun 20, 2025 at 04:44:08PM +0300, Aleksander Alekseev wrote:
> Hi Arseniy,
> 
> > I tried it with the whole project and almost always it works great.
> > But I noticed two cases where it works probably not as expected:
> >
> > 1) comments which don't have a star on each line. For example:
> > file 'cube.c'
> >
> > before:
> > /* make up a metric in which one box will be 'lower' than the other
> >    -- this can be useful for sorting and to determine uniqueness */
> >
> > after:
> > /*
> >  * make up a metric in which one box will be 'lower' than the other
> >    -- this can be useful for sorting and to determine uniqueness */
> >
> > 2) comments where closing */ is on the last comment line. For example:
> > file 'crypt-blowfish.c'
> >
> > before:
> > /* This has to be bug-compatible with the original implementation, so
> >  * only encode 23 of the 24 bytes. :-) */
> >
> > after:
> > /*
> >  * This has to be bug-compatible with the original implementation, so
> >  * only encode 23 of the 24 bytes. :-) */
> 
> Thanks for the review. You are right, these comments shouldn't be affected.
> 
> It's going to be simpler to modify pgindent then. PFA the updated patch.

Given the quality of BSD indent code, I have _always_ found it easier to
modify pgindent.  ;-

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  Do not let urgent matters crowd out time for investment in the future.



Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

From
Bruce Momjian
Date:
On Fri, Jun 20, 2025 at 05:01:41PM +0300, Aleksander Alekseev wrote:
> Hi,
> 
> > Given the quality of BSD indent code, I have _always_ found it easier to
> > modify pgindent.  ;-
> 
> :D Initially I thought that the problem was simple enough to solve it
> in C, but this turned out not to be true.

I always found it ironic that a tool designed to make source code easier
to understand like BSD indent is so hard to understand.  Its use of
short variable names alone is confusing.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  Do not let urgent matters crowd out time for investment in the future.



Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

From
Arseniy Mukhin
Date:
On Fri, Jun 20, 2025 at 5:01 PM Aleksander Alekseev
<aleksander@timescale.com> wrote:
>
> Hi,
>
> > Given the quality of BSD indent code, I have _always_ found it easier to
> > modify pgindent.  ;-
>
> :D Initially I thought that the problem was simple enough to solve it
> in C, but this turned out not to be true.
>
> > It's going to be simpler to modify pgindent then. PFA the updated patch.
>
> I noticed a mistake in v2. Here is the corrected patch. Changes
> comparing to the previous version:
>

Thanks!

Now it affects 4 times more files (380). What I noticed:
1) Most of the comments are bordered comments like this:
-/* --------------------------------------------------------------------------------
+/*
+ * --------------------------------------------------------------------------------
  * Public IO related functions operating on IO Handles
  * --------------------------------------------------------------------------------
  */

Do we want to skip such comments?
I have also seen comments with '====' border.

2) Some comments like this:

before:
/* Author: Linus Tolke
   (actually most if the code is "borrowed" from the distribution and just
   slightly modified)
 */

after:
/*
 * Author: Linus Tolke
   (actually most if the code is "borrowed" from the distribution and just
   slightly modified)
 */

I guess closing */ on the separate line is the trigger?
If I'm not wrong there are only 3 such comments, maybe it is easier to
fix them by hand?)

3) It seems all geqo related file contains such comment:
-/* contributed by:
+/*
+ * contributed by:
    =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
    *  Martin Utesch                             * Institute of
Automatic Control          *
    =


Best regards,
Arseniy Mukhin