If Unix I/O detects an EOF, it doesn't kill the port completely; it will call read() next time you read. this means that multiple C+d's can be used to exit nested listeners on stdin
parent
587d02d35a
commit
35a953efb7
|
@ -10,7 +10,6 @@
|
||||||
- faster I/O
|
- faster I/O
|
||||||
- buffer-ptr should be an alien
|
- buffer-ptr should be an alien
|
||||||
- faster Unix stream-read#
|
- faster Unix stream-read#
|
||||||
- EOF kills a port
|
|
||||||
- fix this:
|
- fix this:
|
||||||
[ 1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10 10 11 11 11 113 ] .
|
[ 1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10 10 11 11 11 113 ] .
|
||||||
[ 1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10 10 11 11 11 113
|
[ 1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10 10 11 11 11 113
|
||||||
|
|
|
@ -198,9 +198,15 @@ M: read1-task task-container drop read-tasks get-global ;
|
||||||
[ swap <read1-task> add-io-task stop ] callcc0
|
[ swap <read1-task> add-io-task stop ] callcc0
|
||||||
] when pending-error ;
|
] when pending-error ;
|
||||||
|
|
||||||
|
: unless-eof ( port quot -- value )
|
||||||
|
over port-eof? [
|
||||||
|
f rot set-port-eof? drop f
|
||||||
|
] [
|
||||||
|
call
|
||||||
|
] if ; inline
|
||||||
|
|
||||||
M: input-port stream-read1
|
M: input-port stream-read1
|
||||||
dup wait-to-read1
|
dup wait-to-read1 [ buffer-pop ] unless-eof ;
|
||||||
dup port-eof? [ drop f ] [ buffer-pop ] if ;
|
|
||||||
|
|
||||||
! Reading character counts
|
! Reading character counts
|
||||||
: read-step ( count reader -- ? )
|
: read-step ( count reader -- ? )
|
||||||
|
@ -242,8 +248,8 @@ M: read-task task-container drop read-tasks get-global ;
|
||||||
|
|
||||||
M: input-port stream-read
|
M: input-port stream-read
|
||||||
>r 0 max >fixnum r>
|
>r 0 max >fixnum r>
|
||||||
[ wait-to-read ] keep dup port-eof?
|
[ wait-to-read ] keep
|
||||||
[ drop f ] [ port-sbuf >string ] if ;
|
[ port-sbuf >string ] unless-eof ;
|
||||||
|
|
||||||
! Writers
|
! Writers
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue