On Fri, 19 Oct 2007, Eric Blake wrote:
Facinating. I would expect opening for append to open at the tail
(end) of the file although I find your use of 'head' and 'tail' to be
confusing since a file is not a queue.
POSIX says the state of the first ftell() on a file after fopen("a+") is
implementation-defined - it can be either offset 0 (as glibc) or the end of the
file (as on BSD). It isn't until you do either an explicit seek (which is what
my m4 patch adds) or a write that the position is then well-defined.
It does not really matter what POSIX says. Do you not agree that the
text of the FreeBSD/OS-X manual page says that the fseeko in your
patch will be ignored?
``a+'' Open for reading and writing. The file is created if it does not
exist. The stream is positioned at the end of the file. Subse-
quent writes to the file will always end up at the then current
end of file, irrespective of any intervening fseek(3) or similar.
----------------------------------------
Not knowing what m4 is really trying to do, is there a reason that
'w+' is not being used? Append obviously intends to write to the end
of the file but it seems that you want to write to the front, which is
what 'w+' intends to do. Otherwise the semantics seem the same.
Bob
======================================
Bob Friesenhahn
[EMAIL PROTECTED], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/