* Eliminate obsolete TTY I/O primitives. These have not been used for
authorChris Hanson <org/chris-hanson/cph>
Mon, 5 Nov 1990 11:55:48 +0000 (11:55 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 5 Nov 1990 11:55:48 +0000 (11:55 +0000)
  several months now.

* If stdin or stdout is a terminal, save its state when entering
  Scheme, and restore it when leaving, as is done with the control
  terminal.  Ignore any attempts to change the state if Scheme is not
  in the foreground.  This code helps prevent buggy Scheme programs
  from screwing up the user's terminal.

* On machines with TERMIOS and BSD_JOB_CONTROL, such as HP-UX, alter
  VSUSPC and t_suspc together.  Altering one and not the other can
  cause the change to be lost.

12 files changed:
v7/src/microcode/osterm.h
v7/src/microcode/ostty.h
v7/src/microcode/prosterm.c
v7/src/microcode/prostty.c
v7/src/microcode/sysprim.c
v7/src/microcode/uxctty.c
v7/src/microcode/uxterm.c
v7/src/microcode/uxterm.h
v7/src/microcode/uxtop.c
v7/src/microcode/uxtty.c
v7/src/microcode/version.h
v8/src/microcode/version.h

index 5a75a0be388fd7d4cf7dd46e23166b63b4af286a..a9bb60dafc2befe5a7f36f2789a26476937dd1db 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osterm.h,v 1.3 1990/11/01 04:33:05 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osterm.h,v 1.4 1990/11/05 11:55:01 cph Exp $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -37,8 +37,6 @@ MIT in each case. */
 
 #include "os.h"
 
-extern int EXFUN (OS_terminal_read_char, (Tchannel channel));
-extern int EXFUN (OS_terminal_char_ready_p, (Tchannel channel, clock_t delay));
 extern unsigned int EXFUN (OS_terminal_get_ispeed, (Tchannel channel));
 extern unsigned int EXFUN (OS_terminal_get_ospeed, (Tchannel channel));
 extern unsigned int EXFUN (arg_baud_index, (unsigned int argument));
index 93f8e80e8ad62f01d78b0a4b2f42222ab40d9064..33db9b756ea67808b6aa5d9eb1d2c070cdd58392 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ostty.h,v 1.1 1990/06/20 19:36:54 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ostty.h,v 1.2 1990/11/05 11:55:06 cph Rel $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -37,43 +37,12 @@ MIT in each case. */
 
 #include "os.h"
 
-/* New interface uses standard terminal and channel I/O. */
 extern Tchannel EXFUN (OS_tty_input_channel, (void));
 extern Tchannel EXFUN (OS_tty_output_channel, (void));
 extern unsigned int EXFUN (OS_tty_x_size, (void));
 extern unsigned int EXFUN (OS_tty_y_size, (void));
 extern CONST char * EXFUN (OS_tty_command_beep, (void));
 extern CONST char * EXFUN (OS_tty_command_clear, (void));
-
-/* These are for the convenience of the microcode. */
-extern void EXFUN (OS_tty_write_char, (unsigned char c));
-extern void EXFUN (OS_tty_write_string, (CONST char * string));
-extern void EXFUN (OS_tty_beep, (void));
-
-/* Old interface requires special entry points and buffered output. */
-extern int EXFUN (OS_tty_char_ready_p, (clock_t delay));
-extern unsigned char EXFUN (OS_tty_read_char, (void));
-extern unsigned char EXFUN (OS_tty_read_char_immediate, (void));
-
-/* `OS_tty_clean_interrupts' is used to clear the input buffer when a
-   character interrupt is received.  On most systems this is not
-   currently used, but the Emacs interface needs some assistance.
-   Normally this is used in conjunction with some kind of
-   distinguished marker in the input stream that indicates where each
-   interrupt occurred.
-
-   The `mode' argument allows the following values:
-
-   `tty_clean_most_recent' indicates that the input buffer should be
-   flushed up to and including the most recent interrupt marker.
-
-   `tty_clean_multiple_copies' indicates that all interrupts which
-   match `interrupt_char' should be removed from the input buffer.
-   Any other interrupts should be left alone. */
-
-enum tty_clean_mode { tty_clean_most_recent, tty_clean_multiple_copies };
 extern cc_t EXFUN (OS_tty_next_interrupt_char, (void));
-extern int EXFUN
-  (OS_tty_clean_interrupts, (enum tty_clean_mode mode, cc_t interrupt_char));
 
 #endif /* SCM_OSTTY_H */
index e645f2c32184aa1319b3f490caf45ed787ac19b7..1bc4488c468b3cc5093e7141b4be0e1759ef6420 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prosterm.c,v 1.4 1990/11/01 06:16:39 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prosterm.c,v 1.5 1990/11/05 11:55:10 cph Exp $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -49,27 +49,6 @@ DEFUN (arg_terminal, (argument_number), int argument_number)
   return (channel);
 }
 
