Обсуждение: pgindent (probably my missing something obvious)

Поиск
Список
Период
Сортировка

pgindent (probably my missing something obvious)

От
James Coleman
Дата:
Hello,

This is the first time I've run pgindent on my current machine, and it
doesn't seem to be making any modifications to source files. For
example this command:

./src/tools/pgindent/pgindent src/backend/optimizer/path/allpaths.c

leaves the allpaths.c file unchanged despite my having some very long
function calls. I've downloaded the latest typedefs list, but I
haven't added any types anyway.

What obvious thing am I missing?

Thanks,
James Coleman



Re: pgindent (probably my missing something obvious)

От
Tom Lane
Дата:
James Coleman <jtc331@gmail.com> writes:
> This is the first time I've run pgindent on my current machine, and it
> doesn't seem to be making any modifications to source files. For
> example this command:

> ./src/tools/pgindent/pgindent src/backend/optimizer/path/allpaths.c

> leaves the allpaths.c file unchanged despite my having some very long
> function calls.

"Long function calls" aren't necessarily something pgindent would
change.  Have you tried intentionally misindenting some lines?

            regards, tom lane



Re: pgindent (probably my missing something obvious)

От
James Coleman
Дата:
On Mon, Jul 3, 2023 at 9:20 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> James Coleman <jtc331@gmail.com> writes:
> > This is the first time I've run pgindent on my current machine, and it
> > doesn't seem to be making any modifications to source files. For
> > example this command:
>
> > ./src/tools/pgindent/pgindent src/backend/optimizer/path/allpaths.c
>
> > leaves the allpaths.c file unchanged despite my having some very long
> > function calls.
>
> "Long function calls" aren't necessarily something pgindent would
> change.  Have you tried intentionally misindenting some lines?
>
>                         regards, tom lane

Hmm, yeah, that works.

My heuristic for what pgindent changes must be wrong. The long
function calls (and 'if' conditions) seem obviously out of place to my
eyes with the surrounding code. Does that mean the surrounding code
was just hand-prettified?

Thanks,
James Coleman



Re: pgindent (probably my missing something obvious)

От
Tom Lane
Дата:
James Coleman <jtc331@gmail.com> writes:
> My heuristic for what pgindent changes must be wrong. The long
> function calls (and 'if' conditions) seem obviously out of place to my
> eyes with the surrounding code. Does that mean the surrounding code
> was just hand-prettified?

pgindent won't usually editorialize on line breaks within C
statements.  (It *will* re-flow comment text, if the comment block
isn't at the left margin.)  It seems to feel free to play with
horizontal whitespace, but not to add or remove newlines within a
statement.  I do know that it will move curly braces around to meet
formatting rules, but I've not seen it do similar changes within a
function call or if-condition.  So it's up to you to break the lines
in a reasonable way.

            regards, tom lane