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: Micah Cowan
Subject: Re: Text tools, line endings, and O_TEXT
Date: Thu, 06 Sep 2007 10:21:27 -0700
User-agent: Thunderbird 1.5.0.13 (X11/20070824)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Eric Blake wrote:
> John Cowan <cowan <at> ccil.org> writes:
> 
>> Are you saying that an O_TEXT open under Cygwin, given a binary mount,
>> will cause newline translation?  I had assumed that O_TEXT would be
>> ignored under Cygwin just as it is under Linux.
> 
> Yes.  The cygwin behavior is as follows:
> 
> open(O_RDONLY), fopen("r") - open the file using the mount point rules to 
> decide whether the file is text or binary
> 
> open(O_RDONLY|O_TEXT), fopen("rt") - open the file forced in text, regardless 
> of mount point

<snip>

> 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. Thus, having a "t" is
redundant, and treating it as different from "r" is broken from the
stadnard's POV, AFAICT.

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG4DcX7M8hyUobTrERCKk9AJ0dmBYQc9mvmruB+ycXS0ARw1tiYQCePjfz
qMAYAM2vnWpcFyGDuVW+Er0=
=ocRY
-----END PGP SIGNATURE-----




reply via email to

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