Diff for /gforth/Attic/io.c between versions 1.15 and 1.20

version 1.15, 1996/04/17 16:39:41 version 1.20, 1997/03/04 22:09:54
Line 28 Line 28
 #include "config.h"  #include "config.h"
 #include <unistd.h>  #include <unistd.h>
   
 #ifdef apollo  #if defined(apollo) || defined(_WIN32)
 #define _POSIX_VERSION  #define _POSIX_VERSION
 #endif  #endif
   
Line 36 Line 36
 #include <signal.h>  #include <signal.h>
 #include <string.h>  #include <string.h>
 #include <sys/types.h>  #include <sys/types.h>
 #ifndef apollo  #if !defined(apollo) && !defined(MSDOS)
 #include <sys/ioctl.h>  #include <sys/ioctl.h>
 #endif  #endif
 #include <fcntl.h>  #include <fcntl.h>
Line 45 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 70 Line 71
   
 /* 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) || defined (Solaris)  #  if defined (USG) || defined (hpux) || defined (Xenix) || defined (sgi) || defined (DGUX) || defined (ultrix) || defined (Solaris) || defined(_WIN32)
 #    undef NEW_TTY_DRIVER  #    undef NEW_TTY_DRIVER
 #    define TERMIO_TTY_DRIVER  #    define TERMIO_TTY_DRIVER
 #    include <termio.h>  #    include <termio.h>
Line 283  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 389  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 443  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 547  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 592  long key_avail (stream) Line 615  long key_avail (stream)
   
   if(!terminal_prepped)  prep_terminal();    if(!terminal_prepped)  prep_terminal();
   
 #if defined (FIONREAD)  #ifndef _WIN32
   result = ioctl (tty, FIONREAD, &chars_avail);    result = ioctl (tty, FIONREAD, &chars_avail);
   #else
     {
        fd_set selin;
        static int now[2] = { 0 , 0 };
        int res;
   
        FD_ZERO(&selin);
        FD_SET(tty, &selin);
        chars_avail=select(1, &selin, NULL, NULL, now);
     }
 #endif  #endif
   
   if(chars_avail == -1L)    if(chars_avail == -1L)
Line 693  int main() Line 726  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 717  signal_throw(int sig) Line 750  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 729  signal_throw(int sig) Line 764  signal_throw(int sig)
   longjmp(throw_jmp_buf,code); /* or use siglongjmp ? */    longjmp(throw_jmp_buf,code); /* or use siglongjmp ? */
 }  }
   
   UCell cols=80;
   #if defined(MSDOS) || defined (_WIN32)
   UCell rows=25;
   #else
   UCell rows=24;
   #endif
   
   #ifdef SIGCONT
 static void termprep (int sig)  static void termprep (int sig)
 {  {
   signal(sig,termprep);    signal(sig,termprep);
   terminal_prepped=0;    terminal_prepped=0;
 }  }
   #endif
   
 UCell rows=24;  #ifdef SIGWINCH
 UCell cols=80;  
   
 void get_winsize()  void get_winsize()
 {  {
 #ifdef TIOCGWINSZ  #ifdef TIOCGWINSZ
Line 770  static void change_winsize(int sig) Line 812  static void change_winsize(int sig)
   get_winsize();    get_winsize();
 #endif  #endif
 }  }
   #endif
   
 void install_signal_handlers (void)  void install_signal_handlers (void)
 {  {

Removed from v.1.15  
changed lines
  Added in v.1.20


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