]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
pgindent: ensure all C files end with a newline.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 27 Mar 2026 19:38:48 +0000 (15:38 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 27 Mar 2026 19:38:48 +0000 (15:38 -0400)
Not only is this good style, but it dodges some obscure bugs within
pg_bsd_indent.  We could try to fix said bugs, but the amount of
effort required seems far out of proportion to the benefit.

Reported-by: Akshay Joshi <akshay.joshi@enterprisedb.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/CANxoLDfca8O5SkeDxB_j6SVNXd+pNKaDmVmEW+2yyicdU8fy0w@mail.gmail.com

src/tools/pgindent/pgindent

index 5f46aa46482f126e538df61173c7f20b13f95395..b2ec5e2914becfea5d136cae6de0cf5751c64c36 100755 (executable)
@@ -239,6 +239,9 @@ sub pre_indent
 {
        my $source = shift;
 
+       ## Ensure file ends with a newline (pg_bsd_indent messes up otherwise)
+       $source .= "\n" unless substr($source, -1) eq "\n";
+
        ## Comments
 
        # Convert // comments to /* */