www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/04/02/04:51:09

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Dave Korn" <dk AT artimi DOT com>
To: <zsh-workers AT sunsite DOT dk>, <cygwin AT cygwin DOT com>
Subject: RE: zsh and line breaks
Date: Fri, 2 Apr 2004 10:49:47 +0100
MIME-Version: 1.0
In-Reply-To: <Pine.LNX.4.53.0404011224320.9892@gremlin.fruitbat.org>
Message-ID: <NUTMEGDMqgKqKTnwjiv00000328@NUTMEG.CAM.ARTIMI.COM>
X-OriginalArrivalTime: 02 Apr 2004 09:49:47.0968 (UTC) FILETIME=[D5D26400:01C41897]

> -----Original Message-----
> From: cygwin-owner On Behalf Of Peter A. Castro
> Sent: 01 April 2004 22:21

>   In system.h I've added a #define in the #ifdef 
> __CYGWIN__ section of:
> #define ORO_TEXT | O_TEXT
> And for the #else case:
> #define ORO_TEXT
> 
> Then in code which needs it I have modified it to look like this:
> 
> if ((fd = open(name, O_RDONLY ORO_TEXT)) < 0) {
> 
> It's really just utilizing the macro ability of the compiler, 
> and it's a
> style judgement call.  I don't have a problem with it, obviously, but
> others might look at it and wonder how it could possible 
> compile if they
> didn't look in system.h first.  If you think that might present
> confusion, then I'll change it to be explicitly "| OR_TEXT" and have
> #define O_TEXT to be 0 if not defined at all.
> 
> Any thoughts on this?

  It's pretty reasonable but as you say could be confusing.  Here's another
approach that might seem nicer because it's kind of function-like:

#ifdef __CYGWIN__
#define MAYBE_ADD_O_TEXT_FLAG(x) (O_TEXT | (x))
#else
#define MAYBE_ADD_O_TEXT_FLAG(x) (x)
#endif

Then say

if ((fd = open(name, MAYBE_ADD_O_TEXT_FLAG(O_RDONLY))) < 0) {

You might well want to choose a better name for the function-like macro than
that, but I think the pattern is slightly clearer.

> The primary problem is with running scripts with CR/LFs.  
> That gets fixed
> with adding O_TEXT everywhere.  A secondary problem is with redirected
> input and/or output which is processed by the shell.
> 
> I've been reviewing this problem and I think maybe I've been 
> attacking it
> incorrectly.  I had though that adding O_TEXT everywhere 
> would solve this
> problem.  However, the environment is complicating things :)
> 
> Here's the deal:

>  So where the file located in the filesystem 
> determines
> the default handling of translation when opened as a text file.
> This is for normal unix style coding of opens without any O_TEXT or
> O_BINARY cruft.
> 
> Now, adding an explicit O_TEXT or O_BINARY forces one mode or 
> the other,
> ignoring the filesystem mount attributes.  The problem is, I 
> don't want
> to force the mode, 
> 
> Thanks for listening.  Any suggestions are welcome.

  Doesn't the POSIX standard specify something about shells should open
stdin, stdout and stderr in textmode?  IOW, aren't you obliged to force the
mode?



    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019