From 0cfb3f1d396bb3d7bc817494b937063f5e8782ad Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Thu, 29 Mar 2012 14:19:23 -0400 Subject: [PATCH] fix flush for `make-pipe-with-specials' Closes PR 12659 --- collects/mzlib/port.rkt | 2 +- collects/tests/racket/portlib.rktl | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/collects/mzlib/port.rkt b/collects/mzlib/port.rkt index 2a87650775..81ce65d631 100644 --- a/collects/mzlib/port.rkt +++ b/collects/mzlib/port.rkt @@ -710,7 +710,7 @@ ;; write (lambda (str start end buffer? w/break?) (if (= start end) - #t + 0 (begin (resume-mgr) (call-with-semaphore diff --git a/collects/tests/racket/portlib.rktl b/collects/tests/racket/portlib.rktl index d07e1c7470..3694437cc8 100644 --- a/collects/tests/racket/portlib.rktl +++ b/collects/tests/racket/portlib.rktl @@ -877,6 +877,23 @@ (eq? (cadr r) 4) (memq (cadr r) '(2 4)))))) + +(let-values ([(in out) (make-pipe-with-specials)]) + (struct str (v) + #:property prop:custom-write + (lambda (a-str port mode) + (let ([recur (case mode + [(#t) write] + [(#f) display] + [else + (lambda (p port) + (print p port mode))])]) + (recur (str-v a-str) port)))) + (write (str "hello world") out) + (flush-output out) + (test "hello world" read in)) + + ;; -------------------------------------------------- (report-errs)