diff src/console-tty.c @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents ec9a17fef872
children c7528f8e288d
line wrap: on
line diff
--- a/src/console-tty.c	Mon Aug 13 09:00:04 2007 +0200
+++ b/src/console-tty.c	Mon Aug 13 09:02:59 2007 +0200
@@ -42,9 +42,9 @@
 DEFINE_CONSOLE_TYPE (tty);
 
 Lisp_Object Qterminal_type;
-Lisp_Object Qcontrolling_process;
 
-extern Lisp_Object Vstdio_str; /* in console-stream.c */
+Lisp_Object Vstdio_str;
+
 
 static void
 allocate_tty_console_struct (struct console *con)
@@ -63,16 +63,14 @@
 static void
 tty_init_console (struct console *con, Lisp_Object props)
 {
-  Lisp_Object tty = CONSOLE_CONNECTION (con);
-  Lisp_Object terminal_type = Qnil, controlling_process = Qnil;
+  Lisp_Object tty = CONSOLE_CONNECTION (con), terminal_type = Qnil;
   int infd, outfd;
-  struct gcpro gcpro1, gcpro2;
+  struct gcpro gcpro1;
 
-  GCPRO2 (terminal_type, controlling_process);
+  GCPRO1 (terminal_type);
 
   terminal_type = Fplist_get (props, Qterminal_type, Qnil);
-  controlling_process = Fplist_get(props, Qcontrolling_process, Qnil);
-  
+
   /* Determine the terminal type */
 
   if (!NILP (terminal_type))
@@ -89,10 +87,6 @@
 	terminal_type = build_string (temp_type);
     }
 
-  /* Determine the controlling process */
-  if (!NILP (controlling_process))
-    CHECK_INT (controlling_process);
-
   /* Open the specified console */
 
   allocate_tty_console_struct (con);
@@ -116,8 +110,16 @@
 								   -1, 0);
   CONSOLE_TTY_DATA (con)->outstream = make_filedesc_output_stream (outfd, 0,
 								   -1, 0);
+#ifdef MULE
+  CONSOLE_TTY_DATA (con)->instream =
+    make_decoding_input_stream (XLSTREAM (CONSOLE_TTY_DATA (con)->instream),
+				Fget_coding_system (Vkeyboard_coding_system));
+  Lstream_set_character_mode (XLSTREAM (CONSOLE_TTY_DATA (con)->instream));
+  CONSOLE_TTY_DATA (con)->outstream =
+    make_encoding_output_stream (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream),
+				 Fget_coding_system (Vterminal_coding_system));
+#endif /* MULE */
   CONSOLE_TTY_DATA (con)->terminal_type = terminal_type;
-  CONSOLE_TTY_DATA (con)->controlling_process = controlling_process;
   if (NILP (CONSOLE_NAME (con)))
     CONSOLE_NAME (con) = Ffile_name_nondirectory (tty);
   {
@@ -205,44 +207,46 @@
   return CONSOLE_TTY_DATA (decode_tty_console (console))->terminal_type;
 }
 
-DEFUN ("console-tty-controlling-process", Fconsole_tty_controlling_process, 0, 1, 0, /*
-Return the controlling process of TTY console CONSOLE.
-*/
-       (console))
-{
-  return CONSOLE_TTY_DATA (decode_tty_console (console))->controlling_process;
-}
-
-extern Lisp_Object stream_semi_canonicalize_console_connection(Lisp_Object,
-							       Error_behavior);
 Lisp_Object
 tty_semi_canonicalize_console_connection (Lisp_Object connection,
 					  Error_behavior errb)
 {
-  return stream_semi_canonicalize_console_connection (connection, errb);
+  if (NILP (connection))
+    return Vstdio_str;
+
+  return connection;
 }
 
-extern Lisp_Object stream_canonicalize_console_connection(Lisp_Object,
-							  Error_behavior);
 Lisp_Object
 tty_canonicalize_console_connection (Lisp_Object connection,
 				     Error_behavior errb)
 {
-  return stream_canonicalize_console_connection (connection, errb);
+  if (NILP (connection) || !NILP (Fequal (connection, Vstdio_str)))
+    return Vstdio_str;
+
+  if (!ERRB_EQ (errb, ERROR_ME))
+    {
+      if (!STRINGP (connection))
+	return Qunbound;
+    }
+  else
+    CHECK_STRING (connection);
+
+  return Ffile_truename (connection, Qnil);
 }
 
 Lisp_Object
 tty_semi_canonicalize_device_connection (Lisp_Object connection,
 					 Error_behavior errb)
 {
-  return stream_semi_canonicalize_console_connection (connection, errb);
+  return tty_semi_canonicalize_console_connection (connection, errb);
 }
 
 Lisp_Object
 tty_canonicalize_device_connection (Lisp_Object connection,
 				    Error_behavior errb)
 {
-  return stream_canonicalize_console_connection (connection, errb);
+  return tty_canonicalize_console_connection (connection, errb);
 }
 
 
@@ -254,9 +258,7 @@
 syms_of_console_tty (void)
 {
   DEFSUBR (Fconsole_tty_terminal_type);
-  DEFSUBR (Fconsole_tty_controlling_process);
   defsymbol (&Qterminal_type, "terminal-type");
-  defsymbol (&Qcontrolling_process, "controlling-process");
 }
 
 void
@@ -279,4 +281,7 @@
 vars_of_console_tty (void)
 {
   Fprovide (Qtty);
+
+  Vstdio_str = build_string ("stdio");
+  staticpro (&Vstdio_str);
 }