bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MS-Windows build of Grep [2/4]


From: Eli Zaretskii
Subject: Re: MS-Windows build of Grep [2/4]
Date: Fri, 30 Dec 2011 18:11:22 +0200

> From: bastien ROUCARIES <address@hidden>
> Date: Fri, 30 Dec 2011 12:36:07 +0100
> Cc: address@hidden,
>  address@hidden,
>  address@hidden
> 
> > > In fact isatty under windows is equivalent to test if a file is a char
> > > device.
> > 
> > That is true.  But unless a Windows user goes out of their way, the
> > only character device they will ever see in routine operations is the
> > null device.
> Not true LPT is also a char device, and I use it for jtag stuff.

And the code I submitted says LPT is not a TTY.  In fact, it works
with every character device I tried: PRN, CLOCK$, and AUX.  So I see
no problem with the code I proposed.  Which character devices succeed
to dupe it?

> The right fix is :
> DWORD st;
> /* note use _ version for porting to vc */
> if(!_isattty(fd))
>       return 0;
> if (!GetConsoleMode(_get_osfhandle(fd), &st)) 
>       return 0;
> return 1;

Thanks.

> This is the idea, it is a little bit more complicated due to INVALID_HANDLE 
> exception raising in _get_osfhandle(fd) but the idea 
> is here. And moreover erno handling.

Further complications are the need to include windows.h, which could
interact in nasty ways with standard C headers or even macros such as
DATADIR.  So if the code I proposed doesn't break in practice, I think
its simplicity is a win.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]