mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 13:49:17 +02:00
sexp_stream_ready_p was forgetting to ungetc non-EOF pending characters
This commit is contained in:
parent
0d560bd3dc
commit
b08d5a53b9
1 changed files with 7 additions and 2 deletions
9
sexp.c
9
sexp.c
|
@ -1874,7 +1874,7 @@ void sexp_maybe_unblock_port (sexp ctx, sexp port) {
|
||||||
#if SEXP_USE_GREEN_THREADS
|
#if SEXP_USE_GREEN_THREADS
|
||||||
static int sexp_fileno_ready_p (int fd) {
|
static int sexp_fileno_ready_p (int fd) {
|
||||||
struct pollfd pfd;
|
struct pollfd pfd;
|
||||||
if (fd < 0) return -1;
|
if (fd < 0) return 0;
|
||||||
pfd.fd = fd;
|
pfd.fd = fd;
|
||||||
pfd.events = POLLIN;
|
pfd.events = POLLIN;
|
||||||
return poll(&pfd, 1, 0) == 1;
|
return poll(&pfd, 1, 0) == 1;
|
||||||
|
@ -1885,7 +1885,12 @@ static int sexp_stream_ready_p (FILE* in) {
|
||||||
if (! (flags & O_NONBLOCK)) fcntl(fileno(in), F_SETFL, flags & O_NONBLOCK);
|
if (! (flags & O_NONBLOCK)) fcntl(fileno(in), F_SETFL, flags & O_NONBLOCK);
|
||||||
res = getc(in);
|
res = getc(in);
|
||||||
if (! (flags & O_NONBLOCK)) fcntl(fileno(in), F_SETFL, flags);
|
if (! (flags & O_NONBLOCK)) fcntl(fileno(in), F_SETFL, flags);
|
||||||
return (res == EOF) ? feof(in) : 1;
|
if (res == EOF || ferror(in)) {
|
||||||
|
clearerr(in);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ungetc(res, in);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue