bug-gnulib
[Top][All Lists]
Advanced

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

Re: new module 'isatty'


From: Bruno Haible
Subject: Re: new module 'isatty'
Date: Tue, 03 Jan 2012 15:06:10 +0100
User-agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )

Eli Zaretskii wrote:
> > Because that would yield warnings when you compile on mingw with "-Wall".
> 
> I compiled with -Wall (using intptr_t) and didn't have any warnings.
> Maybe you are using a newer (= more pedantic) version of GCC.

Maybe I misremembered, and it was MSVC which gave the warnings.

> > Well, I tested also aux, com, com1, lpt, lpt1, prn, and none of these
> > resulted in a successful open() call. Only nul and con could be open()ed,
> > and only for nul was the value of _isatty() wrong. Tested on Windows XP
> > (with no printer connected). YMMV.
> 
> You don't need to open them, you can use redirection:
> 
>   _isatty < nul > prn 2>aux
> 
> I tested this on XP, and I see the value 64 returned by _isatty for
> every character device.
> 
> Btw, it also works for me to open them, but I tried `fopen', not
> `open'.

Hmm, even the redirection does not give these results for me:

$ cat foo.c
#include <stdio.h>
#include <windows.h>
#include <io.h>
#include <fcntl.h>
int main (int argc, char*argv[])
{
  fprintf (stderr, "%d -> %d\n", 0, isatty (0));
  fprintf (stderr, "%d -> %d\n", 1, isatty (1));
  return 0;
}
$ gcc -mno-cygwin -Wall foo.c
$ cmd
>.\a.exe > nul
0 -> 0
1 -> 64

>.\a.exe > con
0 -> 0
1 -> 64

>.\a.exe > aux
The system cannot find the specified file.

>.\a.exe > prn
The system cannot find the specified file.

>.\a.exe > lpt
0 -> 0
1 -> 0

>.\a.exe > lpt0
0 -> 0
1 -> 0

>.\a.exe > com
0 -> 0
1 -> 0

>.\a.exe > com0
0 -> 0
1 -> 0

>.\a.exe > com1
The system cannot find the specified file.

Apparently you have a different version of Windows than I have...

Bruno




reply via email to

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