~ chicken-core (chicken-5) e249d730a0936105f6c7ddec8adf792f8ab294f9
commit e249d730a0936105f6c7ddec8adf792f8ab294f9
Author: Kooda <kooda@upyum.com>
AuthorDate: Mon Apr 1 10:52:54 2019 +0200
Commit: Peter Bex <peter@more-magic.net>
CommitDate: Fri Apr 5 11:05:35 2019 +0200
Reset port EOF flag when seeking
Signed-off-by: Peter Bex <peter@more-magic.net>
diff --git a/NEWS b/NEWS
index c39d106b..825acbfb 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@
- Core libraries
- Read-write invariance of special symbols starting with #! other
than #!key, #!rest or #!optional is now preserved (#1572).
+ - When using (set-file-position!) on a port, its EOF status will now
+ be reset.
5.0.1
diff --git a/posix-common.scm b/posix-common.scm
index bfd77941..73e14841 100644
--- a/posix-common.scm
+++ b/posix-common.scm
@@ -357,8 +357,10 @@ EOF
(##sys#check-fixnum pos 'set-file-position!)
(##sys#check-fixnum whence 'set-file-position!)
(unless (cond ((port? port)
- (and (eq? (##sys#slot port 7) 'stream)
- (##core#inline "C_fseek" port pos whence) ) )
+ (and-let* ((stream (eq? (##sys#slot port 7) 'stream))
+ (res (##core#inline "C_fseek" port pos whence)))
+ (##sys#setislot port 6 #f) ;; Reset EOF status
+ res))
((fixnum? port)
(##core#inline "C_lseek" port pos whence))
(else
Trap