delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD |
X-Spam-Check-By: | sourceware.org |
From: | "Brebner, Gavin" <gavin DOT brebner AT hp DOT com> |
To: | "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com> |
Date: | Thu, 1 Apr 2010 09:06:30 +0000 |
Subject: | fopen with "a+" does not respect setting file read position to start of file |
Message-ID: | <B0E0B6C348D8AB4BAD6290DC0BDE99D47427D7442A@GVW1115EXC.americas.hpqcorp.net> |
MIME-Version: | 1.0 |
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 |
We hit a problem in a code, and narrowed it down to a test case that does : while (cnt) { f=3Dfopen(host_file, "a+"); if (!f) perror("dup_host_file: Could not open hostfile"); /* rewind(f); */ while (cnt) { int ret=3Dfscanf(f, "%s", line); if (ret !=3D EOF) { fprintf(f, "%s\n", line); cnt--; dup++; } } fclose(f); In earlier versions of cygwin we have, this works fine, however in the rece= ntly installed=20 versions, it no longer works. It seems that fopen(host_file, "a+") is NOT p= ositioning the read position at the start of the file as it should. Adding an explicit rew= ind(f) is a=20 work around. Gavin -- 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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |