diff --git a/basis/io/backend/unix/unix.factor b/basis/io/backend/unix/unix.factor index 3245d80d4e..ebb8f1ec05 100644 --- a/basis/io/backend/unix/unix.factor +++ b/basis/io/backend/unix/unix.factor @@ -50,7 +50,7 @@ M: fd cancel-operation ( fd -- ) ] if ; M: unix tell-handle ( handle -- n ) - fd>> SEEK_SET 0 lseek [ io-error ] [ ] bi ; + fd>> 0 SEEK_CUR lseek [ io-error ] [ ] bi ; M: unix seek-handle ( n seek-type handle -- ) swap { diff --git a/basis/io/ports/ports.factor b/basis/io/ports/ports.factor index 7ecb420478..8cdd1d97bd 100644 --- a/basis/io/ports/ports.factor +++ b/basis/io/ports/ports.factor @@ -130,7 +130,7 @@ HOOK: seek-handle os ( n seek-type handle -- ) M: buffered-port stream-tell ( stream -- n ) [ check-disposed ] [ handle>> tell-handle ] - [ buffer>> pos>> ] tri + ; + [ [ buffer>> size>> - 0 max ] [ buffer>> pos>> ] bi + ] tri ; M: input-port stream-seek ( n seek-type stream -- ) [ check-disposed ]