🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #27105

read past EOF?

#27105
From: nowlin
Date: Thu, 04 Jun 1987 20:44
29 lines
2144 bytes
I've run into a problem with the Fread() gemdos macro.  Using Megamax I
wrote a piece of code to buffer line-by-line input.  The code reads files
by 8K blocks at a time.  There's no problem as long as the call to Fread()
requests a block smaller than the rest of the file being read.  For
example, if I read 1000 bytes from a 3000 byte file Fread() returns 1000
and there are exactly 1000 characters stored in the buffer specified.  If
there are only 300 bytes in the file and I request 1000 Fread() will return
301 and the 301st byte is a ^Z.  Since ^Z is the EOF character in gemdos It
appears that Fread() is actually reading one character past/into the end of
file and sticking that character at the end of the input buffer.

Please don't reply with work around solutions to this.  I've already worked
around it.  I just wanted to see if anybody else has run into this problem
and if they've found a real solution for it.  In most cases this isn't much
of a problem but it's something to watch out for when comparing files.  It
looks like the files are actually starting to diverge from each other when
in fact one has ended.  These are two entirely different things and this
bug makes the later trickier to detect.

I'm also not sure if this is only related to Megamax or is a bug in the
gemdos call itself.  Megamax seems to think it's gemdos.  I'm not sure
since Megamax has to provide the gemdos() library call that's used to
invoke the lower level routines and that could be where the problem is
occurring.  Has anyone seen this problem with any of the other C
development systems?

Jerry Nowlin
(...!ihnp4!ihuxy!nowlin)
Technical Details
Message-ID: <1987@ihuxy.ATT.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ihuxy!nowlin

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ihuxy!nowlin
From: nowlin@ihuxy.UUCP
Newsgroups: comp.sys.atari.st
Subject: read past EOF?
Message-ID: <1987@ihuxy.ATT.COM>
Date: Thu, 4-Jun-87 16:44:56 EDT
Article-I.D.: ihuxy.1987
Posted: Thu Jun  4 16:44:56 1987
Date-Received: Sat, 6-Jun-87 10:09:51 EDT
Organization: AT&T Bell Laboratories - Naperville, Illinois
Lines: 29
Keywords: read, bug, gemdos, megamax