www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/11/05:51:00

From: dontmailme AT iname DOT com (Steamer)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: feof(FILE *) NOT portable...
Date: Thu, 11 May 2000 09:57:19 GMT
Organization: always disorganized
Lines: 53
Message-ID: <391a83ec.5977837@news.freeserve.net>
References: <8empao$5k6$1 AT nnrp02 DOT primenet DOT com> <390ef9f9$0$72098 AT SSP1NO17 DOT highway DOT telekom DOT at> <8emvhq$7mn$1 AT nnrp03 DOT primenet DOT com> <3 DOT 0 DOT 6 DOT 32 DOT 20000505015633 DOT 007b2210 AT pop DOT crosswinds DOT net> <3 DOT 0 DOT 6 DOT 32 DOT 20000510204858 DOT 007b6e40 AT pop DOT crosswinds DOT net> <3 DOT 0 DOT 6 DOT 32 DOT 20000511021045 DOT 007af4a0 AT pop DOT crosswinds DOT net>
NNTP-Posting-Host: modem-22.blue-mandarin.dialup.pol.co.uk
X-Trace: newsg1.svr.pol.co.uk 958039040 29175 62.136.237.22 (11 May 2000 09:57:20 GMT)
NNTP-Posting-Date: 11 May 2000 09:57:20 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Free Agent 1.11/32.235
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Thomas J. Hruska wrote:

>Actually, I have tested this code with both Borland's Turbo C v3.0 for DOS
>as well as the latest Borland C++ Builder free command-line tools.  The
>exact same results tell be that over many generations of compilers (with
>thousands and thousands of builds of the libraries and executables), either
>Borland hasn't noticed a non-ANSI standard with feof, or they are following
>the standard.  My aim is to prove which one doesn't follow the ANSI
>standard:  gcc and all ports of it, or Borland.

Borland isn't particularly noted for its standards compliance, is it?
In your previous post you stated that all compilers other than DJGPP
behave like the Borland ones.  Now you appear to be saying only that
GCC ports behave one way and Borland behaves another way, which is a
very different matter.

>So, to begin my proof, I went onto the manpages for Linux (on feof) and
>discovered that the manpages claim to be following the specifications in
>"C3.159-1989"  I have searched both ANSI.org and NSSN.org as well as
>regular web search engines for this particular document.  However, I am
>unable to find this document or anything newer.  

No doubt you have to pay for it.  I don't think standards organizations
ought to charge for copies of their standards, but ANSI does (and so
does ISO).

>The only thing that kept
>coming up was listings of online manpages that made the same reference to
>this document that I can't find.  If anyone can point me to this document
>online (or even offline), I would greatly appreciate it.

You could try e-mailing ANSI and asking them about it.

Alternatively, download the final draft of the C99 standard:

   http://anubis.dkuug.dk/JTC1/SC22/WG14/www/docs/n869/n869.txt.gz

Check the definition of fgetc().  Note that the end-of-file indicator
is only set when an attempt is made to read at end-of-file.  Merely
being at end-of-file doesn't set the end-of-file indicator.

Check the definition of feof().  Note that "the feof function returns
nonzero if and only if the end-of-file indicator is set for stream".

So it's your code that's wrong, not DJGPP's feof().  If your code
really works on the latest Borland compiler then perhaps you should
send a bug report to Inprise (after you've apologised to DJ).

As has already been pointed out, you had no need to use feof() anyway:
fgetc() returns an int, so check it isn't EOF before you force it into
a char.

S.

- Raw text -


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