replaced code-vector by byte-vector (not that this is a real difference)
This commit is contained in:
parent
8cf59dae09
commit
8c4d87dde6
|
@ -5,6 +5,9 @@
|
|||
; See doc/io.txt for a description of the i/o system, including ports,
|
||||
; port handlers, and so forth.
|
||||
|
||||
;;; This is not the original file, but an adapted version for scsh
|
||||
;;; Main difference is, that the ports have a steal-field
|
||||
|
||||
(define-record-type port-handler :port-handler
|
||||
(really-make-port-handler discloser close buffer-proc steal)
|
||||
port-handler?
|
||||
|
@ -103,7 +106,7 @@
|
|||
(let ((index (port-index port)))
|
||||
(if read?
|
||||
(set-port-index! port (+ 1 index)))
|
||||
(ascii->char (code-vector-ref (port-buffer port) index))))
|
||||
(ascii->char (byte-vector-ref (port-buffer port) index))))
|
||||
((port-pending-eof? port)
|
||||
(if read?
|
||||
(set-port-pending-eof?! port #f))
|
||||
|
@ -118,7 +121,7 @@
|
|||
(else
|
||||
(set-port-index! port (if read? 1 0))
|
||||
(set-port-limit! port got)
|
||||
(ascii->char (code-vector-ref (port-buffer port) 0)))))))))
|
||||
(ascii->char (byte-vector-ref (port-buffer port) 0)))))))))
|
||||
|
||||
(define (fill-port-buffer! port needed)
|
||||
((port-handler-buffer-proc (port-handler port))
|
||||
|
@ -132,7 +135,7 @@
|
|||
|
||||
(define (write-char-handler char port)
|
||||
(cond ((< (port-index port) (port-limit port))
|
||||
(code-vector-set! (port-buffer port)
|
||||
(byte-vector-set! (port-buffer port)
|
||||
(port-index port)
|
||||
(char->ascii char))
|
||||
(set-port-index! port (+ 1 (port-index port))))
|
||||
|
@ -140,7 +143,7 @@
|
|||
((port-handler-buffer-proc (port-handler port)) (port-data port) char))
|
||||
(else
|
||||
(empty-port-buffer! port)
|
||||
(code-vector-set! (port-buffer port) 0 (char->ascii char))
|
||||
(byte-vector-set! (port-buffer port) 0 (char->ascii char))
|
||||
(set-port-index! port 1)))
|
||||
(unspecific))
|
||||
|
||||
|
@ -291,7 +294,7 @@
|
|||
(define (buffer-length buffer)
|
||||
(if (string? buffer)
|
||||
(string-length buffer)
|
||||
(code-vector-length buffer)))
|
||||
(byte-vector-length buffer)))
|
||||
|
||||
(define (read-more buffer start count port have)
|
||||
(let ((more ((port-handler-buffer-proc (port-handler port))
|
||||
|
@ -319,8 +322,8 @@
|
|||
(<= (+ start count)
|
||||
(cond ((string? buffer)
|
||||
(string-length buffer))
|
||||
((code-vector? buffer)
|
||||
(code-vector-length buffer))
|
||||
((byte-vector? buffer)
|
||||
(byte-vector-length buffer))
|
||||
(else
|
||||
-1)))))
|
||||
|
||||
|
@ -363,7 +366,7 @@
|
|||
((= i count))
|
||||
(proc data (if string?
|
||||
(string-ref buffer (+ start i))
|
||||
(ascii->char (code-vector-ref buffer (+ start i))))))))
|
||||
(ascii->char (byte-vector-ref buffer (+ start i))))))))
|
||||
|
||||
;----------------
|
||||
; Empty the buffer if it contains anything.
|
||||
|
@ -436,8 +439,8 @@
|
|||
make-input-port handler data buffer index limit)))
|
||||
|
||||
(define (okay-buffer? buffer index limit)
|
||||
(and (code-vector? buffer)
|
||||
(let ((length (code-vector-length buffer)))
|
||||
(and (byte-vector? buffer)
|
||||
(let ((length (byte-vector-length buffer)))
|
||||
(integer? limit)
|
||||
(<= 0 limit)
|
||||
(<= limit length)
|
||||
|
@ -488,7 +491,7 @@
|
|||
(make-lock)
|
||||
#f ; locked?
|
||||
data
|
||||
(make-code-vector 0 0)
|
||||
(make-byte-vector 0 0)
|
||||
0
|
||||
0
|
||||
#f) ; pending-eof?
|
||||
|
@ -512,7 +515,7 @@
|
|||
(make-lock) ; wasted
|
||||
#f ; locked?
|
||||
(unspecific)
|
||||
(make-code-vector 1 0)
|
||||
(make-byte-vector 1 0)
|
||||
0
|
||||
1 ; if 0 it would look unbuffered
|
||||
#f)) ; pending-eof?
|
||||
|
@ -631,9 +634,9 @@
|
|||
(eof? (port-pending-eof? port))
|
||||
(status ((port-handler-steal (port-handler port))
|
||||
(port-data port) owner)))
|
||||
(set-port-buffer! port (make-code-vector (code-vector-length buffer) 0))
|
||||
(set-port-buffer! port (make-byte-vector (byte-vector-length buffer) 0))
|
||||
(set-port-index! port 0)
|
||||
(set-port-limit! port (if (input-port? port) 0 (code-vector-length buffer)))
|
||||
(set-port-limit! port (if (input-port? port) 0 (byte-vector-length buffer)))
|
||||
(set-port-pending-eof?! port #f)
|
||||
(set-port-locked?! port #f)
|
||||
(set-port-lock! port (make-lock))
|
||||
|
|
Loading…
Reference in New Issue