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

Message-Id: <3.0.6.32.20000511161120.007a2970@pop.crosswinds.net>
X-Sender: shinelight AT pop DOT crosswinds DOT net
X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32)
Date: Thu, 11 May 2000 16:11:20 -0500
To: djgpp AT delorie DOT com
From: "Thomas J. Hruska" <shinelight AT crosswinds DOT net>
Subject: feof(FILE *) portable...
In-Reply-To: <200005111331.JAA13189@indy.delorie.com>
References: <3 DOT 0 DOT 6 DOT 32 DOT 20000511021045 DOT 007af4a0 AT pop DOT crosswinds DOT net>
<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>
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Hmm...well, after waking up this morning I checked my e-mail and found the
link to the ANSI-C standard (1999).  Apparently when I wrote the function
years ago, I saw only the first part of the return:



Returns
3 If the end-of-file indicator for the stream is set, or if the stream is
at end-of-file, the end-of-file indicator for the stream is set and fgetc
returns EOF. Otherwise, the fgetc function returns the next character from
the input stream pointed to by stream. If a read error occurs, the error
indicator for the stream is set and fgetc returns EOF.



The way it sounded according to the description and the return is that gcc
was reading in the character AFTER testing for eof indicator and Borland
was reading in a character, moving ahead one character and THEN testing for
eof.

The way my code was written (I must admit it is ugly...but I never had a
problem before) was to read each character in until it hit a newline or
eof.  However, I never ran into any problems because the eof was always
after a newline (due to the way MS-DOS EDIT works).  So, when I started
using notepad/vim, the LineInput routine made djgpp hiccup as well as gcc.
However, my tests ran fine under Borland because I was using different test
files created under MS-DOS EDIT.

Today I tested under Borland on the original files and discovered the same
problem (that's how I came to this e-mail).

****  So, I apologize for the angry e-mails I sent last night.  ****

Oh, BTW, thanks for the ANSI-C documentation.  I've always wondered where I
could get standards like that.


           Thomas J. Hruska -- shinelight AT crosswinds DOT net
Shining Light Productions -- "Meeting the needs of fellow programmers"
                  http://www.shininglightpro.com/

- Raw text -


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