Mail Archives: djgpp/2000/05/11/05:51:00
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 -