mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-29 14:30: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:
parent
15993bce1c
commit
c89b452993
2 changed files with 10 additions and 1 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue