Re: End-of-line on the Mac?



Alf P. Steinbach wrote:
I don't have a Mac (I'm going to, it's the future, but not for now).

I've seen end-of-line on the Mac described as '\r' (C syntax).

But now, with OS/X being *nix-based, is it still that way, or is it now
'\n'?

The issue is that some C compilers will use \r and \n as abstractions,
others treat them to mean 0d and 0a. Even different ports of the same
compiler do different things.

On Macs EOL is traditionally carriage return ie 0d.
On *nix EOL is line feed 0a.
On Windows EOL is 0d 0a (this is the oldest convention)

Mappings are different though. In the *nix parts of MacOS X EOL is
0x0a I think.

In Cygwin line endings are normally also 0a, there is an option at
install time to set the line ending type. On Windows C compilers
though \n is translated to 0d 0a, even on GCC using Mingw.

To make things even more confusing many *nix and Mac programs will
accept Windows line ending because they are so common. Some Windows
programs accept *nix line endings too.

Really silly things have happened because of this. Some drivers in
Linux 1 kernels were found to have Windows line endings for example.
Similarly Perl source files written with mac line endings don't work on
the version of perl shipped in OS X.

.