Re: Mac text files and gets()
- Posted by Robert Craig <rds at RapidEuph?ria.c?m> Sep 17, 2007
- 513 views
Pete Lomax wrote: > Dos/Windows standard is \r\n True, but \n alone will often be accepted by DOS/Windows programs, and certainly by Euphoria. > Linux standard is \n Yes. > Mac standard is \r That's true of old Macs - pre Mac OS X. My understanding is that this is now shifting to \n, since Mac OS X is based on FreeBSD. > This discussion is only about reading files, I take it no changes are proposed > to the way write works. Yes. > Under D/W, "r" mode replaces \r\n with \n, leaves \r alone, alone, and leaves > \n alone, alone. "rb" mode leaves all three as-is. Yes. > Under Linux, both "r" and "rb" mode leave all three alone, correct? Yes. > (no Eu on Mac yet so n/a) > > What happens when Linux finds a \r alone? (leaves it asis, I guess). Yes. > Is there any market for Linux to read D/W files as \n alone? The problem comes up quite often. When using FTP, a file transfer in "text" mode will convert the line-terminators appropriately. There are also trivial little utility programs that can do the same thing. That's how people generally handle this problem. > What is the pukka code for: > > #ifdef EWINDOWS > if (!binary_mode) { > if (c == '\r') { > c = '\n'; There is currently no need to test for binary mode in EGets(). The O/S does the \r\n -> \n thing automatically before EGets() sees the characters. > And lastly, what would the full testset be for all concerned to be happy? I don't think we should bother trying to support foreign systems. Just let each version of Euphoria do what's right for that platform. The rules are complicated enough already. It's trivial to write your own mac_gets() or whatever using getc() in binary mode. To force Euphoria to merge multiple sets of line terminator rules, it will have be somewhat incorrect according to any one set. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com