chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] negative file-position seek


From: Seth Alves
Subject: [Chicken-hackers] negative file-position seek
Date: Thu, 24 Apr 2014 09:30:32 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

#!/usr/local/bin/csi -script

(use posix)

(let ((p (open-input-file "/etc/hosts")))
  (read-char p)
  (read-char p)
  (read-char p)
  (set-file-position! p -1 seek/cur))

---------------------------------------------------------------


Error: (set-file-position!) invalid negative port position
-1
#<input port "/etc/hosts">

--------------------------------------------------------------

diff --git a/posixunix.scm b/posixunix.scm
index 224e9b0..dc415d3 100644
--- a/posixunix.scm
+++ b/posixunix.scm
@@ -629,7 +629,7 @@ EOF
     (let ((whence (if (pair? whence) (car whence) _seek_set)))
       (##sys#check-exact pos 'set-file-position!)
       (##sys#check-exact whence 'set-file-position!)
-      (when (negative? pos)
+      (when (and (negative? pos) (eq? whence _seek_set))
        (##sys#signal-hook #:bounds-error 'set-file-position! "invalid
negative port position" pos port))
       (unless (cond ((port? port)
                     (and (eq? (##sys#slot port 7) 'stream)


    -seth




reply via email to

[Prev in Thread] Current Thread [Next in Thread]