fix peek implementation in R6RS input ports

The peek operation must not block, otherwise the port behaves
badly for `sync`.

Based on a bug report from Brett Stahlman.
This commit is contained in:
Matthew Flatt 2014-09-14 16:38:04 +02:00
parent 9dbc4842f7
commit 7304420691
2 changed files with 7 additions and 1 deletions

View File

@ -164,7 +164,7 @@
n)))
(lambda (bytes skip evt)
(check-disconnect)
(let ([n (peek-bytes-avail! bytes skip evt port)])
(let ([n (peek-bytes-avail!* bytes skip evt port)])
(if (eq? n 0)
(wrap-evt port (lambda (v) 0))
n)))

View File

@ -0,0 +1,6 @@
#lang racket
(require rnrs/io/ports-6)
;; Make sure that an R6RS port plays ok with sync,
;; particularly when no input is available.
(void (sync/timeout 0 (standard-input-port)))