replaced code-vector by byte-vector (not that this is a real difference)

This commit is contained in:
marting 1999-11-04 20:43:36 +00:00
parent 8cf59dae09
commit 8c4d87dde6
1 changed files with 17 additions and 14 deletions

View File

@ -5,6 +5,9 @@
; See doc/io.txt for a description of the i/o system, including ports, ; See doc/io.txt for a description of the i/o system, including ports,
; port handlers, and so forth. ; 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 (define-record-type port-handler :port-handler
(really-make-port-handler discloser close buffer-proc steal) (really-make-port-handler discloser close buffer-proc steal)
port-handler? port-handler?
@ -103,7 +106,7 @@
(let ((index (port-index port))) (let ((index (port-index port)))
(if read? (if read?
(set-port-index! port (+ 1 index))) (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) ((port-pending-eof? port)
(if read? (if read?
(set-port-pending-eof?! port #f)) (set-port-pending-eof?! port #f))
@ -118,7 +121,7 @@
(else (else
(set-port-index! port (if read? 1 0)) (set-port-index! port (if read? 1 0))
(set-port-limit! port got) (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) (define (fill-port-buffer! port needed)
((port-handler-buffer-proc (port-handler port)) ((port-handler-buffer-proc (port-handler port))
@ -132,7 +135,7 @@
(define (write-char-handler char port) (define (write-char-handler char port)
(cond ((< (port-index port) (port-limit port)) (cond ((< (port-index port) (port-limit port))
(code-vector-set! (port-buffer port) (byte-vector-set! (port-buffer port)
(port-index port) (port-index port)
(char->ascii char)) (char->ascii char))
(set-port-index! port (+ 1 (port-index port)))) (set-port-index! port (+ 1 (port-index port))))
@ -140,7 +143,7 @@
((port-handler-buffer-proc (port-handler port)) (port-data port) char)) ((port-handler-buffer-proc (port-handler port)) (port-data port) char))
(else (else
(empty-port-buffer! port) (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))) (set-port-index! port 1)))
(unspecific)) (unspecific))
@ -291,7 +294,7 @@
(define (buffer-length buffer) (define (buffer-length buffer)
(if (string? buffer) (if (string? buffer)
(string-length buffer) (string-length buffer)
(code-vector-length buffer))) (byte-vector-length buffer)))
(define (read-more buffer start count port have) (define (read-more buffer start count port have)
(let ((more ((port-handler-buffer-proc (port-handler port)) (let ((more ((port-handler-buffer-proc (port-handler port))
@ -319,8 +322,8 @@
(<= (+ start count) (<= (+ start count)
(cond ((string? buffer) (cond ((string? buffer)
(string-length buffer)) (string-length buffer))
((code-vector? buffer) ((byte-vector? buffer)
(code-vector-length buffer)) (byte-vector-length buffer))
(else (else
-1))))) -1)))))
@ -363,7 +366,7 @@
((= i count)) ((= i count))
(proc data (if string? (proc data (if string?
(string-ref buffer (+ start i)) (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. ; Empty the buffer if it contains anything.
@ -436,8 +439,8 @@
make-input-port handler data buffer index limit))) make-input-port handler data buffer index limit)))
(define (okay-buffer? buffer index limit) (define (okay-buffer? buffer index limit)
(and (code-vector? buffer) (and (byte-vector? buffer)
(let ((length (code-vector-length buffer))) (let ((length (byte-vector-length buffer)))
(integer? limit) (integer? limit)
(<= 0 limit) (<= 0 limit)
(<= limit length) (<= limit length)
@ -488,7 +491,7 @@
(make-lock) (make-lock)
#f ; locked? #f ; locked?
data data
(make-code-vector 0 0) (make-byte-vector 0 0)
0 0
0 0
#f) ; pending-eof? #f) ; pending-eof?
@ -512,7 +515,7 @@
(make-lock) ; wasted (make-lock) ; wasted
#f ; locked? #f ; locked?
(unspecific) (unspecific)
(make-code-vector 1 0) (make-byte-vector 1 0)
0 0
1 ; if 0 it would look unbuffered 1 ; if 0 it would look unbuffered
#f)) ; pending-eof? #f)) ; pending-eof?
@ -631,9 +634,9 @@
(eof? (port-pending-eof? port)) (eof? (port-pending-eof? port))
(status ((port-handler-steal (port-handler port)) (status ((port-handler-steal (port-handler port))
(port-data port) owner))) (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-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-pending-eof?! port #f)
(set-port-locked?! port #f) (set-port-locked?! port #f)
(set-port-lock! port (make-lock)) (set-port-lock! port (make-lock))