From 9462239c90db4abb61b2dc7f8b48ffbf8de6d8da Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 8 Sep 2026 11:42:24 +0200 Subject: [PATCH 2/2] pgindent: Fix indentation of alignas() in struct members pg_bsd_indent doesn't know about alignas(). A struct member using alignas() ends up being treated as the variable name of the preceding member's declaration and gets indented to the declaration column. This only shows up for members that are not the first member of the struct. Have pgindent temporarily disguise alignas(...) as a plain identifier to avoid that. Also reindent the one affected place in xlogreader.h. --- src/include/access/xlogreader.h | 2 +- src/tools/pgindent/pgindent | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.h index a2563458018..6e27b30fb35 100644 --- a/src/include/access/xlogreader.h +++ b/src/include/access/xlogreader.h @@ -262,7 +262,7 @@ struct XLogReaderState /* * Buffer for currently read page (valid up to at least readLen bytes) */ - alignas(MAXIMUM_ALIGNOF) char readBuf[XLOG_BLCKSZ]; + alignas(MAXIMUM_ALIGNOF) char readBuf[XLOG_BLCKSZ]; uint32 readLen; /* last read XLOG position for data currently in readBuf */ diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent index 004b8fcab00..b8e42515104 100755 --- a/src/tools/pgindent/pgindent +++ b/src/tools/pgindent/pgindent @@ -263,6 +263,13 @@ sub pre_indent # Protect wrapping in CATALOG() $source =~ s!^(CATALOG\(.*)$!/*$1*/!gm; + # pg_bsd_indent doesn't know about alignas(). A struct member + # using alignas() ends up being treated as the variable name of + # the preceding member's declaration and gets indented to the + # declaration column. Disguise alignas(...) as a plain identifier + # to avoid that. + $source =~ s!\balignas\(([^()\n]*)\)!alignas_${1}_!g; + return $source; } @@ -270,6 +277,9 @@ sub post_indent { my $source = shift; + # Restore alignas(...) + $source =~ s!\balignas_(.*?)_(?=\s)!alignas($1)!g; + # Restore CATALOG lines $source =~ s!^/\*(CATALOG\(.*)\*/$!$1!gm; -- 2.55.0