From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125167 invoked by alias); 1 Dec 2017 17:02:25 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 124569 invoked by uid 89); 1 Dec 2017 17:02:25 -0000 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 Received: from sonic302-22.consmr.mail.gq1.yahoo.com (HELO sonic302-22.consmr.mail.gq1.yahoo.com) (98.137.68.148) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 01 Dec 2017 17:02:22 +0000 Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.gq1.yahoo.com with HTTP; Fri, 1 Dec 2017 17:02:21 +0000 Date: Fri, 01 Dec 2017 17:02:00 -0000 From: "Xiaofeng Liu via cygwin" Reply-To: Xiaofeng Liu Reply-To: Xiaofeng Liu To: The Cygwin Mailing List 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.5430561.1512147734234.ref@mail.yahoo.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg00008.txt.bz2 In ftello.c, it intentionally skipped fflush for read mode: https://github.com/openunix/cygwin/blob/master/newlib/libc/stdio/ftello.c#L= 121 /* Find offset of underlying I/O object, then adjust for buffered=C2=A0 =C2= =A0 =C2=A0bytes.=C2=A0 Flush a write stream, since the offset may be altere= d if=C2=A0 =C2=A0 =C2=A0the stream is appending.=C2=A0 Do not flush a read = stream, since we=C2=A0 =C2=A0 =C2=A0must not lose the ungetc buffer.=C2=A0 = */=C2=A0 if (fp->_flags & __SWR)=C2=A0 =C2=A0 _fflush_r (ptr, fp); But in fseeko.c, when fseek(..., SEEK_CUR) requires to get the current posi= tion first. But it calls _fflush_r(ptr, fp) in read mode, which screwed up = the current position after fflush.=C2=A0 https://github.com/openunix/cygwin/blob/master/newlib/libc/stdio/fseeko.c#L= 174 For my job, if I skip _fflush_r for read only mode in fseek(..., SEEK_CUR),= the job runs OK.=C2=A0 Considering fseek(..., SEEK_CUR) is a basic call, could my understanding be= wrong?=C2=A0 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