This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
Re: upload: diffstat-1.40-1, tar-1.15.1-1
On Wed, 17 Aug 2005, Eric Blake wrote:
> > >I'm not sure this is correct. fopen(..., "rt") should create LF endings
> > >on binary mounts and CRLF on text mounts... IIUC, the open mode is a hint
> > >to the underlying filesystem whether line ending translation should be
> > >done -- the actual translation is done based on the mount type.
> >
> > Opening with "rt" bypasses the underlying mount type. And, it only
> > opens the file for read.
>
> But opening with "rt" is non-POSIX, while opening with "r" or "rb" is
> POSIX, so the upstream maintainers are more reluctant to accept
> a patch that uses "rt". I have never seen any standards documentation
> that describes what "rt" should do, so I assumed that it forced
> opening a file in text mode (ie. all \r\n in the file are collapsed to
> \n to the application reading the file, regardless of the mount point
> of the file). It sounds like you are telling me my assumption was
> wrong, and that "rt" on a binary mount point preserves \r?
That's what I was saying, but I was confused. Chris said that text mode
always forces CRLF->LF conversion on reads and LF->CRLF conversion on
writes.
The fact that there are no standards for O_TEXT or "rt"/"wt" didn't help
my confusion any.
It seems that "wt" is rather useless, then. If one wanted to always
produce a file with CRLF line endings, she'd open it with O_BINARY and use
"\r\n" sequences for line endings.
In any case, "rt"/"wt" should be equivalent to O_TEXT...
> Maybe we need an update to
> http://cygwin.com/cygwin-ug-net/using-textbinary.html
Yes, it does say "there is no direct way to specify text mode in an
fopen() call", doesn't it?
Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
If there's any real truth it's that the entire multidimensional infinity
of the Universe is almost certainly being run by a bunch of maniacs. /DA