wingo pushed a commit to branch wip-port-refactor
in repository guile.
commit 422f65fe09e93bff383cc3e818204902ed0d32d2
Author: Andy Wingo <[email protected]>
Date: Sun May 1 22:00:37 2016 +0200
Minor tweak to Scheme peek-byte.
* module/ice-9/ports.scm (peek-byte): Use second return from
fill-input.
---
module/ice-9/ports.scm | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/module/ice-9/ports.scm b/module/ice-9/ports.scm
index 2bc12c5..db1c6f7 100644
--- a/module/ice-9/ports.scm
+++ b/module/ice-9/ports.scm
@@ -241,11 +241,12 @@
(cur (port-buffer-cur buf)))
(if (< cur (port-buffer-end buf))
(bytevector-u8-ref (port-buffer-bytevector buf) cur)
- (let* ((buf (fill-input port))
- (cur (port-buffer-cur buf)))
- (if (< cur (port-buffer-end buf))
- (bytevector-u8-ref (port-buffer-bytevector buf) cur)
- the-eof-object)))))
+ (call-with-values (lambda () (fill-input port))
+ (lambda (buf buffered)
+ (if (zero? buffered)
+ the-eof-object
+ (bytevector-u8-ref (port-buffer-bytevector buf)
+ (port-buffer-cur buf))))))))