public inbox for [email protected]
help / color / mirror / Atom feedFrom: Andrew Dunstan <[email protected]>
To: Akshay Joshi <[email protected]>
To: pgsql-hackers <[email protected]>
Subject: Re: [PATCH] pgindent truncates last line of files missing a trailing newline
Date: Mon, 16 Feb 2026 11:28:58 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CANxoLDfca8O5SkeDxB_j6SVNXd+pNKaDmVmEW+2yyicdU8fy0w@mail.gmail.com>
References: <CANxoLDfca8O5SkeDxB_j6SVNXd+pNKaDmVmEW+2yyicdU8fy0w@mail.gmail.com>
On 2026-02-16 Mo 9:09 AM, Akshay Joshi wrote:
> Hi Hackers,
>
> I have encountered a bug in "*src/tools/pg_bsd_indent/lexi.c"* where
> pgindent was incorrectly dropping the final line of a file if that
> line did not end with a newline character (\n). This occurred because
> the EOF logic triggered a termination of the processing loop before
> the remaining buffer was flushed to the output.
>
> *Steps to Reproduce:*
>
> 1. Create a *header/c* file with some content but no newline at the
> very end.
> 2. Run pgindent on those files.
> 3. Check the file content. The file is now empty or missing the last
> line.
>
> This patch ensures that had_eof states do not bypass the final buffer
> processing, preserving the integrity of the source code regardless of
> trailing whitespace.
Yeah. I wonder if we shouldn't be just ensuring that there is a line
feed at the end of the buffer, i.e. add one if it's not there. We
shouldn't be adding files without a trailing LF, and ensuring there is
one seems like a reasonable thing to do in pg_bsd_indent.
cheers
andrew
--
Andrew Dunstan
EDB:https://www.enterprisedb.com
view thread (7+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [PATCH] pgindent truncates last line of files missing a trailing newline
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox