version 1.21, 2006/04/09 07:44:13
|
version 1.23, 2006/04/09 08:24:47
|
Line 624 long key_avail (FILE * stream)
|
Line 624 long key_avail (FILE * stream)
|
static int now[2] = { 0 , 0 }; |
static int now[2] = { 0 , 0 }; |
int res; |
int res; |
|
|
|
setvbuf(stream, NULL, _IONBF, 0); |
if(!terminal_prepped && stream == stdin) |
if(!terminal_prepped && stream == stdin) |
prep_terminal(); |
prep_terminal(); |
|
|
Line 644 Cell getkey(FILE * stream)
|
Line 645 Cell getkey(FILE * stream)
|
Cell result; |
Cell result; |
unsigned char c; |
unsigned char c; |
|
|
if(!terminal_prepped) |
setvbuf(stream, NULL, _IONBF, 0); |
|
if(!terminal_prepped && stream == stdin) |
prep_terminal(); |
prep_terminal(); |
|
|
while (1) |
result = fread(&c, sizeof(c), 1, stream); |
{ |
return result==0 ? EOF : c; |
result = read (fileno (stream), &c, sizeof (char)); |
|
|
|
if (result == sizeof (char)) |
|
return /* (c == 0x7F ? 0x08 :*/ c /*)*/; |
|
|
|
/* If zero characters are returned, then the file that we are |
|
reading from is empty! Return EOF in that case. */ |
|
if (result == 0) |
|
return (EOF); |
|
|
|
/* If the error that we received was SIGINT, then try again, |
|
this is simply an interrupted system call to read (). |
|
Otherwise, some error ocurred, also signifying EOF. */ |
|
if (errno != EINTR) |
|
return (EOF); |
|
} |
|
} |
} |
|
|
#ifdef TEST |
#ifdef TEST |