-DEFINE_PRIMITIVE ("TERMINAL-READ-CHAR", Prim_terminal_read_char, 1, 1,
-  "Read and return a single character from TERMINAL.")
-{
-  PRIMITIVE_HEADER (1);
-  {
-    int c = (OS_terminal_read_char (arg_terminal (1)));
-    PRIMITIVE_RETURN ((c < 0) ? SHARP_F : (ASCII_TO_CHAR (c)));
-  }
-}
-
-DEFINE_PRIMITIVE ("TERMINAL-CHAR-READY?", Prim_terminal_char_ready_p, 2, 2,
-  "Return #T if a character from TERMINAL.\n\
-Second arg DELAY says how long to wait for one to arrive, in milliseconds.")
-{
-  PRIMITIVE_HEADER (2);
-  PRIMITIVE_RETURN
-    (BOOLEAN_TO_OBJECT
-     (OS_terminal_char_ready_p ((arg_terminal (1)),
-                               (arg_nonnegative_integer (2)))));
-}
-
 DEFINE_PRIMITIVE ("TERMINAL-GET-ISPEED", Prim_terminal_get_ispeed, 1, 1, 0)
 {
   PRIMITIVE_HEADER (1);
index 577bd7b0237b695b8e91c82d249e509a80861899..b7212e5d3156dd7eab1c53ae3816679281929965 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prostty.c,v 1.1 1990/06/20 19:38:38 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prostty.c,v 1.2 1990/11/05 11:55:15 cph Rel $
 
 Copyright (c) 1987, 1988, 1989, 1990 Massachusetts Institute of Technology
 
@@ -42,37 +42,6 @@ MIT in each case. */
 #include "osfile.h"
 #include "osio.h"
 \f
-static int transcript_file_open;
-static Tchannel transcript_channel;
-
-void
-DEFUN_VOID (OS_initialize_transcript_file)
-{
-  transcript_file_open = 0;
-  return;
-}
-
-DEFINE_PRIMITIVE ("TRANSCRIPT-ON", Prim_transcript_on, 1, 1, 0)
-{
-  PRIMITIVE_HEADER (1);
-  if (transcript_file_open)
-    error_external_return ();
-  transcript_channel = (OS_open_output_file (STRING_ARG (1)));
-  transcript_file_open = 1;
-  PRIMITIVE_RETURN (UNSPECIFIC);
-}
-
-DEFINE_PRIMITIVE ("TRANSCRIPT-OFF", Prim_transcript_off, 0, 0, 0)
-{
-  PRIMITIVE_HEADER (0);
-  if (transcript_file_open)
-    {
-      OS_channel_close (transcript_channel);
-      transcript_file_open = 0;
-    }
-  PRIMITIVE_RETURN (UNSPECIFIC);
-}
-
 DEFINE_PRIMITIVE ("TTY-INPUT-CHANNEL", Prim_tty_input_channel, 0, 0,
   "Return the standard input channel.")
 {
@@ -114,118 +83,7 @@ DEFINE_PRIMITIVE ("TTY-COMMAND-CLEAR", Prim_tty_command_clear, 0, 0,
   PRIMITIVE_HEADER (0);
   PRIMITIVE_RETURN (char_pointer_to_string (OS_tty_command_clear ()));
 }
-\f
-DEFINE_PRIMITIVE ("TTY-READ-CHAR-READY?", Prim_tty_read_char_ready_p, 1, 1,
-  "This is an obsolete primitive.\n\
-Return #T iff a character is ready to be read from the console.\n\
-Argument DELAY says how many milliseconds to wait for a character.\n\
-If a character is typed, #T is returned immediately,\n\
- otherwise #F is returned after DELAY has expired.")
-{
-  PRIMITIVE_HEADER (1);
-  PRIMITIVE_RETURN
-    (BOOLEAN_TO_OBJECT (OS_tty_char_ready_p (arg_nonnegative_integer (1))));
-}
 
-DEFINE_PRIMITIVE ("TTY-READ-CHAR", Prim_tty_read_char, 0, 0,
-  "This is an obsolete primitive.\n\
-Read a character from the console.\n\
-The operating system's input editor is used to provide the character.")
-{
-  PRIMITIVE_HEADER (0);
-  {
-    char c = (OS_tty_read_char ());
-    if (transcript_file_open)
-      {
-       if ((OS_channel_write (transcript_channel, (&c), 1)) != 1)
-         error_external_return ();
-      }
-    PRIMITIVE_RETURN (ASCII_TO_CHAR (c));
-  }
-}
-
-DEFINE_PRIMITIVE ("TTY-READ-CHAR-IMMEDIATE", Prim_tty_read_char_immediate, 0, 0,
-  "This is an obsolete primitive.\n\
-Read a character from the console, without input editing.\n\
-First, any pending input is discarded,\n\
- then the next character typed is returned immediately.")
-{
-  PRIMITIVE_HEADER (0);
-  {
-    char c = (OS_tty_read_char_immediate ());
-    if (transcript_file_open)
-      {
-       if ((OS_channel_write (transcript_channel, (&c), 1)) != 1)
-         error_external_return ();
-      }
-    PRIMITIVE_RETURN (ASCII_TO_CHAR (c));
-  }
-}
-\f
-DEFINE_PRIMITIVE ("TTY-WRITE-CHAR", Prim_tty_write_char, 1, 1,
-  "This is an obsolete primitive.\n\
-Write a character to the console.")
-{
-  PRIMITIVE_HEADER (1);
-  {
-    char c = (arg_ascii_char (1));
-    OS_tty_write_char (c);
-    if (transcript_file_open)
-      {
-       if ((OS_channel_write (transcript_channel, (&c), 1)) != 1)
-         error_external_return ();
-      }
-  }
-  PRIMITIVE_RETURN (UNSPECIFIC);
-}
-
-DEFINE_PRIMITIVE ("TTY-WRITE-STRING", Prim_tty_write_string, 1, 1,
-  "This is an obsolete primitive.\n\
-Write a string to the console.")
-{
-  PRIMITIVE_HEADER (1);
-  CHECK_ARG (1, STRING_P);
-  {
-    fast SCHEME_OBJECT argument = (ARG_REF (1));
-    fast CONST PTR string = (STRING_LOC (argument, 0));
-    OS_tty_write_string (string);
-    if (transcript_file_open)
-      {
-       long length = (STRING_LENGTH (argument));
-       if ((OS_channel_write (transcript_channel, string, length)) != length)
-         error_external_return ();
-      }
-  }
-  PRIMITIVE_RETURN (UNSPECIFIC);
-}
-
-DEFINE_PRIMITIVE ("TTY-FLUSH-OUTPUT", Prim_tty_flush_output, 0, 0,
-  "This is an obsolete primitive.\n\
-Write the contents of the console output buffer to the console.\n\
-Return after all of the contents has been written.")
-{
-  PRIMITIVE_HEADER (0);
-  PRIMITIVE_RETURN (UNSPECIFIC);
-}
-
-DEFINE_PRIMITIVE ("TTY-BEEP", Prim_tty_beep, 0, 0,
-  "This is an obsolete primitive.\n\
-Ring the console bell.")
-{
-  PRIMITIVE_HEADER (0);
-  OS_tty_beep ();
-  PRIMITIVE_RETURN (UNSPECIFIC);
-}
-
-DEFINE_PRIMITIVE ("TTY-CLEAR", Prim_tty_clear, 0, 0,
-  "This is an obsolete primitive.\n\
-Clear the console screen.")
-{
-  PRIMITIVE_HEADER (0);
-  OS_tty_write_string (OS_tty_command_clear ());
-  PRIMITIVE_RETURN (UNSPECIFIC);
-}
-\f
 DEFINE_PRIMITIVE ("TTY-NEXT-INTERRUPT-CHAR", Prim_tty_next_interrupt_char, 0, 0,
   "Return the next interrupt character in the console input buffer.\n\
 The character is returned as an unsigned integer.")
@@ -233,20 +91,6 @@ The character is returned as an unsigned integer.")
   PRIMITIVE_HEADER (0);
   PRIMITIVE_RETURN (long_to_integer (OS_tty_next_interrupt_char ()));
 }
-
-DEFINE_PRIMITIVE ("TTY-CLEAN-INTERRUPTS", Prim_tty_clean_interrupts, 2, 2,
-  "Clear the input buffer for a character interrupt.\n\
-First arg MODE says how:\n\
- 0 ==> discard input up to the most recent interrupt marker\n\
-       that matches second arg CHAR.\n\
- 1 ==> remove all interrupt markers that match second arg CHAR.\n\
-CHAR should be the result of a call to `tty-next-interrupt-char'.")
-{
-  PRIMITIVE_HEADER (2);
-  OS_tty_clean_interrupts ((arg_index_integer (1, 2)),
-                          ((enum tty_clean_mode) (arg_ascii_integer (2))));
-  PRIMITIVE_RETURN (UNSPECIFIC);
-}
 \f
 DEFINE_PRIMITIVE ("TTY-GET-INTERRUPT-ENABLES", Prim_tty_get_interrupt_enables, 0, 0,
   "Return the current keyboard interrupt enables.")
@@ -307,16 +151,3 @@ STRING must be in the correct form for this operating system.")
   }
   PRIMITIVE_RETURN (UNSPECIFIC);
 }
