pgsql: pgindent: Fix spacing after != when member name matches typedef.

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: pgindent: Fix spacing after != when member name matches typedef.
Date: 2026-05-13 14:11:56
Message-ID: E1wNAJX-000Lpd-36@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

pgindent: Fix spacing after != when member name matches typedef.

When a struct member name matches a registered typedef, pgindent
removes the space after "!=" (and some other operators), like so:

entry->dsh.dsa_handle !=DSA_HANDLE_INVALID

The problem is that the related code in lexi.c sets last_u_d to
true before jumping to found_typename, causing the next operator to
be classified as unary and suppressing the following space. This
is correct for type names, but not for struct members. For
example, "Datum *x" needs "*" to be unary to suppress the space
before "x". To fix, only set last_u_d before jumping to
found_typename if the typedef name doesn't appear after "." or
"->".

Note that this does not bump INDENT_VERSION. We'll do that just
once after some other changes to pg_bsd_indent are committed.

Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/aS9hkwnkWf3dZIA_%40nathan

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a3e6beba60ec4e6804e91200e407d046414f18de

Modified Files
--------------
src/tools/pg_bsd_indent/lexi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-05-13 14:22:20 pgsql: Make pg_bsd_indent add a space between comma and period.
Previous Message Peter Eisentraut 2026-05-13 11:51:40 pgsql: Fix FOR PORTION OF with non-updatable view columns