mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 13:49:17 +02:00
fixing bug in flushed output on custom ports
This commit is contained in:
parent
f16e889e04
commit
f5a228ee9e
2 changed files with 15 additions and 1 deletions
|
@ -179,7 +179,7 @@
|
||||||
(lambda (bv start end)
|
(lambda (bv start end)
|
||||||
(do ((i start (+ i 1))
|
(do ((i start (+ i 1))
|
||||||
(x 0 (+ x (bytevector-u8-ref bv i))))
|
(x 0 (+ x (bytevector-u8-ref bv i))))
|
||||||
((= i end) (set! sum x)))))))
|
((= i end) (set! sum (+ sum x))))))))
|
||||||
(write-bytevector #u8(0 1 2 3) out)
|
(write-bytevector #u8(0 1 2 3) out)
|
||||||
(flush-output out)
|
(flush-output out)
|
||||||
(test 6 sum)
|
(test 6 sum)
|
||||||
|
@ -187,6 +187,19 @@
|
||||||
(flush-output out)
|
(flush-output out)
|
||||||
(test 106 sum))
|
(test 106 sum))
|
||||||
|
|
||||||
|
(let* ((ls '())
|
||||||
|
(out (make-custom-output-port
|
||||||
|
(lambda (str start end)
|
||||||
|
(set! ls (cons (substring str start end) ls))
|
||||||
|
(- end start)))))
|
||||||
|
(display "Test1\n" out)
|
||||||
|
(flush-output out)
|
||||||
|
(display "Test2\n" out)
|
||||||
|
(flush-output out)
|
||||||
|
(display "Test3\n" out)
|
||||||
|
(flush-output out)
|
||||||
|
(test "Test1\nTest2\nTest3\n" (string-concatenate (reverse ls))))
|
||||||
|
|
||||||
(test "file-position"
|
(test "file-position"
|
||||||
'(0 1 2)
|
'(0 1 2)
|
||||||
(let* ((p (open-input-file "/etc/passwd"))
|
(let* ((p (open-input-file "/etc/passwd"))
|
||||||
|
|
1
sexp.c
1
sexp.c
|
@ -1471,6 +1471,7 @@ int sexp_buffered_flush (sexp ctx, sexp p, int forcep) {
|
||||||
tmp = sexp_list2(ctx, SEXP_ZERO, sexp_make_fixnum(sexp_port_offset(p)));
|
tmp = sexp_list2(ctx, SEXP_ZERO, sexp_make_fixnum(sexp_port_offset(p)));
|
||||||
tmp = sexp_cons(ctx, sexp_port_binaryp(p) ? sexp_string_bytes(sexp_port_buffer(p)) : sexp_port_buffer(p), tmp);
|
tmp = sexp_cons(ctx, sexp_port_binaryp(p) ? sexp_string_bytes(sexp_port_buffer(p)) : sexp_port_buffer(p), tmp);
|
||||||
tmp = sexp_apply(ctx, sexp_port_writer(p), tmp);
|
tmp = sexp_apply(ctx, sexp_port_writer(p), tmp);
|
||||||
|
sexp_port_offset(p) = 0;
|
||||||
res = (sexp_fixnump(tmp) && sexp_unbox_fixnum(tmp) > 0) ? 0 : -1;
|
res = (sexp_fixnump(tmp) && sexp_unbox_fixnum(tmp) > 0) ? 0 : -1;
|
||||||
} else { /* string port */
|
} else { /* string port */
|
||||||
tmp = sexp_c_string(ctx, sexp_port_buf(p), off);
|
tmp = sexp_c_string(ctx, sexp_port_buf(p), off);
|
||||||
|
|
Loading…
Add table
Reference in a new issue