This is the mail archive of the
cygwin
mailing list for the Cygwin project.
fseek(...,SEEK_CUR) calls _fflush_r(ptr, fp) in read only mode
- From: "Xiaofeng Liu via cygwin" <cygwin at cygwin dot com>
- To: The Cygwin Mailing List <cygwin at cygwin dot com>
- Date: Fri, 1 Dec 2017 17:02:14 +0000 (UTC)
- Subject: fseek(...,SEEK_CUR) calls _fflush_r(ptr, fp) in read only mode
- Authentication-results: sourceware.org; auth=none
- References: <1470375482.5430561.1512147734234.ref@mail.yahoo.com>
- Reply-to: Xiaofeng Liu <liuxf09 at yahoo dot com>
- Reply-to: Xiaofeng Liu <liuxf09 at yahoo dot com>
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?
Thanks.
Xiaofeng Liu
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple