1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-29 22:40:34 +02:00

Fix fencepost error in bip_seek

* libguile/r6rs-ports.c (bip_seek): Fix to allow seeking to end of port.

* test-suite/tests/r6rs-ports.test ("bytevector input port can seek to
  very end"): Add tests.
This commit is contained in:
Ian Price 2011-04-08 02:49:20 +01:00 committed by Andy Wingo
parent 15993bce1c
commit c89b452993
2 changed files with 10 additions and 1 deletions

View file

@ -136,7 +136,7 @@ bip_seek (SCM port, scm_t_off offset, int whence)
/* Fall through. */
case SEEK_SET:
if (c_port->read_buf + offset < c_port->read_end)
if (c_port->read_buf + offset <= c_port->read_end)
{
c_port->read_pos = c_port->read_buf + offset;
c_result = offset;

View file

@ -320,6 +320,15 @@
(u8-list->bytevector
(map char->integer (string->list "Port!")))))))
(pass-if "bytevector input port can seek to very end"
(let ((empty (open-bytevector-input-port '#vu8()))
(not-empty (open-bytevector-input-port '#vu8(1 2 3))))
(and (begin (set-port-position! empty (port-position empty))
(= 0 (port-position empty)))
(begin (get-bytevector-n not-empty 3)
(set-port-position! not-empty (port-position not-empty))
(= 3 (port-position not-empty))))))
(pass-if-exception "make-custom-binary-input-port [wrong-num-args]"
exception:wrong-num-args