X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Mon, 26 Apr 2010 14:43:32 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: zsh 4.3.9-1: text-mode stdin problem (breaking base64) Message-ID: <20100426124332.GR1845@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <4BCEBF96 DOT 3030201 AT jade DOT plala DOT or DOT jp> <4BD35527 DOT 8020101 AT jade DOT plala DOT or DOT jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <4BD35527.8020101@jade.plala.or.jp> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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