changeset 99311:9e2c3c623db2

(main) [WINDOWSNT]: Don't ifdef away the call to `ttyname'. (w32_getenv): Treat $TERM specially: if not found in the environment and in the Registry, return "w32console". (ttyname) [WINDOWSNT]: New function.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 01 Nov 2008 13:48:55 +0000
parents 8a10e7f2f286
children 90b4d44d8513
files lib-src/emacsclient.c
diffstat 1 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/emacsclient.c	Sat Nov 01 04:37:54 2008 +0000
+++ b/lib-src/emacsclient.c	Sat Nov 01 13:48:55 2008 +0000
@@ -353,8 +353,13 @@
 
   if (! (value = w32_get_resource (HKEY_CURRENT_USER, envvar, &dwType)) &&
       ! (value = w32_get_resource (HKEY_LOCAL_MACHINE, envvar, &dwType)))
-    /* Not found in the registry.  */
-    return NULL;
+    {
+      /* "w32console" is what Emacs on Windows uses for tty-type under -nw.  */
+      if (strcmp (envvar, "TERM") == 0)
+	return xstrdup ("w32console");
+      /* Found neither in the environment nor in the registry.  */
+      return NULL;
+    }
 
   if (dwType == REG_SZ)
     /* Registry; no need to expand.  */
@@ -435,6 +440,13 @@
 #undef execvp
 #define execvp w32_execvp
 
+/* Emulation of ttyname for Windows.  */
+char *
+ttyname (int fd)
+{
+  return "CONOUT$";
+}
+
 #endif /* WINDOWSNT */
 
 /* Display a normal or error message.
@@ -570,10 +582,8 @@
 
   if (!tty && display)
     window_system = 1;
-#if !defined (WINDOWSNT)
   else if (!current_frame)
     tty = 1;
-#endif
 
   /* --no-wait implies --current-frame on ttys when there are file
        arguments or expressions given.  */
@@ -1444,9 +1454,8 @@
     {
       char *type = egetenv ("TERM");
       char *tty_name = NULL;
-#ifndef WINDOWSNT
+
       tty_name = ttyname (fileno (stdout));
-#endif
 
       if (! tty_name)
         {