Fix pg_ctl's readfile() to not go into infinite loop on an empty file

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 040f28b4b096b34f3e7bc62121a7be347bcebbc3
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2009-09-02T02:40:52Z
Releases: 9.0.0
Fix pg_ctl's readfile() to not go into infinite loop on an empty file
(could happen if either postgresql.conf or postmaster.opts is empty).
It's been broken since the C version was written for 8.0, so patch
all the way back.

initdb's copy of the function is broken in the same way, but it's
less important there since the input files should never be empty.
Patch that in HEAD only, and also fix some cosmetic differences that
crept into that copy of the function.

Per report from Corry Haines and Jeff Davis.

Files

PathChange+/−
src/bin/initdb/initdb.c modified +7 −13
src/bin/pg_ctl/pg_ctl.c modified +2 −2