mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-21 12:10:26 +02:00
close-port implementation in sports
* module/ice-9/sports.scm (close-port): New function. (port-bindings): Add close-port.
This commit is contained in:
parent
690b856d59
commit
25381bdbc0
1 changed files with 12 additions and 2 deletions
|
@ -54,7 +54,8 @@
|
|||
#:use-module (ice-9 match)
|
||||
#:replace (peek-char
|
||||
read-char
|
||||
force-output)
|
||||
force-output
|
||||
close-port)
|
||||
#:export (lookahead-u8
|
||||
get-u8
|
||||
get-bytevector-n
|
||||
|
@ -92,6 +93,15 @@
|
|||
(error "not an open output port" port))
|
||||
(flush-output port))
|
||||
|
||||
(define close-port
|
||||
(let ((%close-port (@ (guile) close-port)))
|
||||
(lambda (port)
|
||||
(cond
|
||||
((port-closed? port) #f)
|
||||
(else
|
||||
(when (output-port? port) (flush-output port))
|
||||
(%close-port port))))))
|
||||
|
||||
(define (default-read-waiter port) (port-poll port "r"))
|
||||
(define (default-write-waiter port) (port-poll port "w"))
|
||||
|
||||
|
@ -579,7 +589,7 @@
|
|||
|
||||
(define saved-port-bindings #f)
|
||||
(define port-bindings
|
||||
'(((guile) read-char peek-char force-output)
|
||||
'(((guile) read-char peek-char force-output close-port)
|
||||
((ice-9 binary-ports) get-u8 lookahead-u8 get-bytevector-n)
|
||||
((ice-9 rdelim) %read-line read-line read-delimited)))
|
||||
(define (install-sports!)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue