This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: zsh 4.3.9-1: text-mode stdin problem (breaking base64)
On Apr 25 05:31, Yutaka Amanai wrote:
> 2010/04/24 10:03 Peter A. Castro wrote:
> >>Could you give me a simple test case that fails without
> >>cygwin_premain0()? I set my filesystems as text-mode and tried to find
> >>such cases, but I couldn't.
> >
> >It's been a while since I've looked at this, but the problem was mostly
> >with binary-mode mounts, not text-mode mounts. The problem was that,
> >say, you had your root mounted as text-mode, but your /tmp mounted as
> >binary-mode. Zsh (and other utilities) create temp files fairly often
> >and feed those as input to itself or other programs. Or, reverse the
> >case (root mounted binary and /tmp mounted text).
> >
> >{f}open() in Cygwin is context sensitive to the filesystem mount mode.
> >This leads to such situations as calling fopen("/tmp/foo","r") and
> >expecting it to read "text" lines, but "/tmp" is mounted binary and file
> >"foo" contains CRLF's because it was created by a Windows program or
> >editor. So, when you read the lines you will get the CR as well as the
> >LF, when you really only want the LF. Where as if "/tmp" was mounted
> >text, the CR would be stripped off as part of text processing.
> Thank you. Indeed, even if a person mounts root (or some
> filesystems) as text-mode, still he might mount /tmp as binary-mode.
> So, I see that we need to take measures to meet such cases.
Tcsh has a long history of running on Windows NT natively, so it had to
find a solution for the CRLF problem long ago. It uses the (IMHO) only
correct approach. Always open stdio descriptors with default mode.
*Only* when reading scripts, always check for a CR right in front of an
LF and just ignore it.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple