convincing squeak to use LF instead of CR as the line separator...

Greg A. Woods woods at weird.com
Thu May 24 21:28:01 UTC 2001


[ On Wednesday, May 23, 2001 at 22:20:10 (+0100), John Hinsley wrote: ]
> Subject: Re: convincing squeak to use LF instead of CR as the line separator...
>
> I'm not entirely sure why the LF/CR "thing" is a problem for you. 

The major problem is of course that when my Unix-based squeak writes
ordinary files I want it to always honour the Unix file separator
convention, no matter what!  ;-)

> I've always liked the idea of changing it within Squeak, but I think Ned
> put me off last time.....
 
I have toyed with the idea of searching for all implementers of "cr" (or
at least those that deal with external file streams) and fixing them to
make a platform-dependent line separator, and then inventing
supplemental "ret" and "nl" methods to send bare '\r' and '\n'
characters where necessary (such as in network protocol implementations,
etc.).  I don't know yet though if this would be a reasonable thing to
do from a smalltalk P.O.V., nor how big a task it might turn out to
be....  The big question in my mind isn't how to find and modify the
methods which might generate line separators, but rather how to find and
modify the methods with might read and interpret them.  In theory
anything that reads an external stream as text should be able to either
be strict or liberal (depending perhaps on a user-settable preference)
in what bytes it interprets as line separators.

One thing I do very much want to try to avoid is introducing any concept
of "binary" vs. "text".  Text is just a bunch of data that happens to
have been divided up into some interesting groups by line separators.
Unix got rid of this distinction by making it the responsibility of the
I/O drivers to convert line separators to/from whatever form was
necessary for presentation on (or input from) any given device.  I don't
even remember there being any distinction (outside the card/record
oriented world of old mainframes) between text and binary until folks on
such new-fangled strange platforms as MS-DOS tried to provide unix-like
libraries.

However I don't really want to debate these issues -- just make Squeak
integrate better into at least my current preferred platform.  :-)

> If you only need to change it to make it readable, you can either knock

Under Unix you cannot use some C-language constructs (eg. anything to do
with the pre-processor, or anything with a backslash line continuation)
without using newlines and this means that Squeak-generated C code will
not compile unless it's written with '\n' line separators.  Not all
whitespace is of equal value in C source code....

As for just viewing stuff, well yes I can work around that, but it's a
royal pain to have to do so....

I guess I can live with converting public .cs and .pr files, but if I'm
going to integrate Squeak into more and more of my day-to-day Unix work
then I'll need it to read and write everthing in the same way all my
other tools do, maybe even including .cs and .pr files which I might
want to manipulate in other ways too (eg. with a Unix text editor).

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods at acm.org>     <woods at robohack.ca>
Planix, Inc. <woods at planix.com>;   Secrets of the Weird <woods at weird.com>





More information about the Squeak-dev mailing list