Date : Thu, 09 Oct 1986 15:35:32 GMT
From : Stu Heiss <stu%jpusa1.uucp@BRL.ARPA>
Subject: standardizing BDS C (sort of)
In article <882@sigma.UUCP> bill@sigma.UUCP (William Swan) writes:
-Has anybody "standardized" BDS C?
-I would like to reorganize the standard libraries so that the "new"
-standard functions would work just like the "real" thing. A quick
-survey shows the following routines (there may be others) to be
-(possibly) nonstandard in some potentially critical way:
- puts() getline()?
- open() creat() read() write() seek()? tell()?
- fopen() fgets()?
-If anybody has done this before (or knows of it being done), I would
-appreciate sources, pointers, or hints.
I came up with a quick and dirty solution for the buffered i/o stuff via
defines and a small library. It went something like this. stdio.h for
bdsc is basically bdscio.h with some defines that map fopen to ufopen,
fclose to ufclose and so-on. The library file (I called it unixio.c)
has the ufopen which uses malloc to get a buffer and bdsc's fopen to do
the actual open after parsing the mode field. ufclose frees the buffer
and calls fclose. The higher level calls are easily handled this way
but read/write/seek/tell will need a complete rewrite. Seek and tell
really can't be done without longs anyway. As long as your code sticks
to buffered i/o, this works fine and is easy to implement. While you're
at it, put the whole malloc library in unixio and save yourself further
headaches. The code in k&r will do.
--
Stu Heiss {ihnp4!jpusa1!stu}