Diff for /gforth/Attic/io.c between versions 1.10 and 1.14

version 1.10, 1995/10/16 18:33:10 version 1.14, 1996/01/25 16:45:52
Line 1 Line 1
 /*      direct key io driver  /* direct key io driver; signal handler
   
         The following is stolen from the readline library for bash    Copyright (C) 1995 Free Software Foundation, Inc.
   
     This file is part of Gforth.
   
     Gforth is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
     as published by the Free Software Foundation; either version 2
     of the License, or (at your option) any later version.
   
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
   
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   
     The following is stolen from the readline library for bash
 */  */
   
 /*  /*
    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 164  static int eof_char = CTRL ('D'); Line 183  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 710  signal_throw(int sig) Line 729  signal_throw(int sig)
   longjmp(throw_jmp_buf,code); /* or use siglongjmp ? */    longjmp(throw_jmp_buf,code); /* or use siglongjmp ? */
 }  }
   
 static void  static void termprep (int sig)
 termprep (int sig)  
 {  {
   terminal_prepped=0;  
   signal(sig,termprep);    signal(sig,termprep);
     terminal_prepped=0;
   }
   
   UCell rows=24;
   UCell cols=80;
   
   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
 }  }
   
 void  void install_signal_handlers (void)
 install_signal_handlers (void)  
 {  {
   
 #if 0  #if 0
Line 782  install_signal_handlers (void) Line 835  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 819  install_signal_handlers (void) Line 869  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 860  install_signal_handlers (void) Line 913  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 870  install_signal_handlers (void) Line 920  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 886  install_signal_handlers (void) Line 931  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.10  
changed lines
  Added in v.1.14


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