public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: fseek(...,SEEK_CUR) calls _fflush_r(ptr, fp) in read only mode
Date: Fri, 01 Dec 2017 17:19:00 -0000	[thread overview]
Message-ID: <20171201171917.GB4325@calimero.vinschen.de> (raw)
In-Reply-To: <1470375482.5430561.1512147734234@mail.yahoo.com>

[-- 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 --]

      reply	other threads:[~2017-12-01 17:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171201171917.GB4325@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).