--- gforth/Attic/io.c 1995/01/18 18:41:38 1.7 +++ gforth/Attic/io.c 1995/09/06 21:00:19 1.9 @@ -3,20 +3,20 @@ The following is stolen from the readline library for bash */ -/* Use -DDOMAINOS for Apollo Domain-OS. +/* Use -D_POSIX_VERSION for POSIX systems. */ #include -#ifdef DOMAINOS +#ifdef apollo #define _POSIX_VERSION #endif #include #include #include -#ifndef DOMAINOS +#ifndef apollo #include #endif #include @@ -36,7 +36,7 @@ #define NEW_TTY_DRIVER #define HAVE_BSD_SIGNALS /* -#ifndef DOMAINOS +#ifndef apollo #define USE_XON_XOFF #endif */ @@ -106,7 +106,7 @@ extern int errno; # endif /* USGr3 */ #endif /* USG && hpux */ -#if (defined (_POSIX_VERSION) || defined (USGr3)) && !defined(DOMAINOS) +#if (defined (_POSIX_VERSION) || defined (USGr3)) && !defined(apollo) # include # define direct dirent # if defined (_POSIX_VERSION) @@ -570,6 +570,8 @@ long key_avail (stream) long chars_avail = pending; int result; + if(!terminal_prepped) prep_terminal(); + #if defined (FIONREAD) result = ioctl (tty, FIONREAD, &chars_avail); #endif @@ -605,6 +607,8 @@ unsigned char getkey(stream) int result; unsigned char c; + if(!terminal_prepped) prep_terminal(); + while (pending < 0) { result = read (fileno (stream), &c, sizeof (char)); @@ -615,7 +619,7 @@ unsigned char getkey(stream) /* If zero characters are returned, then the file that we are reading from is empty! Return EOF in that case. */ if (result == 0) - return (0); + return CTRL('D'); /* If the error that we received was SIGINT, then try again, this is simply an interrupted system call to read (). @@ -745,7 +749,7 @@ signal_throw(int sig) static void termprep (int sig) { - terminal_prepped=0; prep_terminal(); + terminal_prepped=0; signal(sig,termprep); }