-
-DEFINE_PRIMITIVE ("SET-TTY-INTERRUPT-ENABLES!", Prim_set_tty_interrupt_enables, 1, 1,
-  "This primitive is obsolete.")
-{
-  PRIMITIVE_HEADER (1);
-  {
-    Tinterrupt_enables old;
-    Tinterrupt_enables new = (arg_integer (1));
-    OS_ctty_get_interrupt_enables (&old);
-    OS_ctty_set_interrupt_enables (&new);
-    PRIMITIVE_RETURN (long_to_integer (old));
-  }
-}
index 8039324f680bfbceeb559b2e17a37536c52a353a..ed52919af812d8dfd19f4f4627ac05f261861217 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/sysprim.c,v 9.34 1990/06/20 17:42:19 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/sysprim.c,v 9.35 1990/11/05 11:55:19 cph Rel $
 
 Copyright (c) 1987, 1988, 1989, 1990 Massachusetts Institute of Technology
 
@@ -72,7 +72,8 @@ DEFINE_PRIMITIVE ("SET-RUN-LIGHT!", Prim_set_run_light, 1, 1, 0)
 {
   PRIMITIVE_HEADER (1);
 #ifdef RUN_LIGHT_IS_BEEP
-  OS_tty_beep ();
+  fputs ((OS_tty_command_beep ()), stdout);
+  fflush (stdout);
   PRIMITIVE_RETURN (SHARP_T);
 #else
   PRIMITIVE_RETURN (SHARP_F);
index eba651beadb5d8cccd8bcefe4334ea2a3de54e44..2b37f82c601f557ae0b2de6b8ebb89d09a02ba6f 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxctty.c,v 1.2 1990/11/01 04:33:33 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxctty.c,v 1.3 1990/11/05 11:55:24 cph Exp $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -42,87 +42,160 @@ MIT in each case. */
    terminal's settings. */
 static int ctty_fildes;
 
-/* If `ctty_fildes' is nonnegative, this flag says whether Scheme was
-   in the foreground when it was last entered.  Provided that no other
-   process forces Scheme out of the foreground, it will remain in the
-   foreground until it exits or is stopped.
+/* This flag says whether Scheme was in the foreground when it was
+   last entered.  Provided that no other process forces Scheme out of
+   the foreground, it will remain in the foreground until it exits or
+   is stopped.
 
-   If `ctty_foreground' is zero, Scheme should not alter the control
-   terminal's settings. */
-static int ctty_foreground;
+   If `scheme_in_foreground' is zero, Scheme should not alter the
+   control terminal's settings, nor should it alter the settings of
+   stdin, stdout, or stderr if they are terminals. */
+int scheme_in_foreground;
 
 /* This flag, set during initialization, says whether we are
    permitted to change the settings of the control terminal. */
 static int permit_ctty_control;
 
-/* Original states of the control terminal when Scheme was last
-   continued or stopped, respectively.  If the corresponding
-   `_recorded' flag is zero, then no information is saved. */
-static int outside_ctty_state_recorded;
-static Ttty_state outside_ctty_state;
-static int inside_ctty_state_recorded;
-static Ttty_state inside_ctty_state;
+/* Original states of the control terminal, stdin, and stdout when
+   Scheme was last continued or stopped, respectively.  If the
+   corresponding `_recorded' flag is zero, then no information is
+   saved. */
+
+struct terminal_state_recording
+{
+  int fd;
+  int recorded_p;
+  Ttty_state state;
+};
+
+static struct terminal_state_recording outside_ctty_state;
+static struct terminal_state_recording outside_stdin_state;
+static struct terminal_state_recording outside_stdout_state;
+static struct terminal_state_recording inside_ctty_state;
+static struct terminal_state_recording inside_stdin_state;
+static struct terminal_state_recording inside_stdout_state;
 
 static void EXFUN (ctty_update_interrupt_chars, (void));
 \f
+static void
+DEFUN (save_external_state, (s), struct terminal_state_recording * s)
+{
+  (s -> recorded_p) =
+    (scheme_in_foreground
+     && (isatty (s -> fd))
+     && ((UX_terminal_get_state ((s -> fd), (& (s -> state)))) >= 0));
+}
+
+static void
+DEFUN (restore_external_state, (s), struct terminal_state_recording * s)
+{
+  if (s -> recorded_p)
+    {
+      UX_terminal_set_state ((s -> fd), (& (s -> state)));
+      (s -> recorded_p) = 0;
+    }
+}
+
+void
+DEFUN (save_internal_state, (s, es),
+       struct terminal_state_recording * s AND
+       struct terminal_state_recording * es)
+{
+  /* Don't do anything unless we have a recording of the external
+     state.  Otherwise, we should preserve the previous recording of
+     the internal state, if any. */
+  if (es -> recorded_p)
+    (s -> recorded_p) =
+      ((UX_terminal_get_state ((s -> fd), (& (s -> state)))) >= 0);
+}
+
+static void
+DEFUN (restore_internal_state, (s, es),
+       struct terminal_state_recording * s AND
+       struct terminal_state_recording * es)
+{
+  /* When we recorded the internal state, we had a recording of the
+     external state.  But since we've stopped Scheme and restarted it,
+     we may no longer have a current recording of the external state.
+     If we don't, then we can't restore the internal state.
+
+     The usual reason that we don't have a recording is that Scheme is
+     in the background.  In that case it would be nice to preserve the
+     previous internal state until we go back to the foreground.  But
+     doing that transparently would also require tracking all
+     attempted state changes in the recording, which is a pain.  So if
+     we can't restore the internal state, we just thrown it away. */
+  if (s -> recorded_p)
+    {
+      if (es -> recorded_p)
+       UX_terminal_set_state ((s -> fd), (& (s -> state)));
+      (s -> recorded_p) = 0;
+    }
+}
+\f
 void
 DEFUN_VOID (UX_ctty_save_external_state)
 {
   if (permit_ctty_control && (ctty_fildes >= 0))
     {
       pid_t pgrp_id = (UX_tcgetpgrp (ctty_fildes));
-      ctty_foreground =
+      scheme_in_foreground =
        ((pgrp_id < 0)
         /* If no job control, assume we're in foreground. */
         ? (errno == ENOSYS)
         : ((UX_getpgrp ()) == pgrp_id));
     }
   else
-    ctty_foreground = 0;
-  outside_ctty_state_recorded =
-    (ctty_foreground &&
-     ((UX_terminal_get_state (ctty_fildes, (&outside_ctty_state))) >= 0));
+    scheme_in_foreground = 0;
+  save_external_state (&outside_ctty_state);
+  save_external_state (&outside_stdin_state);
+  save_external_state (&outside_stdout_state);
 }
 
 void
 DEFUN_VOID (UX_ctty_restore_internal_state)
 {
-  if (inside_ctty_state_recorded)
-    {
-      if (outside_ctty_state_recorded)
-       {
-         UX_terminal_set_state (ctty_fildes, (&inside_ctty_state));
-         ctty_update_interrupt_chars ();
-       }
-      inside_ctty_state_recorded = 0;
-    }
+  save_internal_state ((&inside_ctty_state), (&outside_ctty_state));
+  save_internal_state ((&inside_stdin_state), (&outside_stdin_state));
+  save_internal_state ((&inside_stdout_state), (&outside_stdout_state));
 }
 
 void
 DEFUN_VOID (UX_ctty_save_internal_state)
 {
-  inside_ctty_state_recorded =
-    (outside_ctty_state_recorded
-     ? ((UX_terminal_get_state (ctty_fildes, (&inside_ctty_state))) >= 0)
-     /* If outside state not recorded, we haven't changed anything, so
-       there's no need to save the inside state. */
-     : 0);
+  int do_update =
+    ((inside_ctty_state . recorded_p)
+     && (outside_ctty_state . recorded_p));
+  restore_internal_state ((&inside_ctty_state), (&outside_ctty_state));
+  restore_internal_state ((&inside_stdin_state), (&outside_stdin_state));
+  restore_internal_state ((&inside_stdout_state), (&outside_stdout_state));
+  if (do_update)
+    ctty_update_interrupt_chars ();
 }
 
 void
 DEFUN_VOID (UX_ctty_restore_external_state)
 {
-  if (outside_ctty_state_recorded)
-    {
-      UX_terminal_set_state (ctty_fildes, (&outside_ctty_state));
-      outside_ctty_state_recorded = 0;
-    }
+  restore_external_state (&outside_ctty_state);
+  restore_external_state (&outside_stdin_state);
+  restore_external_state (&outside_stdout_state);
 }
 
 int
 DEFUN_VOID (OS_ctty_interrupt_control)
 {
-  return (outside_ctty_state_recorded);
+  return (outside_ctty_state . recorded_p);
+}
+
+int
+DEFUN (UX_terminal_control_ok, (fd), int fd)
+{
+  return
+    ((fd == STDIN_FILENO)
+     ? (outside_stdin_state . recorded_p)
+     : (fd == STDOUT_FILENO)
+     ? (outside_stdout_state . recorded_p)
+     : 1);
 }
 \f
 /* Keyboard Interrupt Characters */
@@ -241,28 +314,21 @@ DEFUN (ctty_set_interrupt_chars, (ic), Tinterrupt_chars * ic)
       ((s . tio . c_cc) [VQUIT]) = (ic -> quit);
       ((s . tio . c_cc) [VINTR]) = (ic -> intrpt);
       ((s . tio . c_cc) [VSUSP]) = (ic -> tstp);
-#ifdef HAVE_BSD_JOB_CONTROL
-      (s . ltc . t_dsuspc) = (ic -> dtstp);
-#endif
 #else /* not HAVE_TERMIOS */
 #ifdef HAVE_TERMIO
       ((s . tio . c_cc) [VQUIT]) = (ic -> quit);
       ((s . tio . c_cc) [VINTR]) = (ic -> intrpt);
-#ifdef HAVE_BSD_JOB_CONTROL
-      (s . ltc . t_suspc) = (ic -> tstp);
-      (s . ltc . t_dsuspc) = (ic -> dtstp);
-#endif
 #else /* not HAVE_TERMIO */
 #ifdef HAVE_BSD_TTY_DRIVER
       (s . tc . t_quitc) = (ic -> quit);
       (s . tc . t_intrc) = (ic -> intrpt);
+#endif /* HAVE_BSD_TTY_DRIVER */
+#endif /* HAVE_TERMIO */
+#endif /* HAVE_TERMIOS */
 #ifdef HAVE_BSD_JOB_CONTROL
       (s . ltc . t_suspc) = (ic -> tstp);
       (s . ltc . t_dsuspc) = (ic -> dtstp);
 #endif
-#endif /* HAVE_BSD_TTY_DRIVER */
-#endif /* HAVE_TERMIO */
-#endif /* HAVE_TERMIOS */
       UX_terminal_set_state (ctty_fildes, (&s));
     }
 }
