[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-janitors] #1339: char-ready? returns #f even when input is avai
From: |
Chicken Trac |
Subject: |
[Chicken-janitors] #1339: char-ready? returns #f even when input is available |
Date: |
Wed, 11 Jan 2017 08:41:53 -0000 |
#1339: char-ready? returns #f even when input is available
----------------------------+-------------------------------
Reporter: kooda | Owner:
Type: defect | Status: new
Priority: minor | Milestone: 5.0
Component: core libraries | Version: 4.11.0
Keywords: | Estimated difficulty: insane
----------------------------+-------------------------------
The current implementation of char-ready? on stdio files returns #f if you
have buffering enabled, didn’t consume the whole buffer and no more input
is available from the system’s point of view, as it only asks the system
via select or poll (see C_char_ready_p and C_check_fd_ready).
I’m afraid there’s no way to do better than this with stdio files, as
there is no way of checking the state of the buffer.
The workaround I found was to simply disable buffering altogether, like
so:
{{{
(set-buffering-mode! (current-input-port) #:none)
}}}
This bug probably requires a pretty big rework of ports.
Here is a little program that '''might''' show the erroneous behaviour:
{{{
(use posix)
(call-with-input-pipe "echo coucou"
(lambda (p)
(let loop ((c (read-char p)))
(unless (eof-object? c)
(print c)
(when (char-ready? p) (loop (read-char p)))))))
}}}
--
Ticket URL: <https://bugs.call-cc.org/ticket/1339>
CHICKEN Scheme <https://www.call-cc.org/>
CHICKEN Scheme is a compiler for the Scheme programming language.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Chicken-janitors] #1339: char-ready? returns #f even when input is available,
Chicken Trac <=