🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #924

Re: JPI TopSpeed FIO.WrBin bug affects only re-directed I/O. Apologies.

#924
From: Tom Almy
Date: Thu, 12 Jul 1990 15:45
43 lines
2480 bytes
Well I investigated this some more, and came to a different conclusion than
Simon Lovatt.

The IO module does MS-DOS calls directly and thus does not suffer from this
problem. So you can do IO.WrLn where output is redirected to a file and not
get the lf -> crlf conversion.

On the other hand, the FIO module does io through the common language interface
(read *C-like interface*). Files can be opened in text (which translates) or
binary ("raw") mode. All the FIO procedures that open files use binary mode.

Unfortunately, the FIO.StandardInput and FIO.StandardOutput files (as well as
several others) are initially open, and the mode bit is
set to text! In a mixed language program, this would be required for C modules
to successfully write to the display.

Now, there are two solutions.

The first is to change the second entry in __openfd (in file r_mcore.a) from
4002H to 8002H, and recompile the libraries. Don't try to use the new library
if you have TS C.

A second less drastic solution is to import CLB and execute:
CLB._openfd[StandardInput] := CLB._openfd[StandardOutput] + CLB.O_BINARY - CLB.O_TEXT;

These bits are marked "read only", but in this case you gotta break the rules.

Of course, ideally one should be using the IO module, which doesn't have this 
problem. But I recognize that there might be some instances where one would
desire FIO so that routines can arbitrarily output to any device. Also, you 
can buffer file access with FIO (default is unbuffered, but I always specify
a buffer since it can make major differences in performance), while IO is
always unbuffered.

Simon's original fix has the problem that any file open for appending probably
won't work correctly as _write has the code to reposition the file at the end
while __write does not. Also _write has code to prevent a zero length write
(which truncates the file with MS-DOS).

Tom Almy
toma@tekgvs.labs.tek.com
Standard Disclaimers Apply
Technical Details
Message-ID: <7788@tekgvs.LABS.TEK.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!cs.utexas.edu!rice!uw-beaver!zephyr.ens.tek.com!tekcrl!tekgvs!toma
References: <845@massey.ac.nz>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!cs.utexas.edu!rice!uw-beaver!zephyr.ens.tek.com!tekcrl!tekgvs!toma
From: toma@tekgvs.LABS.TEK.COM (Tom Almy)
Newsgroups: comp.lang.modula2
Subject: Re: JPI TopSpeed FIO.WrBin bug affects only re-directed I/O. Apologies.
Keywords: JPI TopSpeed Modula-2
Message-ID: <7788@tekgvs.LABS.TEK.COM>
Date: 12 Jul 90 15:45:45 GMT
References: <845@massey.ac.nz>
Reply-To: toma@tekgvs.LABS.TEK.COM (Tom Almy)
Organization: Tektronix, Inc., Beaverton,  OR.
Lines: 43