CrLfFileStream as default?

lex at lex at
Sat Oct 31 20:32:54 UTC 1998

"R. A. Harmon" <harmonra at> wrote:

> >This sounds basically like what CrLfFileStream does
> [snip]
> >So in my opinion, the only things stopping adoption of CrLfFileStream as a
> default are:
> >
> >	1. a decision on the file positions issue (I vote for "it's illegal",
> >          migrating towards "it's expensive and unadvised")
> >	2. automatically choosing output line endings based on what the current
> >          platform is.  This could be done by putting a "CrLfFileStream >
> guessLineEndConvention" in SystemDictionary.processStartupList.
> [snip]
> I don't think there is any reason for "guessLineEndConvention" in the
> approach I propose and if it guesses wrong (especially on an already
> anomalous file), CrLfFileStream, seems to produce anomalies that I don't
> think are caused just by cut-and-paste.

The purpose of this method is to pick a convention for *new* files.  The idea being if you create a text file on Windows, it should have CRLF line endings, and if you create a file on Unix, it should have LF line endings.  That way you can view Squeak files using other applications on your operating system, without having to convert the files first.

If you don't do this method during startup, then CrLfFileStream won't notice it is operating on a new platform.  It will continue using whatever convention it was using when the image was saved, even if it was saved on a different platform.

Now, there's a second "guess" going on in CrLfFileStream, and that's when a specific file is opened.  This guess is to ensure that new data written to the file will have the same convention as the data that's already in the file.  If you have a CRLF-delimitted file on Unix, then you should keep writing CRLF endings, and not start appeding lines with LF endings.  The point is debatable, I suppose, but that's the purpose of this one.

Now in the CrLfFileStream in the standard image, this second guess is also used when reading.  If the convention was guessed to be CR, then any LF's read in will be left as is.  This is also debatable, and in fact I think that LF's should be converted to CR's no matter what convention has been guessed.

So I sent a patch around a few days ago that did just this.

Now, I've been using this setup for a week or so now with no troubles.  However, I've not messed with any *really* strange files....


More information about the Squeak-dev mailing list