summaryrefslogtreecommitdiff
path: root/w32
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2014-09-15 19:51:41 +0300
committerEli Zaretskii <eliz@gnu.org>2014-09-15 19:51:41 +0300
commit53f8961ee4ce774eaf06f1785acd8ca8b1bdf7de (patch)
tree9731291588d109944ab3a4275c209f5ed827ea01 /w32
parentaea68e0fae0211dd32fe1e9b93caa15722f4510b (diff)
downloadmake-53f8961ee4ce774eaf06f1785acd8ca8b1bdf7de.tar.gz
Support MAKE_TERMOUT and MAKE_TERMERR on MS-Windows.
* w32/compat/posixfcn.c (isatty, ttyname): New functions. * config.h.W32.template (HAVE_TTYNAME): Define. Add a prototype for ttyname.
Diffstat (limited to 'w32')
-rw-r--r--w32/compat/posixfcn.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/w32/compat/posixfcn.c b/w32/compat/posixfcn.c
index 1d852f5f..946f16b2 100644
--- a/w32/compat/posixfcn.c
+++ b/w32/compat/posixfcn.c
@@ -454,3 +454,33 @@ dlclose (void *handle)
#endif /* MAKE_LOAD */
+
+/* MS runtime's isatty returns non-zero for any character device,
+ including the null device, which is not what we want. */
+int
+isatty (int fd)
+{
+ HANDLE fh = (HANDLE) _get_osfhandle (fd);
+ DWORD con_mode;
+
+ if (fh == INVALID_HANDLE_VALUE)
+ {
+ errno = EBADF;
+ return 0;
+ }
+ if (GetConsoleMode (fh, &con_mode))
+ return 1;
+
+ errno = ENOTTY;
+ return 0;
+}
+
+char *
+ttyname (int fd)
+{
+ /* This "knows" that Make only asks about stdout and stderr. A more
+ sophisticated implementation should test whether FD is open for
+ input or output. We can do that by looking at the mode returned
+ by GetConsoleMode. */
+ return "CONOUT$";
+}