This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: zsh and line breaks

> -----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))
#define MAYBE_ADD_O_TEXT_FLAG(x) (x)

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

Can't think of a witty .sigline today....

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]