diff --git a/RELEASE b/RELEASE index e2efa12..25a22cb 100644 --- a/RELEASE +++ b/RELEASE @@ -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 diff --git a/doc/scsh-manual/syscalls.tex b/doc/scsh-manual/syscalls.tex index d7a0ec0..762735c 100644 --- a/doc/scsh-manual/syscalls.tex +++ b/doc/scsh-manual/syscalls.tex @@ -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} diff --git a/scsh/syscalls.scm b/scsh/syscalls.scm index d7fe6fb..70d329f 100644 --- a/scsh/syscalls.scm +++ b/scsh/syscalls.scm @@ -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)))