From 39d1cf4635b70335a229b621a833a3322c60f4a5 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 16 Jun 2011 09:18:47 -0600 Subject: [PATCH] support progress evts in result of `make-limited-input-port' and also adjust initial position in various port constructions to use `file-position' instead of `port-next-location' original commit: a9190621439b8bf8ecace2fd9e81217dcaed808d --- collects/mzlib/port.rkt | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/collects/mzlib/port.rkt b/collects/mzlib/port.rkt index 330f13f..fad66f2 100644 --- a/collects/mzlib/port.rkt +++ b/collects/mzlib/port.rkt @@ -529,8 +529,7 @@ (lambda (n evt target-evt) (port-commit-peeked n evt target-evt p))) (lambda () (port-next-location p)) (lambda () (port-count-lines! p)) - (let-values ([(line col pos) (port-next-location p)]) - (or pos (file-position p)))))) + (add1 (file-position p))))) ;; Not kill-safe. (define make-pipe-with-specials @@ -891,9 +890,14 @@ n))))) (lambda () (when close-orig? - (close-input-port port))))))) - - + (close-input-port port))) + (and (port-provides-progress-evts? port) + (lambda () (port-progress-evt port))) + (and (port-provides-progress-evts? port) + (lambda (n evt target-evt) (port-commit-peeked n evt target-evt port))) + (lambda () (port-next-location port)) + (lambda () (port-count-lines! port)) + (add1 (file-position port)))))) (define special-filter-input-port (lambda (p filter [close? #t]) @@ -927,8 +931,7 @@ (lambda (n evt target-evt) (port-commit-peeked n evt target-evt p))) (lambda () (port-next-location p)) (lambda () (port-count-lines! p)) - (let-values ([(l c p) (port-next-location p)]) - p)))) + (add1 (file-position p))))) ;; ---------------------------------------- @@ -1758,8 +1761,7 @@ (let ([new (transplant-output-port p (lambda () (port-next-location p)) - (let-values ([(line col pos) (port-next-location p)]) - (or pos (file-position p))) + (add1 (file-position p)) close? (lambda () (port-count-lines! p)))]) (port-display-handler new (port-display-handler p)) @@ -1771,8 +1773,7 @@ (let ([new (transplant-input-port p (lambda () (port-next-location p)) - (let-values ([(line col pos) (port-next-location p)]) - (or pos (file-position p))) + (add1 (file-position p)) close? (lambda () (port-count-lines! p)))]) (port-read-handler new (port-read-handler p))