Date: Sun, 1 Apr 2001 10:42:50 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Martin Str|mberg , djgpp-workers AT delorie DOT com Subject: Re: Bug00323, final? (LONG) In-Reply-To: <3791-Sat31Mar2001222212+0200-eliz@is.elta.co.il> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Sat, 31 Mar 2001, Eli Zaretskii wrote: > > - if (*mode == 'a') > > - lseek(fd, 0, SEEK_END); > > - > > What does ANSI C say about the file stream position right after it is > open with "a" mode? If it says it should be at the file's end, you > cannot remove the above lseek. This is from the draft: 7.19.3 Files [#1] A stream is associated with an external file (which may be a physical device) by opening a file, which may involve creating a new file. Creating an existing file causes its former contents to be discarded, if necessary. If a file can support positioning requests (such as a disk file, as opposed to a terminal), then a file position indicator associated with the stream is positioned at the start (character number zero) 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 the end of the file. Note the last sentence: the file position is implementation defined. This probably means that different library implementations do it differently. Can someone please check what happens on Unix and GNU/Linux systems? A simple test program which opens an existing file with "a" and then calls ftell and prints the result is all you need. The Posix draft seem to say the same. It would be interesting to know what happens with open and fdopen on Unix systems, btw.