I think the buffer-ports egg incorrectly sign-extends bytes read from byte vectors that are greater than 127 and have the high bit set.
To reproduce: (use buffer-ports) (read-byte (open-input-port #u8(#x80))) ; => #x1FFF80 If this is not the expected behaviour, the attached patch changes this according to the included test case. Regards, Simon.
diff -r trunk/buffer-ports.scm buffer-ports/buffer-ports.scm 38c38 < C_make_character(((C_char *)C_block_item(ptr, 0))[ C_unfix(i) ]) --- > C_make_character(((C_uchar *)C_block_item(ptr, 0))[ C_unfix(i) ]) diff -r trunk/buffer-ports.setup buffer-ports/buffer-ports.setup 4c4 < (standard-extension 'buffer-ports "0.7") --- > (standard-extension 'buffer-ports "0.8") diff -r trunk/tests/run.scm buffer-ports/tests/run.scm 85a86,98 > > (print "read/write u8vector:") > (let* ((buf #u8(0 0 0)) > (out (open-output-buffer buf)) > (in (open-input-buffer buf))) > (write-byte 127 out) > (write-byte 128 out) > (print buf) > (assert (= 127 (read-byte in))) > (assert (= 128 (read-byte in))) > (assert (= 0 (read-byte in))) > (assert (eq? #!eof (read-byte in)))) >
_______________________________________________ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers