* Added $write-byte to ikarus.io-primitives.unsafe.ss

This commit is contained in:
Abdulaziz Ghuloum 2007-05-18 08:15:51 -04:00
parent bc41665bf3
commit 35fa003558
6 changed files with 32 additions and 2 deletions

Binary file not shown.

View File

@ -845,7 +845,12 @@ ikrt_open_output_file(ikp fname, ikp flagptr, ikpcb* pcb){
ikp
ikrt_write_file(ikp fd, ikp buff, ikp idx, ikpcb* pcb){
int bytes = write(unfix(fd), string_data(buff), unfix(idx));
int bytes;
if(tagof(buff) == bytevector_tag){
bytes = write(unfix(fd), buff+off_bytevector_data, unfix(idx));
} else {
bytes = write(unfix(fd), string_data(buff), unfix(idx));
}
return fix(bytes);
}

Binary file not shown.

View File

@ -24,6 +24,19 @@
($write-char c p)
(error 'write-char "~s is not an output-port" p))
(error 'write-char "~s is not a character" c))]))
#;(define write-byte
(case-lambda
[(c)
(if (char? c)
($write-char c (current-output-port))
(error 'write-char "~s is not a character" c))]
[(c p)
(if (char? c)
(if (output-port? p)
($write-char c p)
(error 'write-char "~s is not an output-port" p))
(error 'write-char "~s is not a character" c))]))
;;;
(define newline
(case-lambda

View File

@ -1,6 +1,6 @@
(library (ikarus io-primitives unsafe)
(export $write-char $read-char $unread-char $peek-char
(export $write-char $write-byte $read-char $unread-char $peek-char
$reset-input-port! $flush-output-port
$close-input-port $close-output-port)
(import
@ -20,6 +20,17 @@
($set-port-output-index! p ($fxadd1 idx)))
(($port-handler p) 'write-char c p)))))
(define $write-byte
(lambda (b p)
(let ([idx (port-output-index p)])
(if ($fx< idx ($port-output-size p))
(let ([buff ($port-output-buffer p)])
(if (string? buff)
(string-set! buff idx ($fixnum->char b))
($bytevector-set! buff idx b))
($set-port-output-index! p ($fxadd1 idx)))
(($port-handler p) 'write-byte b p)))))
(define $read-char
(lambda (p)
(let ([idx ($port-input-index p)])

View File

@ -589,6 +589,7 @@
[$close-input-port $io]
[$close-output-port $io]
[$write-char $io]
[$write-byte $io]
[$read-char $io]
[$peek-char $io]
[$unread-char $io]