Ensure and document that SEEK works on unbuffered ports only.

This commit is contained in:
mainzelm 2003-11-12 11:07:29 +00:00
parent 903fdad089
commit 9b29fff8e1
3 changed files with 9 additions and 0 deletions

View File

@ -191,6 +191,8 @@ We manage the project using SourceForge:
This release adds support for SRFI 42.
** Bug fixes
- SEEK currently works on unbuffered ports only. Check this in the
implementation and oopsify it in the manual.
- Adjust documentation of some low-level regexp procedures
- Removed message argument form errno-error
- After fork/pipe, make the ports returned by the pipe the

View File

@ -572,6 +572,7 @@ this is dependent on the OS implementation.
The return value is the resulting position of the I/O cursor in the I/O stream.
\oops{The current implementation doesn't handle \var{offset} arguments
that are not immediate integers (\ie, representable in 30 bits).}
\oops{The current implementation doesn't handle buffered ports.}
\end{desc}

View File

@ -375,6 +375,12 @@
(define seek/end 2)
(define (seek fd/port offset . maybe-whence)
(if (and (open-input-port? fd/port)
(> (byte-vector-length (port-buffer fd/port)) 1))
(error "Seek does currently not work on buffered ports" fd/port))
(if (and (open-output-port? fd/port)
(> (byte-vector-length (port-buffer fd/port)) 0))
(error "Seek does currently not work on buffered ports" fd/port))
(let ((whence (:optional maybe-whence seek/set))
(fd (if (integer? fd/port) fd/port (port->fdes fd/port))))
(%fd-seek fd offset whence)))