Include current buffered offset in file-position for output ports.

Fixes issue #273.
This commit is contained in:
Alex Shinn 2016-02-28 17:36:40 +09:00
parent 64f3e0fc56
commit 8ea51a77ce

View file

@ -417,6 +417,8 @@ sexp sexp_seek (sexp ctx, sexp self, sexp x, off_t offset, int whence) {
res = lseek(sexp_fileno_fd(sexp_port_fd(x)), offset, whence); res = lseek(sexp_fileno_fd(sexp_port_fd(x)), offset, whence);
if (res >= 0 && !(whence == SEEK_CUR && offset == 0)) if (res >= 0 && !(whence == SEEK_CUR && offset == 0))
sexp_port_offset(x) = 0; sexp_port_offset(x) = 0;
else if (sexp_oportp(x))
res += sexp_port_offset(x);
return sexp_make_integer(ctx, res); return sexp_make_integer(ctx, res);
} }
if (sexp_stream_portp(x)) if (sexp_stream_portp(x))