Diff for /gforth/engine/io.c between versions 1.37 and 1.42

version 1.37, 2009/06/29 20:29:54 version 1.42, 2012/04/03 22:57:00
Line 1 Line 1
 /* direct key io driver  /* direct key io driver
   
   Copyright (C) 1995,1996,1997,1998,1999,2002,2003,2006,2007,2008 Free Software Foundation, Inc.    Copyright (C) 1995,1996,1997,1998,1999,2002,2003,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
   
   This file is part of Gforth.    This file is part of Gforth.
   
Line 447  void deprep_terminal () Line 447  void deprep_terminal ()
 #define VTIME VEOL  #define VTIME VEOL
 #endif  #endif
   
 #include <locale.h>  
   
 void prep_terminal ()  void prep_terminal ()
 {  {
   int tty = fileno (stdin);    int tty = fileno (stdin);
Line 474  void prep_terminal () Line 472  void prep_terminal ()
     return;      /* added by MdG */      return;      /* added by MdG */
   }      /* added by MdG */    }      /* added by MdG */
         
   setlocale(LC_ALL, "");  
   setlocale(LC_NUMERIC, "C");  
   
   /* 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 672  long key_avail (FILE *stream) Line 667  long key_avail (FILE *stream)
   static struct timeval now = { 0 , 0 };    static struct timeval now = { 0 , 0 };
   int chars_avail;    int chars_avail;
   
     if (gf_ungottenc(stream))
       return 1;
   setvbuf(stream, NULL, _IONBF, 0);    setvbuf(stream, NULL, _IONBF, 0);
   if(!terminal_prepped && stream == stdin)    if(!terminal_prepped && stream == stdin)
     prep_terminal();      prep_terminal();
   if (gf_ungottenc(stream))  
     return 1;  
   
   FD_ZERO(&selin);  #if defined(FIONREAD) && !defined(_WIN32)
   FD_SET(tty, &selin);    if(isatty (tty)) {
   chars_avail = select(1, &selin, NULL, NULL, &now);      int result = ioctl (tty, FIONREAD, &chars_avail);
     } else
   #endif
     {
       FD_ZERO(&selin);
       FD_SET(tty, &selin);
       chars_avail = select(1, &selin, NULL, NULL, &now);
     }
   if (chars_avail > 0) {    if (chars_avail > 0) {
     /* getc won't block */      /* getc won't block */
     int c = getc(stream);      int c = getc(stream);
Line 703  Cell getkey(FILE * stream) Line 705  Cell getkey(FILE * stream)
   Cell result;    Cell result;
   unsigned char c;    unsigned char c;
   
   setvbuf(stream, NULL, _IONBF, 0);    if (!gf_ungottenc(stream))
       setvbuf(stream, NULL, _IONBF, 0);
   if(!terminal_prepped && stream == stdin)    if(!terminal_prepped && stream == stdin)
     prep_terminal();      prep_terminal();
   

Removed from v.1.37  
changed lines
  Added in v.1.42


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