| From: | Akshay Joshi <akshay(dot)joshi(at)enterprisedb(dot)com> |
|---|---|
| To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | [PATCH] pgindent truncates last line of files missing a trailing newline |
| Date: | 2026-02-16 14:09:46 |
| Message-ID: | CANxoLDfca8O5SkeDxB_j6SVNXd+pNKaDmVmEW+2yyicdU8fy0w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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.
Akshay Joshi
Principal Engineer | Engineering Manager | pgAdmin Hacker
* Blog*: https://www.enterprisedb.com/akshay-joshi
* GitHub*: https://github.com/akshay-joshi
* LinkedIn*: https:// <http://goog_373708537>
www.linkedin.com/in/akshay-joshi-a9317b14
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Fix-pgindent-truncates-last-line-of-files.patch | application/octet-stream | 2.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Robert Treat | 2026-02-16 14:24:49 | Re: Proposal: SELECT * EXCLUDE (...) command |
| Previous Message | Jakub Wartak | 2026-02-16 14:07:16 | Re: [PROPOSAL] Doublewrite Buffer as an alternative torn page protection to Full Page Write |