public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* fseek(...,SEEK_CUR) calls _fflush_r(ptr, fp) in read only mode
       [not found] <1470375482.5430561.1512147734234.ref@mail.yahoo.com>
@ 2017-12-01 17:02 ` Xiaofeng Liu via cygwin
  2017-12-01 17:19   ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Xiaofeng Liu via cygwin @ 2017-12-01 17:02 UTC (permalink / raw)
  To: The Cygwin Mailing List

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: fseek(...,SEEK_CUR) calls _fflush_r(ptr, fp) in read only mode
  2017-12-01 17:02 ` fseek(...,SEEK_CUR) calls _fflush_r(ptr, fp) in read only mode Xiaofeng Liu via cygwin
@ 2017-12-01 17:19   ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2017-12-01 17:19 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1223 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-01 17:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1470375482.5430561.1512147734234.ref@mail.yahoo.com>
2017-12-01 17:02 ` fseek(...,SEEK_CUR) calls _fflush_r(ptr, fp) in read only mode Xiaofeng Liu via cygwin
2017-12-01 17:19   ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).