[Pythonmac-SIG] line endings

Oliver Steele steele@cs.brandeis.edu
Sat, 09 Oct 1999 07:09:40 -0400


Joseph J. Strout writes:
>>OK, here's a patch (at http://www.strout.net/python/mac/) which
>>extends the IDE's editor in a couple of ways:

Jim Harrison writes:
> For newbies like me--remember to change the line endings to Mac after the
> files are downloaded, at least when downloading by dragging out of the
> Navigator window. BBedit or BBedit Lite works well for this. Bad things
> happen if you run these patches with unix line endings.

The 1.5.2c1 PythonIDE can also do this.  (It incorporates the
PythonIDE-crlf-patch.txt patch I sent mail about a few months ago.)  Open a
UNIX or DOS-style file with the IDE, and it will ask whether to convert the
line separators.  Confirm, and then save the file.

<http://developer.apple.com/technotes/tn/tn1176.html> says that the StdCLib
shared library has been changed for MacOS 9, such that "fgets now recognizes
line endings for Mac, DOS, and UNIX files."  I wonder if MacPython will
inherit this behavior?  (I don't know have access to MacOS 9, and I haven't
read the Python sources to see where file.readline() is coming from, and
whether the compiler uses this.)  If it does, then UNIX/DOS-originated
source files should compile under MacOS 9 (and anything else that uses
readline should start working on foreign text files too).  The editor will
still need special casing to treat foreign line separator sequences as line
separators, but if readline() and the compiler treat them the same, then the
editor should be changed to do the conversion silently a la BBEdit, Alpha,
and the Metrowerks IDE.