Diff for /gforth/Attic/io.c between versions 1.4 and 1.9

version 1.4, 1994/07/08 15:00:45 version 1.9, 1995/09/06 21:00:19
Line 3 Line 3
         The following is stolen from the readline library for bash          The following is stolen from the readline library for bash
 */  */
   
 /* Use -DDOMAINOS for Apollo Domain-OS.  /*
    Use -D_POSIX_VERSION for POSIX systems.     Use -D_POSIX_VERSION for POSIX systems.
 */  */
   
 #ifdef DOMAINOS  #include <unistd.h>
   
   #ifdef apollo
 #define _POSIX_VERSION  #define _POSIX_VERSION
 #endif  #endif
   
 #include <stdio.h>  #include <stdio.h>
 #include <signal.h>  #include <signal.h>
 #include <sys/types.h>  #include <sys/types.h>
 #ifndef DOMAINOS  #ifndef apollo
 #include <sys/ioctl.h>  #include <sys/ioctl.h>
 #endif  #endif
 #include <fcntl.h>  #include <fcntl.h>
Line 31 Line 33
 #  endif  #  endif
 #endif  #endif
   
 #if defined (HAVE_UNISTD_H)  
 #  include <unistd.h>  
 #endif  
   
 #define NEW_TTY_DRIVER  #define NEW_TTY_DRIVER
 #define HAVE_BSD_SIGNALS  #define HAVE_BSD_SIGNALS
 #ifndef DOMAINOS  /*
   #ifndef apollo
 #define USE_XON_XOFF  #define USE_XON_XOFF
 #endif  #endif
   */
   
   #define HANDLE_SIGNALS
   
 /* Some USG machines have BSD signal handling (sigblock, sigsetmask, etc.) */  /* Some USG machines have BSD signal handling (sigblock, sigsetmask, etc.) */
 #if defined (USG) && !defined (hpux)  #if defined (USG) && !defined (hpux)
Line 48 Line 50
   
 /* System V machines use termio. */  /* System V machines use termio. */
 #if !defined (_POSIX_VERSION)  #if !defined (_POSIX_VERSION)
 #  if defined (USG) || defined (hpux) || defined (Xenix) || defined (sgi) || defined (DGUX) || defined (ultrix)  #  if defined (USG) || defined (hpux) || defined (Xenix) || defined (sgi) || defined (DGUX) || defined (ultrix) || defined (Solaris)
 #    undef NEW_TTY_DRIVER  #    undef NEW_TTY_DRIVER
 #    define TERMIO_TTY_DRIVER  #    define TERMIO_TTY_DRIVER
 #    include <termio.h>  #    include <termio.h>
Line 104  extern int errno; Line 106  extern int errno;
 #  endif /* USGr3 */  #  endif /* USGr3 */
 #endif /* USG && hpux */  #endif /* USG && hpux */
   
 #if (defined (_POSIX_VERSION) || defined (USGr3)) && !defined(DOMAINOS)  #if (defined (_POSIX_VERSION) || defined (USGr3)) && !defined(apollo)
 #  include <dirent.h>  #  include <dirent.h>
 #  define direct dirent  #  define direct dirent
 #  if defined (_POSIX_VERSION)  #  if defined (_POSIX_VERSION)
Line 568  long key_avail (stream) Line 570  long key_avail (stream)
   long chars_avail = pending;    long chars_avail = pending;
   int result;    int result;
   
     if(!terminal_prepped)  prep_terminal();
   
 #if defined (FIONREAD)  #if defined (FIONREAD)
   result = ioctl (tty, FIONREAD, &chars_avail);    result = ioctl (tty, FIONREAD, &chars_avail);
 #endif  #endif
Line 603  unsigned char getkey(stream) Line 607  unsigned char getkey(stream)
   int result;    int result;
   unsigned char c;    unsigned char c;
   
     if(!terminal_prepped)  prep_terminal();
   
   while (pending < 0)    while (pending < 0)
     {      {
       result = read (fileno (stream), &c, sizeof (char));        result = read (fileno (stream), &c, sizeof (char));
Line 613  unsigned char getkey(stream) Line 619  unsigned char getkey(stream)
       /* If zero characters are returned, then the file that we are        /* If zero characters are returned, then the file that we are
          reading from is empty!  Return EOF in that case. */           reading from is empty!  Return EOF in that case. */
       if (result == 0)        if (result == 0)
         return (0);          return CTRL('D');
   
       /* If the error that we received was SIGINT, then try again,        /* If the error that we received was SIGINT, then try again,
          this is simply an interrupted system call to read ().           this is simply an interrupted system call to read ().
Line 740  signal_throw(int sig) Line 746  signal_throw(int sig)
   longjmp(throw_jmp_buf,throw_codes[sig-1]); /* or use siglongjmp ? */    longjmp(throw_jmp_buf,throw_codes[sig-1]); /* or use siglongjmp ? */
 }  }
   
   static void
   termprep (int sig)
   {
     terminal_prepped=0;
     signal(sig,termprep);
   }
   
 void  void
 install_signal_handlers (void)  install_signal_handlers (void)
 {  {
Line 751  install_signal_handlers (void) Line 764  install_signal_handlers (void)
                         SIGALRM,  SIGBUS                          SIGALRM,  SIGBUS
 #define SIGS_TO_QUIT    SIGHUP, SIGQUIT, SIGABRT, SIGPIPE, \  #define SIGS_TO_QUIT    SIGHUP, SIGQUIT, SIGABRT, SIGPIPE, \
                         SIGTERM                           SIGTERM 
   #define SIGS_TO_TERMPREP    SIGCONT
   
   static short sigs_to_ignore [] = { SIGS_TO_IGNORE };    static short sigs_to_ignore [] = { SIGS_TO_IGNORE };
   static short sigs_to_abort [] = { SIGS_TO_ABORT };    static short sigs_to_abort [] = { SIGS_TO_ABORT };
   static short sigs_to_quit [] = { SIGS_TO_QUIT };    static short sigs_to_quit [] = { SIGS_TO_QUIT };
     static short sigs_to_termprep [] = { SIGS_TO_TERMPREP };
   int i;    int i;
   
 #define DIM(X)          (sizeof (X) / sizeof *(X))  #define DIM(X)          (sizeof (X) / sizeof *(X))
Line 765  install_signal_handlers (void) Line 780  install_signal_handlers (void)
     signal (sigs_to_abort [i], signal_throw); /* !! change to throw */      signal (sigs_to_abort [i], signal_throw); /* !! change to throw */
   for (i = 0; i < DIM (sigs_to_quit); i++)    for (i = 0; i < DIM (sigs_to_quit); i++)
     signal (sigs_to_quit [i], graceful_exit);      signal (sigs_to_quit [i], graceful_exit);
     for (i = 0; i < DIM (sigs_to_termprep); i++)
       signal (sigs_to_termprep [i], termprep);
 }  }
 /* end signal handling */  /* end signal handling */

Removed from v.1.4  
changed lines
  Added in v.1.9


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>