Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@sources.redhat.com>
List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@sources.redhat.com
Delivered-To: mailing list cygwin@sources.redhat.com
Message-Id: <5.0.0.25.0.20010330093251.00a66a30@barbar.esat.kuleuven.ac.be>
X-Sender: uwe@barbar.esat.kuleuven.ac.be
X-Mailer: QUALCOMM Windows Eudora Version 5.0
Date: Fri, 30 Mar 2001 09:37:31 +0200
To: "Robert Collins" <robert.collins@itdomain.com.au>,
        "Mumit Khan" <khan@NanoTech.Wisc.EDU>
From: Uwe Pahner <uwe.pahner@esat.kuleuven.ac.be>
Subject: Re: fscanf does not return EOF
Cc: <cygwin@cygwin.com>
In-Reply-To: <01f201c0b8d5$6e9c5d60$0200a8c0@lifelesswks>
References: <Pine.HPP.3.96.1010329222253.29265D-100000@hp2.xraylith.wisc.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed

Thanks Mumit and Rob! The explicit test to EOF does the trick.

I replaced the direct call of the fscanf function in my code with the 
following:

int readline(FILE *inputfile,char *linetxt)
{
   int k;

   k=fscanf(inputfile," %[^\r]",linetxt);
   if ((k==0)&&(feof(inputfile)!=0))  k=EOF;
   return(k);
}

This seems to work fine.

Uwe
At 02:53 PM 3/30/01 +1000, Robert Collins wrote:
>----- Original Message -----
>From: "Mumit Khan" <khan@NanoTech.Wisc.EDU>
>To: "Uwe Pahner" <uwe.pahner@esat.kuleuven.ac.be>
>Cc: <cygwin@cygwin.com>
>Sent: Friday, March 30, 2001 2:31 PM
>Subject: Re: fscanf does not return EOF
>
>
> > On Thu, 29 Mar 2001, Uwe Pahner wrote:
> >
> > > Hi,
> > >
> >
> > I suggest portable coding, where you read the lines one by one using
> > fgets, checking for EOF, and if not, pass the line buffer it to
>sscanf.
> > Or, use fscanf, but check explicitly for eof on the stream when you
> > see a return value of 0.
> >
> > I may of course be reading the specification wrong.
> >
> > Regards,
> > Mumit
> >
>
>I think you're right: I am using fscanf in my fifo tests, and the first
>iteration was written without checking the specs:].. as soon as I ran
>man 3 fscanf on my opsnBSD machine (best man pages ever) I saw the same
>point of confusion. Coding to the spec worked fine on cygwin.
>
>Rob




--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

