From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123437 invoked by alias); 12 Mar 2016 22:29: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 123423 invoked by uid 89); 12 Mar 2016 22:29:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-94.7 required=5.0 tests=BAYES_40,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_PBL,RDNS_DYNAMIC,USER_IN_WHITELIST autolearn=no version=3.3.2 spammy=liberty, H*f:sk:11ca145, swear, newlibs X-HELO: calimero.vinschen.de Received: from ipbcc0d020.dynamic.kabel-deutschland.de (HELO calimero.vinschen.de) (188.192.208.32) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 12 Mar 2016 22:29:23 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 9559DA806A2; Sat, 12 Mar 2016 23:29:21 +0100 (CET) Date: Sat, 12 Mar 2016 22:29:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Problem with line buffering and getc function on 1.7.33. Message-ID: <20160312222921.GD3567@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <56E34346.9010000@gmail.com> <11ca145175d5b7d15db927c0c1f28b18@mail.kylheku.com> <20160312193946.GB3567@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="cHMo6Wbp1wrKhbfi" Content-Disposition: inline In-Reply-To: <20160312193946.GB3567@calimero.vinschen.de> User-Agent: Mutt/1.5.24 (2015-08-30) X-SW-Source: 2016-03/txt/msg00189.txt.bz2 --cHMo6Wbp1wrKhbfi Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1574 On Mar 12 20:39, Corinna Vinschen wrote: > On Mar 11 16:05, Kaz Kylheku wrote: > > We can reproduce the problem with just file streams using > > a much simpler program: > >=20 > > #include > >=20 > > int main(void) > > { > > FILE *out =3D fopen("file", "w+"); > > setvbuf(out, (char *) NULL, _IOLBF, 0); > > getc(out); > > clearerr(out); > > fseek(out, 0, SEEK_SET); > > putc('a', out); > > putc('b', out); > > putc('c', out); > > putc('d', out); > > putc('e', out); > > putc('\n', out); > > fclose(out); > > return 0; > > } > >=20 > > The contents of file end up being "\n": one empty > > line, instead of "abcde\n": > >=20 > > $ cat file > >=20 > > $ >=20 > Thanks for the testcase. I can reproduce the issue and I see where the > problem occurs, but I'm still puzzled. Comparing the code in our newlib > C library with its BSD counterparts, I could swear the same behaviour > happens on OpenBSD as well. If not (which needs testing), I wonder why > and where newlib's actually different. Right now I don't see the > difference. I do now. Basically it's setvbuf screwing up the internal flags in the FILE structure. I took the liberty to update newlib's setvbuf to the OpenBSD version locally and I'm going to apply my patches to newlib soon. I'll provide a new 2.5.0 test release of Cygwin with this patch tomorrow or early next week. Thanks again for the testcase, Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --cHMo6Wbp1wrKhbfi Content-Type: application/pgp-signature; name="signature.asc" Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJW5JhBAAoJEPU2Bp2uRE+gPz4P/3/BPids/aCcUBPeEfgZTLnZ vRa9igKC7OzMY5+GCtuSl4iQRoEtNr0Ncf2bNfjNBYa6zzS2NguJhqIj0SE3ZEYS gBqw74PVbnAONeQgtO0rnaBidyw6sc0ZiYx/oizG4k1ma4vTTnQfpj0mgao4fXIj WP7ZUdAmbTN8YMSXl2Zout31UaRCxVvZ48ZZYuAdPUTiUBU8yw7cFu/lVZD4jRkT LXxgDvZsDMnpQ0XKyoEm+/64uQZxBkuQJ77tgxvycHNJAe1OFyudC1SmaPIk2gtC RIf6fRRi/LKSUsCdFKAU0RGXHKvCSHy/mrCfhELDozoEb3bkUIv26rVY/Ndq+0cS 2xydeVlcLHnrTwx9kpP+C5qEkzUHvEHtKxlyL2h0dwJRJLs9FFij2+6v2rQXKxhU zInyLcJxJvik8rYiOeIAlE6lySS7Dq67CQvV9KMu9wa6pJdTKeA68iuL4MPw123w b6d0DJ4Yj/rFNffBO5HR06WjEAKN31M6ry1Spv9dZr9zNLxtW6rgDJg0HDP/MfTs OGo3g9mb4G35ZmsnkVUFJG9/+KSXo6WEwLgWkV/9KI/ZR93xsL86rJ7rUvK+aWuf jK5fuCyxyfJmDZsT/7rDIipTAslepCEmxqV5M0CFDGDeBVHrGMGgoax6lpYz08Y+ ouCH+jukOQVOOx3ig5Jx =VyMh -----END PGP SIGNATURE----- --cHMo6Wbp1wrKhbfi--