On Sat, Jul 21, 2007 at 10:27:04PM -0600, Eric Blake wrote:
> Nevermind - I finally figured it out!  POSIX states "a ``file position
> indicator'' associated with the stream is positioned at the start (byte
> number 0) of the file, unless the file is opened with append mode, in
> which case it is implementation-defined whether the file position
> indicator is initially positioned at the beginning or end of the file."
> And I was using fopen(tmpname, "a+").  In m4 1.4.9, it was followed by a
> rewind(), but that is inherently unsafe (since rewind() can lose data on a
> flush error, but clears the stream error indicator anyway), so I deleted
> it in m4 1.4.10.  The difference between my system and yours, then, must
> be that NetBSD opens files in append mode with the file descriptor at the
> last byte instead of the first byte of the file, and hence, does not read
> any data unless we add an explicit seek.  I never saw the bug because my
> system always opens files at offset 0 (even in append mode), delaying the
> seek to the end until the first write.
> 
> This is the patch, I'm still working on a testsuite addition:

Thank you, this fixes the problem in the cases I tried so far!
I've updated pkgsrc m4 again including this patch, I'll let you know
if other problems appear.
 Thomas


_______________________________________________
Bug-m4 mailing list
Bug-m4@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-m4

Reply via email to