www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/02/23/17:32:40

From: "Juan Manuel Guerrero" <ST001906 AT HRZ1 DOT HRZ DOT TU-Darmstadt DOT De>
Organization: Darmstadt University of Technology
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Date: Fri, 23 Feb 2001 23:31:48 +0200
MIME-Version: 1.0
Subject: Re: gettext pretest available
CC: Bruno Haible <haible AT ilog DOT fr>, djgpp-workers AT delorie DOT com
X-mailer: Pegasus Mail for Windows (v2.54DE)
Message-ID: <2D628811C2A@HRZ1.hrz.tu-darmstadt.de>
Reply-To: djgpp-workers AT delorie DOT com

On Fri, 23 Feb 2001 09:44:52 +0200, Eli Zaretskii:

> > > Then the setmode() macro should take care of it.
> > I will assume you are makeing reference to setmode() macro defined in lib/system.h.
> > I will add a setmode() macro to system.h for djgpp:
> > 1) DJGPP:
> > # define setmode(fd, mode)      do { \
> >                                   if (!isatty ((fd))) \
> >                                     setmode ((fd), mode); \
> >                                 } while (0)
>
> This will only DTRT if this macro is called _only_ for switching
> stdin/stdout to binary mode and back.  If you ever call the macro on a
> handle other than 0 or 1, it might silently do nothing without a good
> reason.
>
> It is okay to do this if you _know_ setmode will only be invoked on
> stdin/stdout, but I'd suggest a prominent comment to that effect where
> the macro is defined, lest someone forgets this caveat.

Unfortunately I do not understand this objection.
The goal of the macro is to *inhibit* the switching of *every* file handle
conected to a console. All other handles should be *serviced* as usual.
1) Lets assume file handle fd **is** connected to a console.
   In this case the test: !isatty(fd) will be *false* and the file handle
   will retain its mode whatever this may be. The macro inhibits mode switching
   ot the console as wanted.
2) Now, lets assume fd is **not** connected to a console. This time the
   test: !isatty(fd) will be *true* and the following setmode() function
   will be called switching the mode of the handle.
Once again: the setmode macro should be transparent for all handles **not
associated** to a console and should ignore any mode switch request for all
handles **associated** to a console. This macro will *not* allow any mode 
switching of a handle connected to console. This is certainly very drastic
but for our purposes in this code it is ok, IMHO.
Am I missing something? If I am missing something an appropiate code snippet
that will DTRT will be iluminating.

- Raw text -


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