Diff for /gforth/Attic/io.c between versions 1.11 and 1.16

version 1.11, 1995/11/07 18:06:46 version 1.16, 1996/09/19 22:17:32
Line 25 Line 25
    Use -D_POSIX_VERSION for POSIX systems.     Use -D_POSIX_VERSION for POSIX systems.
 */  */
   
   #include "config.h"
 #include <unistd.h>  #include <unistd.h>
   
 #ifdef apollo  #ifdef apollo
Line 44 Line 45
 #include "forth.h"  #include "forth.h"
 #include "io.h"  #include "io.h"
   
   #ifndef MSDOS
 #if defined (__GNUC__)  #if defined (__GNUC__)
 #  define alloca __builtin_alloca  #  define alloca __builtin_alloca
 #else  #else
Line 110 Line 112
 #endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */  #endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */
   
 #include <errno.h>  #include <errno.h>
 extern int errno;  /* extern int errno; */
   
 #if defined (SHELL)  #if defined (SHELL)
 #  include <posixstat.h>  #  include <posixstat.h>
Line 182  static int eof_char = CTRL ('D'); Line 184  static int eof_char = CTRL ('D');
 /* **************************************************************** */  /* **************************************************************** */
   
 /* Non-zero means that the terminal is in a prepped state. */  /* Non-zero means that the terminal is in a prepped state. */
 static int terminal_prepped = 0;  int terminal_prepped = 0;
   
 #if defined (NEW_TTY_DRIVER)  #if defined (NEW_TTY_DRIVER)
   
Line 282  void prep_terminal () Line 284  void prep_terminal ()
   if (terminal_prepped)    if (terminal_prepped)
     return;      return;
   
     if (!isatty(tty)) {      /* added by MdG */
       terminal_prepped = 1;      /* added by MdG */
       return;      /* added by MdG */
     }      /* added by MdG */
      
   oldmask = sigblock (sigmask (SIGINT));    oldmask = sigblock (sigmask (SIGINT));
   
   /* We always get the latest tty values.  Maybe stty changed them. */    /* We always get the latest tty values.  Maybe stty changed them. */
Line 388  void deprep_terminal () Line 395  void deprep_terminal ()
   if (!terminal_prepped)    if (!terminal_prepped)
     return;      return;
   
   /* Added by MdG */
     if (!isatty(tty)) {
       terminal_prepped = 0;
       return;
     }
      
   oldmask = sigblock (sigmask (SIGINT));    oldmask = sigblock (sigmask (SIGINT));
   
   the_ttybuff.sg_flags = original_tty_flags;    the_ttybuff.sg_flags = original_tty_flags;
Line 442  void prep_terminal () Line 455  void prep_terminal ()
   if (terminal_prepped)    if (terminal_prepped)
     return;      return;
   
     if (!isatty(tty))  {     /* added by MdG */
       terminal_prepped = 1;      /* added by MdG */
       return;      /* added by MdG */
     }      /* added by MdG */
      
   /* Try to keep this function from being INTerrupted.  We can do it    /* Try to keep this function from being INTerrupted.  We can do it
      on POSIX and systems with BSD-like signal handling. */       on POSIX and systems with BSD-like signal handling. */
 #if defined (HAVE_POSIX_SIGNALS)  #if defined (HAVE_POSIX_SIGNALS)
Line 546  void deprep_terminal () Line 564  void deprep_terminal ()
   if (!terminal_prepped)    if (!terminal_prepped)
     return;      return;
   
   /* Added by MdG */
     if (!isatty(tty)) {
       terminal_prepped = 0;
       return;
     }
   
 #if defined (HAVE_POSIX_SIGNALS)  #if defined (HAVE_POSIX_SIGNALS)
   sigemptyset (&set);    sigemptyset (&set);
   sigemptyset (&oset);    sigemptyset (&oset);
Line 692  int main() Line 716  int main()
         puts("");          puts("");
 }  }
 #endif  #endif
   #endif /* MSDOS */
   
 /* signal handling adapted from pfe by Dirk Zoller (Copylefted) - anton */  /* signal handling adapted from pfe by Dirk Zoller (Copylefted) - anton */
   
