fixed (read-bytes/partial! _ _ n n)

added (assert ... <calling procedure>)
.
This commit is contained in:
Rolf-Thomas Happe 2003-04-22 17:13:43 +00:00
parent 62ab061350
commit cc2b4fe985
1 changed files with 35 additions and 27 deletions

View File

@ -33,9 +33,10 @@
;; the buffer size. READ-BOLLOCK prefers to read maybe less than
;; available but to avoid allocating a temp buffer ]
(define (read-bollock buf start min uebermax inport)
(assert (<= 0 min uebermax))
(assert (<= 0 min uebermax) read-bollock)
(assert (<= (+ start uebermax)
(sequence-length buf)))
(sequence-length buf))
read-bollock)
(let* ((len (sequence-length buf))
(mean (if (= min 0) 0
(read-block buf start min inport)))
@ -58,21 +59,25 @@
(let-optionals args ((fd/port (current-input-port))
(start 0)
(end (sequence-length bytes)))
(assert (<= 0 start end (sequence-length bytes)))
(if (integer? fd/port)
(let ((port (fdes->inport fd/port)))
(set-port-buffering port bufpol/block (- end start))
(read-bytes!/partial bytes port start end))
(let ((blocking-i/o? (= 0 (bitwise-and open/non-blocking
(fdes-status fd/port)))))
(read-bollock bytes start
(if blocking-i/o? 1 0) ; cond. forward progress
(- end start)
fd/port)))))
(assert (<= 0 start end (sequence-length bytes))
read-bytes!/partial)
(cond ((= end start) 0)
((integer? fd/port)
(let ((port (fdes->inport fd/port)))
(set-port-buffering port bufpol/block (- end start))
(read-bytes!/partial bytes port start end)))
(else
(let ((blocking-i/o? (= 0 (bitwise-and open/non-blocking
(fdes-status fd/port)))))
(read-bollock bytes start
(if blocking-i/o? 1 0) ; cond. forward progress
(- end start)
fd/port))))))
(define (read-bytes/partial len . maybe-fd/port)
(assert (<= 0 len))
(assert (<= 0 len)
read-bytes/partial)
(let* ((fd/port (:optional maybe-fd/port (current-input-port)))
(buf (make-byte-vector len 0))
(nread (read-bytes!/partial buf fd/port 0 len)))
@ -88,7 +93,8 @@
(let-optionals args ((fd/port (current-input-port))
(start 0)
(end (sequence-length bytes)))
(assert (<= 0 start end (sequence-length bytes)))
(assert (<= 0 start end (sequence-length bytes))
read-bytes!)
(if (integer? fd/port)
(let ((port (fdes->inport fd/port)))
(set-port-buffering port bufpol/block (- end start))
@ -99,7 +105,7 @@
(define (read-bytes len . maybe-fd/port)
(assert (<= 0 len))
(assert (<= 0 len) read-bytes)
(let* ((fd/port (:optional maybe-fd/port (current-input-port)))
(buf (make-byte-vector len 0))
(nread (read-bytes! buf fd/port 0 len)))
@ -112,7 +118,8 @@
(let-optionals args ((fd/port (current-output-port))
(start 0)
(end (sequence-length bytes)))
(assert (<= 0 start end (sequence-length bytes)))
(assert (<= 0 start end (sequence-length bytes))
write-bytes/partial)
(error
"write-bytes/partial : behaves no better than write-string/partial.
The latter is dereleased, cf. the RELEASE notes."
@ -125,7 +132,8 @@ The latter is dereleased, cf. the RELEASE notes."
(let-optionals args ((fd/port (current-output-port))
(start 0)
(end (sequence-length bytes)))
(assert (<= 0 start end (sequence-length bytes)))
(assert (<= 0 start end (sequence-length bytes))
write-bytes)
(let ((port (if (integer? fd/port)
(let ((port (fdes->outport fd/port)))
(set-port-buffering port bufpol/block (- end start))