@@ -270,7 +336,7 @@ DEFUN (ctty_set_interrupt_chars, (ic), Tinterrupt_chars * ic)
 static void
 DEFUN_VOID (ctty_update_interrupt_chars)
 {
-  if (outside_ctty_state_recorded)
+  if (outside_ctty_state . recorded_p)
     {
       cc_t disabled_char = (UX_PC_VDISABLE (ctty_fildes));
       /* Must split declaration and assignment because some compilers
@@ -325,11 +391,14 @@ DEFUN (UX_initialize_ctty, (interactive), int interactive)
   }
   permit_ctty_control = interactive;
   UX_ctty_save_external_state ();
+  (inside_ctty_state . recorded_p) = 0;
+  (inside_stdin_state . recorded_p) = 0;
+  (inside_stdout_state . recorded_p) = 0;
   (current_interrupt_chars . quit) = DEFAULT_SIGQUIT_CHAR;
   (current_interrupt_chars . intrpt) = DEFAULT_SIGINT_CHAR;
   (current_interrupt_chars . tstp) = DEFAULT_SIGTSTP_CHAR;
   (current_interrupt_chars . dtstp) = (UX_PC_VDISABLE (ctty_fildes));
   current_interrupt_enables = KEYBOARD_ALL_INTERRUPTS;
-  if (outside_ctty_state_recorded)
+  if (outside_ctty_state . recorded_p)
     ctty_set_interrupt_chars (&current_interrupt_chars);
 }
index 04d9eaa6cf80a6ba893c265c3daacc22d4732182..6462dc8c0e1c932b6166ee71e18044a3ed0ecd74 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.c,v 1.5 1990/11/01 04:33:40 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.c,v 1.6 1990/11/05 11:55:29 cph Exp $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -101,22 +101,22 @@ DEFUN (terminal_open, (channel), Tchannel channel)
   get_terminal_state (channel, (& (TERMINAL_ORIGINAL_STATE (channel))));
 }
 
-int
-DEFUN (OS_terminal_read_char, (channel), Tchannel channel)
+void
+DEFUN (get_terminal_state, (channel, s), Tchannel channel AND Ttty_state * s)
 {
-  {
-    int c = (TERMINAL_BUFFER (channel));
-    if (c >= 0)
-      {
-       (TERMINAL_BUFFER (channel)) = (-1);
-       return (c);
-      }
-  }
-  {
-    unsigned char c;
-    long nread = (OS_channel_read (channel, (&c), 1));
-    return ((nread == 1) ? c : (-1));
-  }
+  STD_VOID_SYSTEM_CALL
+    ("terminal_get_state",
+     (UX_terminal_get_state ((CHANNEL_DESCRIPTOR (channel)), s)));
+}
+
+void
+DEFUN (set_terminal_state, (channel, s), Tchannel channel AND Ttty_state * s)
+{
+  extern int EXFUN (UX_terminal_control_ok, (int fd));
+  if (UX_terminal_control_ok (CHANNEL_DESCRIPTOR (channel)))
+    STD_VOID_SYSTEM_CALL
+      ("terminal_set_state",
+       (UX_terminal_set_state ((CHANNEL_DESCRIPTOR (channel)), s)));
 }
 \f
 unsigned int
@@ -269,115 +269,6 @@ DEFUN (terminal_state_buffered, (s, channel),
 #endif /* HAVE_TERMIOS or HAVE_TERMIO */
 }
 \f
-void
-DEFUN (get_terminal_state, (channel, s), Tchannel channel AND Ttty_state * s)
-{
-  STD_VOID_SYSTEM_CALL
-    ("tty_get_state",
-     (UX_terminal_get_state ((CHANNEL_DESCRIPTOR (channel)), s)));
-}
-
-void
-DEFUN (set_terminal_state, (channel, s), Tchannel channel AND Ttty_state * s)
-{
-  STD_VOID_SYSTEM_CALL
-    ("tty_set_state",
-     (UX_terminal_set_state ((CHANNEL_DESCRIPTOR (channel)), s)));
-}
-
-struct terminal_state_record
-{
-  Tchannel channel;
-  Ttty_state state;
-};
-
-static void
-DEFUN (restore_terminal_state, (ap), PTR ap)
-{
-  set_terminal_state ((((struct terminal_state_record *) ap) -> channel),
-                     (& (((struct terminal_state_record *) ap) -> state)));
-}
-
-Ttty_state *
-DEFUN (preserve_terminal_state, (channel), Tchannel channel)
-{
-  struct terminal_state_record * record =
-    (dstack_alloc (sizeof (struct terminal_state_record)));
-  (record -> channel) = channel;
-  get_terminal_state (channel, (& (record -> state)));
-  transaction_record_action (tat_always, restore_terminal_state, record);
-  return (& (record -> state));
-}
-\f
-#ifdef HAVE_FIONREAD
-/* This covers HAVE_BSD_TTY_DRIVER and some others. */
-
-int
-DEFUN (OS_terminal_char_ready_p, (channel, delay),
-       Tchannel channel AND clock_t delay)
-{
-  clock_t limit;
-  if (delay > 0)
-    limit = ((OS_real_time_clock ()) + delay);
-  while (1)
-    {
-      long n;
-      int scr;
-      INTERRUPTABLE_EXTENT
-       (scr, (UX_ioctl ((CHANNEL_DESCRIPTOR (channel)), FIONREAD, (&n))));
-      if (scr < 0)
-       UX_prim_check_errno ("ioctl_FIONREAD");
-      else if (n > 0)
-       return (1);
-      else if ((delay <= 0) || ((OS_real_time_clock ()) >= limit))
-       return (0);
-    }
-}
-
-#else /* not HAVE_FIONREAD */
-#if defined(HAVE_TERMIO) || defined(HAVE_TERMIOS)
-
-int
-DEFUN (OS_terminal_char_ready_p, (channel, delay),
-       Tchannel channel AND clock_t delay)
-{
-  clock_t limit;
-  if (delay > 0)
-    limit = ((OS_real_time_clock ()) + delay);
-  transaction_begin ();
-  {
-    /* Must split declaration and assignment because some compilers
-       do not permit aggregate initializers. */
-    Ttty_state s;
-    s = (* (preserve_terminal_state (channel)));
-    terminal_state_nonbuffered ((&s), 1);
-    set_terminal_state (channel, (&s));
-  }
-  while (1)
-    {
-      unsigned char c;
-      int nread;
-      INTERRUPTABLE_EXTENT
-       (nread, (UX_read ((CHANNEL_DESCRIPTOR (channel)), (&c), 1)));
-      if (nread < 0)
-       UX_prim_check_errno ("read");
-      else if (nread == 1)
-       {
-         (TERMINAL_BUFFER (channel)) = c;
-         transaction_commit ();
-         return (1);
-       }
-      if ((delay <= 0) || ((OS_real_time_clock ()) >= limit))
-       {
-         transaction_commit ();
-         return (0);
-       }
-    }
-}
-
-#endif /* HAVE_TERMIO or HAVE_TERMIOS */
-#endif /* HAVE_FIONREAD */
-\f
 unsigned int
 DEFUN (OS_terminal_get_ispeed, (channel), Tchannel channel)
 {
index fa8783e4b5c75327a387f0cc944c156ee4b1049f..fea0d8ca06b0c99eebe2ba788e1c195cdd26101e 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.h,v 1.1 1990/06/20 19:37:42 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.h,v 1.2 1990/11/05 11:55:34 cph Exp $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -44,6 +44,5 @@ extern void EXFUN (terminal_state_nonbuffered, (Ttty_state * s, int polling));
 extern void EXFUN (terminal_state_raw, (Ttty_state * s));
 extern void EXFUN (get_terminal_state, (Tchannel channel, Ttty_state * s));
 extern void EXFUN (set_terminal_state, (Tchannel channel, Ttty_state * s));
-extern Ttty_state * EXFUN (preserve_terminal_state, (Tchannel channel));
 
 #endif /* SCM_UXTERM_H */
index 22bb3cf482ad37b79eab4ef2e9e946987f117dc4..f2a2d7c0d66b6bf1cf15f38fd02f599dfcde9129 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxtop.c,v 1.4 1990/08/16 23:36:36 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxtop.c,v 1.5 1990/11/05 11:55:38 cph Exp $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -54,8 +54,6 @@ extern void EXFUN (UX_reset_processes, (void));
 extern void EXFUN (UX_reset_terminals, (void));
 extern void EXFUN (execute_reload_cleanups, (void));
 
-extern void EXFUN (OS_initialize_transcript_file, (void));
-
 extern void EXFUN (UX_ctty_save_external_state, (void));
 extern void EXFUN (UX_ctty_save_internal_state, (void));
 extern void EXFUN (UX_ctty_restore_internal_state, (void));
@@ -109,7 +107,6 @@ DEFUN_VOID (OS_initialize)
   UX_initialize_signals ();
   UX_initialize_trap_recovery ();
   UX_initialize_directory_reader ();
-  OS_initialize_transcript_file ();
   OS_Name = SYSTEM_NAME;
   OS_Variant = SYSTEM_VARIANT;
   fprintf (stdout, "MIT Scheme running under %s\n", OS_Variant);
index 8e763507aee5cdc07e722dc2082fc96ef0d75441..81e640e55fcce50ab645cba95b88e8d3aeb6b1ac 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxtty.c,v 1.2 1990/06/21 20:01:58 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxtty.c,v 1.3 1990/11/05 11:55:43 cph Exp $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -38,9 +38,14 @@ MIT in each case. */
 #include "uxio.h"
 #include "uxterm.h"
 \f
-/* Standard Input */
+/* Standard Input and Output */
 
 static Tchannel input_channel;
+static Tchannel output_channel;
+static int tty_x_size;
+static int tty_y_size;
+static CONST char * tty_command_beep;
+static CONST char * tty_command_clear;
 
 Tchannel
 DEFUN_VOID (OS_tty_input_channel)
@@ -48,84 +53,6 @@ DEFUN_VOID (OS_tty_input_channel)
   return (input_channel);
 }
 
-/* New input interface doesn't require the following, because they
-   can be provided by standard terminal and channel operations. */
-
-static unsigned char
-DEFUN (tty_read_char, (immediate), int immediate)
-{
-  if ((OS_channel_type (input_channel)) == channel_type_terminal)
-    {
-      transaction_begin ();
-      preserve_terminal_state (input_channel);
-      if (immediate)
-       OS_terminal_nonbuffered (input_channel);
-      else
-       OS_terminal_buffered (input_channel);
-      {
-       int c = (OS_terminal_read_char (input_channel));
-       if (c == (-1))
-         termination_eof ();
-       transaction_commit ();
-       return ((unsigned char) c);
-      }
-    }
-  else
-    {
-      unsigned char c;
-      if ((OS_channel_read (input_channel, (&c), 1)) != 1)
-       termination_eof ();
-      if ((OS_channel_type (input_channel)) == channel_type_file)
-       OS_tty_write_char (c);
-      return (c);
-    }
-}
-
-unsigned char
-DEFUN_VOID (OS_tty_read_char)
-{
-  return (tty_read_char (0));
-}
-
-unsigned char
-DEFUN_VOID (OS_tty_read_char_immediate)
-{
-  return (tty_read_char (1));
-}
-
-int
-DEFUN (OS_tty_char_ready_p, (delay), clock_t delay)
-{
-  if ((OS_channel_type (input_channel)) == channel_type_terminal)
-    return (OS_terminal_char_ready_p (input_channel, delay));
-  if (delay > 0)
-    {
-      clock_t limit = ((OS_real_time_clock ()) + delay);
-      while ((OS_real_time_clock ()) < limit)
-       ;
-    }
-  return (0);
-}
-
-int
-DEFUN (OS_tty_clean_interrupts, (mode, interrupt_char),
-       enum tty_clean_mode mode AND
-       cc_t interrupt_char)
-{
-  if (parent_process_is_emacs && (mode == tty_clean_most_recent))
-    while ((OS_tty_read_char_immediate ()) != '\0')
-      ;
-  return (1);
-}
-\f
-/* Standard Output */
-
-static Tchannel output_channel;
-static int tty_x_size;
-static int tty_y_size;
-static CONST char * tty_command_beep;
-static CONST char * tty_command_clear;
-
 Tchannel
 DEFUN_VOID (OS_tty_output_channel)
 {
@@ -169,29 +96,6 @@ DEFUN_VOID (OS_tty_command_clear)
 {
   return (tty_command_clear);
 }
-
-/* Old output interface requires output buffering at the microcode
-   level.  The new runtime system will provide the buffering so that
-   the microcode doesn't have to. */
-
-void
-DEFUN (OS_tty_write_char, (c), unsigned char c)
-{
-  if ((OS_channel_write (output_channel, (&c), 1)) != 1)
-    error_external_return ();
-}
-
-void
-DEFUN (OS_tty_write_string, (s), CONST char * s)
-{
-  OS_channel_write_string (output_channel, s);
-}
-
-void
-DEFUN_VOID (OS_tty_beep)
-{
-  OS_channel_write_string (output_channel, tty_command_beep);
-}
 \f
 #ifndef TERMCAP_BUFFER_SIZE
 #define TERMCAP_BUFFER_SIZE 2048
index be72ca2398500064123a3b174186dbccc940e7bb..442a7b93ffe2cd67d00c5d33542a222877aa11dd 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.50 1990/11/01 04:33:46 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.51 1990/11/05 11:55:48 cph Exp $
 
 Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology
 
@@ -46,7 +46,7 @@ MIT in each case. */
 #define VERSION                11
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     50
+#define SUBVERSION     51
 #endif
 
 #ifndef UCODE_TABLES_FILENAME
index c6bc474eb02474d9d6f79631c3ce31f389a44161..de15b347837664b5ea9079d23206558cf6af8ca1 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.50 1990/11/01 04:33:46 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.51 1990/11/05 11:55:48 cph Exp $
 
 Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology
 
@@ -46,7 +46,7 @@ MIT in each case. */
 #define VERSION                11
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     50
+#define SUBVERSION     51
 #endif
 
 #ifndef UCODE_TABLES_FILENAME