bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text tools, line endings, and O_TEXT


From: Eric Blake
Subject: Re: Text tools, line endings, and O_TEXT
Date: Thu, 06 Sep 2007 21:24:24 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Micah Cowan on 9/6/2007 11:21 AM:
>> Using O_BINARY is important, however, I claim that using O_TEXT in portable 
>> code should be a very rare circumstance.  There's a reason that C99 only 
>> calls 
>> out fopen("r") and fopen("rb"), but not fopen("rt").
> 
> The reason C99 uses "r" and not "rt", is that, unless "b" is specified,
> it is _always_ supposed to be opened in text-mode.

To which POSIX adds that "r" and "rb" must be identical in POSIX-compliant
systems (ie. text mode IS binary mode in a sane system), which is why
POSIX does not even specify O_BINARY, let alone O_TEXT.

> Thus, having a "t" is
> redundant, and treating it as different from "r" is broken from the
> stadnard's POV, AFAICT.

No, there is NO standard that specifies the behavior of "rt", therefore
"rt" can behave however it wants, including being different from "r" in
the case when you are on a binary mount and POSIX rules require "r" to
match "rb", but you still have a reason to perform text-mode translations.

But I digress - at this point, we seem to be debating about design
decisions of cygwin, which are probably more appropriate on the cygwin
list than here.  The original suggestion is whether upstream coreutils
should be taught how to recognize alternate line ending schemes without
the aid of unspecified text mode extensions available only on some
non-POSIX systems, to which I don't have very many good ideas (or rather,
I don't have any patches to propose, and ideas without patches don't go
very far).

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG4MRn84KuGfSFAYARAk0nAKCdWmJ+BD1bYTOQzJs7L9nt/hvVfwCdGwIq
+HMHRa8kjHBTwCZhrjSzKmY=
=aaCa
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]