The Icon implementation is very simple: they *still* open the file in stdio text mode. "What's natural for the platform" on writing then comes for free. On reading, libc usually takes care of what's needed, and what remains is to check for stray '\r' characters that stdio glossed over.
This'll work for Unix and PC conventions, but not for the Mac. Mac end of line is \r, so reading a line from a mac file on unix will give you the whole file. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm
[Tim]
On reading, libc usually takes care of what's needed, and what remains is to check for stray '\r' characters that stdio glossed over.
[Jack Jansen]
This'll work for Unix and PC conventions, but not for the Mac. Mac end of line is \r, so reading a line from a mac file on unix will give you the whole file.
I don't see how. Did you look at the code I posted? It treats '\r' the same as '\n', except that when it sees an '\r' it eats a following '\n' (if any) too, and replaces the '\r' with '\n' regardless. Maybe you're missing that Python reads lines one character at a time? So e.g. the behavior of the platform libc fgets is irrelevant.
participants (2)
-
Jack Jansen
-
Tim Peters