[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MS-Windows build of Grep [2/4]
From: |
bastien ROUCARIES |
Subject: |
Re: MS-Windows build of Grep [2/4] |
Date: |
Fri, 30 Dec 2011 12:36:07 +0100 |
User-agent: |
KMail/1.13.7 (Linux/3.1.0-1-amd64; KDE/4.6.5; x86_64; ; ) |
Le Wednesday 28 December 2011 18:12:06, Eli Zaretskii a écrit :
> > Date: Wed, 28 Dec 2011 17:06:05 +0100
> > From: Bastien ROUCARIES <address@hidden>
> > Cc: Eli Zaretskii <address@hidden>, bug-gnulib <address@hidden>,
> > address@hidden
> >
> > Isatty is broken under windows but this not the right fix.
>
> What's wrong about it? If it fails under some conditions, please
> describe them.
>
> > 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.
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;
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.
With this code is it is guaranted that only CON will be considered as
interactive.
if you want to test modem and COM port you should use GetCommProperties and
dwProvSubType member of COMMPROP structure.
Sorry for first top post from my mobile phone
Thanks
Bastien