[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Yet more on linefeeds.



At 14:01 -0600 4/18/99, Doug McNutt wrote:
>That ought to be done! It's just possible that the line ends are in fact
>determined at a system level well below the perl parser. There were once
>system level I/O calls which read to "end of line". AOS, CP/M, and VMS did
>things like that but I donno about MSDOS, WindozeXX, BIOS's, and CMOS's. In
>the MacOS the PBRead system call has provision for "newline" mode which
>surely looks for \r, the correct character for the system at hand.

Well, no.  The parameter block contains the (one ASCII) character which is
treated as the newline character.  That character goes into the high byte
of a 16-bit thing, and bit 7 is set on.

Here is what a 1995 Tech Note ("Inside Macintosh -- Files Errata") says
about bit 7 and the high byte:

Bit 7 of ioPosMode is a request for newline mode.  If bit 7 is set, then
the high-byte of ioPosMode is the newline character - even if that
character is null ($00).  When bit 7 is set, the read should stop when any
one of these conditions is med:

*  ioReqCount bytes have been read
*  End-of-file is reached
*  The newLine character has been read.  If the NewLine character is found,
it will be the last character put into ioBuffer and ioActCount will include
it.

When using newLine mode, the HFS file system reads the file one block
(512-bytes) at a time into a file system cache block ... then copies the
data into the user buffer one byte at a time looking at each byte for the
newLine character.  Since a file read with newLine mode is read one block
at a time, newLine mode is about the slowest way you can read a file.

-----------
So newLine mode won't help with being flexible about what is newLine, and
can't deal with multi-character ones (there's a risk of the requested byte
count being reached between the two parts of a DOS newline).

Not helpful in the implementation of MacPerl, I think.  (Really not helpful
in many contexts.)

   --John
--
John Baxter   jwblist@olympus.net      Port Ludlow, WA, USA
Give a man a fish and you feed him for a day.  Teach him to fish,
and you get rid of him for the weekend.

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org