delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/12/01/12:02:38

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:reply-to:reply-to:to:message-id
:subject:mime-version:references:content-type
:content-transfer-encoding; q=dns; s=default; b=pnhuZLwOefhxuO3U
XfI82cjsz0Vh/3oLXzhZpbKHlPOGJBQGN8pOsQoDs7UYg/8pHe56pJwwLMqAAFB4
7FOlFhpNXvRpGPujVnXV18Ppl42sGu2il5w3eY7MavVEVhq3SOSrqsGdqI7bvUIV
Cf23/UiBbhcrr5amReKt2R1WmDE=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:reply-to:reply-to:to:message-id
:subject:mime-version:references:content-type
:content-transfer-encoding; s=default; bh=iQ5m15D5p0tu/K5dw0zkZh
rb0q0=; b=GHrvIkShByf2HJNOewy+j8m9xzJcmzgDREcehnUGbDk82PhmfPk8I2
6IU6u9rsI9DOlqwi87RsqeKB3Be8XkZFIguhQJixBb4uk9uytPbE+qux4v+9t5si
Z/sowYQKNk+rcf1znhsfTLxbTkSgqbSHS+YOyVioBz60jomPPKMAw=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=4.7 required=5.0 tests=AWL,BAYES_50,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,FREEMAIL_REPLYTO_END_DIGIT,HTML_MESSAGE,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=H*UA:x64, H*UA:Win64, H*x:Win64, H*x:x64
X-HELO: sonic302-22.consmr.mail.gq1.yahoo.com
Date: Fri, 1 Dec 2017 17:02:14 +0000 (UTC)
From: "Xiaofeng Liu via cygwin" <cygwin AT cygwin DOT com>
Reply-To: Xiaofeng Liu <liuxf09 AT yahoo DOT com>
Reply-To: Xiaofeng Liu <liuxf09 AT yahoo DOT com>
To: The Cygwin Mailing List <cygwin AT cygwin DOT com>
Message-ID: <1470375482.5430561.1512147734234@mail.yahoo.com>
Subject: fseek(...,SEEK_CUR) calls _fflush_r(ptr, fp) in read only mode
MIME-Version: 1.0
References: <1470375482 DOT 5430561 DOT 1512147734234 DOT ref AT mail DOT yahoo DOT com>
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id vB1H2Z5k014547

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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019