Mantis - Squeak
Viewing Issue Advanced Details
6173 Files major always 02-19-07 22:39 11-18-08 20:25
closed 3.9  
none 3.10  
0006173: Auto-detection of cr/lf is broken on MacOS X
Whenever an image is restarted, CrLfFileStream class >> startUp invokes CrLfFileStream class >> guessDefaultLineEndConvention to reset the class variable LineEndDefault to one of #cr, #lf or #crlf.
This variable is used to determine the cr translation to be used. The same logic has been copied into MultiByteFileStream.

The guessDefaultLineEndConvention uses the pathNameDelimiter of the deafult directory class to figure out which file system we are running on. This used to be correct, because Mac VMs ran on Mac file systems. But it is no longer correct: the right file directory on MacOSX is UnixFileDirectory, so this no longer suffices to distinguish Mac from ordinary Unix.
I propose a fix in the attached changeset which makes the guessDefaultLineEndConvention look and see if the underlying platform is darwin (Mac OS's Unix), and if so choose #cr as the default line ending. The change is copied to both CrLfFileStream class >> guessDefaultLineEndConvention and MultiByteFileStream >> guessDefaultLineEndConvention.

You might think that this code should go in a trait, so that it coulbe be sahred between the two classes. Or that MultiByteFileStream should subclass CrLfFileStream. But, in fact, CrLfFileStream is dead: its new method creates a MultiByteFileStream. So all of its methods except for CrLfFileStream new could be deleted. (Or, MultiByteFileStream could subclass CrLfFileStream, use basicNew, and all of its methods that replicate the superclass could be deleted.) Right now, however, I'm more concerned with getting the bug fixed than with getting the code cleaned up.
 guessLineEndFix.1.cs [^] (1,332 bytes) 02-19-07 22:40
 CrLfFileStream on MacOSX.txt [^] (15,136 bytes) 02-19-07 22:44

02-19-07 22:49   
I've also attached an archive of the discussion on Squeak-dev on this topic. What I learned from this is that John McIntosh believs that the MacFileDirectory classes are now for Mac OS 9 and earlier only , and that UnixFileDirectory is the right choice for MacOS X systems.
11-18-08 20:25   
Harvested in update 7117 and released in Squeak 3.10.