fseek(...,SEEK_CUR) calls _fflush_r(ptr, fp) in read only mode
Corinna Vinschen
corinna-cygwin@cygwin.com
Fri Dec 1 17:19:00 GMT 2017
On Dec 1 17:02, Xiaofeng Liu via cygwin wrote:
> In ftello.c, it intentionally skipped fflush for read mode:
> https://github.com/openunix/cygwin/blob/master/newlib/libc/stdio/ftello.c#L121
>
> /* Find offset of underlying I/O object, then adjust for buffered bytes. Flush a write stream, since the offset may be altered if the stream is appending. Do not flush a read stream, since we must not lose the ungetc buffer. */ if (fp->_flags & __SWR) _fflush_r (ptr, fp);
> But in fseeko.c, when fseek(..., SEEK_CUR) requires to get the current position first. But it calls _fflush_r(ptr, fp) in read mode, which screwed up the current position after fflush.
> https://github.com/openunix/cygwin/blob/master/newlib/libc/stdio/fseeko.c#L174
>
>
> For my job, if I skip _fflush_r for read only mode in fseek(..., SEEK_CUR), the job runs OK.
> Considering fseek(..., SEEK_CUR) is a basic call, could my understanding be wrong?
Please provide a simple, self-contained testcase. It might clear
up the problem.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20171201/8d8e7301/attachment.sig>
More information about the Cygwin
mailing list