--- gforth/engine/io.c 2006/04/14 12:18:50 1.24 +++ gforth/engine/io.c 2007/07/14 19:57:16 1.30 @@ -1,6 +1,6 @@ /* direct key io driver - Copyright (C) 1995,1996,1997,1998,1999,2002,2003 Free Software Foundation, Inc. + Copyright (C) 1995,1996,1997,1998,1999,2002,2003,2006 Free Software Foundation, Inc. This file is part of Gforth. @@ -622,7 +622,7 @@ long key_avail (FILE * stream) { int tty = fileno (stream); fd_set selin; - static int now[2] = { 0 , 0 }; + static struct timespec now = { 0 , 0 }; int res; setvbuf(stream, NULL, _IONBF, 0); @@ -631,7 +631,7 @@ long key_avail (FILE * stream) FD_ZERO(&selin); FD_SET(tty, &selin); - return select(1, &selin, NULL, NULL, now); + return select(1, &selin, NULL, NULL, &now); } /* Get a key from the buffer of characters to be read. @@ -651,9 +651,21 @@ Cell getkey(FILE * stream) prep_terminal(); result = fread(&c, sizeof(c), 1, stream); - return result==0 ? EOF : c; + return result==0 ? (errno == EINTR ? 12 : 4) : c; } +#ifdef STANDALONE +void emit_char(char x) +{ + putc(x, stdout); +} + +void type_chars(char *addr, unsigned int l) +{ + fwrite(addr, l, 1, stdout); +} +#endif + #ifdef TEST #include