Line 716  signal_throw(int sig) Line 740  signal_throw(int sig)
   } *p, throwtable[] = {    } *p, throwtable[] = {
     { SIGINT, -28 },      { SIGINT, -28 },
     { SIGFPE, -55 },      { SIGFPE, -55 },
   #ifdef SIGBUS
     { SIGBUS, -23 },      { SIGBUS, -23 },
   #endif
     { SIGSEGV, -9 },      { SIGSEGV, -9 },
   };    };
   signal(sig,signal_throw);    signal(sig,signal_throw);
Line 728  signal_throw(int sig) Line 754  signal_throw(int sig)
   longjmp(throw_jmp_buf,code); /* or use siglongjmp ? */    longjmp(throw_jmp_buf,code); /* or use siglongjmp ? */
 }  }
   
 static void  UCell cols=80;
 termprep (int sig)  #ifdef MSDOS
   UCell rows=25;
   #else
   UCell rows=24;
   #endif
   
   #ifdef SIGCONT
   static void termprep (int sig)
 {  {
   terminal_prepped=0;  
   signal(sig,termprep);    signal(sig,termprep);
     terminal_prepped=0;
 }  }
   #endif
   
 void  #ifdef SIGWINCH
 install_signal_handlers (void)  void get_winsize()
   {
   #ifdef TIOCGWINSZ
     struct winsize size;
     
     if (ioctl (1, TIOCGWINSZ, (char *) &size) >= 0) {
       rows = size.ws_row;
       cols = size.ws_col;
     }
   #else
     char *s, *ends;
     unsigned long ul;
     if (s=getenv("LINES")) {
       rows=atoi(s);
       if (rows==0)
         rows=24;
     }
     if (s=getenv("COLUMNS")) {
       rows=atoi(s);
       if (rows==0)
         cols=80;
     }
   #endif
   }
   
   static void change_winsize(int sig)
   {
     signal(sig,change_winsize);
   #ifdef TIOCGWINSZ
     get_winsize();
   #endif
   }
   #endif
   
   void install_signal_handlers (void)
 {  {
   
 #if 0  #if 0
Line 800  install_signal_handlers (void) Line 868  install_signal_handlers (void)
 #ifdef SIGTTOU  #ifdef SIGTTOU
     SIGTTOU,      SIGTTOU,
 #endif  #endif
 #ifdef SIGWINCH  
     SIGWINCH,  
 #endif  
 #ifdef SIGSTKFLT  #ifdef SIGSTKFLT
     SIGSTKFLT,      SIGSTKFLT,
 #endif  #endif
Line 837  install_signal_handlers (void) Line 902  install_signal_handlers (void)
 #ifdef SIGALRM  #ifdef SIGALRM
     SIGALRM,      SIGALRM,
 #endif  #endif
   #ifdef SIGPIPE
       SIGPIPE,
   #endif
 #ifdef SIGPOLL  #ifdef SIGPOLL
     SIGPOLL,      SIGPOLL,
 #endif  #endif
Line 878  install_signal_handlers (void) Line 946  install_signal_handlers (void)
 #ifdef SIGABRT  #ifdef SIGABRT
     SIGABRT,      SIGABRT,
 #endif  #endif
 #ifdef SIGPIPE  
     SIGPIPE,  
 #endif  
 #ifdef SIGTERM  #ifdef SIGTERM
     SIGTERM,      SIGTERM,
 #endif  #endif
Line 888  install_signal_handlers (void) Line 953  install_signal_handlers (void)
     SIGXCPU,      SIGXCPU,
 #endif  #endif
   };    };
   static short sigs_to_termprep [] = {  
 #ifdef SIGCONT  
     SIGCONT,  
 #endif  
   };  
   int i;    int i;
   
 #define DIM(X)          (sizeof (X) / sizeof *(X))  #define DIM(X)          (sizeof (X) / sizeof *(X))
Line 904  install_signal_handlers (void) Line 964  install_signal_handlers (void)
     signal (sigs_to_throw [i], signal_throw);      signal (sigs_to_throw [i], signal_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++)  #ifdef SIGCONT
     signal (sigs_to_termprep [i], termprep);      signal (SIGCONT, termprep);
   #endif
   #ifdef SIGWINCH
       signal (SIGWINCH, change_winsize);
   #endif
 }  }
 /* end signal handling */  /* end signal handling */

Removed from v.1.11  
changed lines
  Added in v.1.16


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