[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-hackers] [PATCH] Reset port EOF flag when seeking
From: |
Peter Bex |
Subject: |
Re: [Chicken-hackers] [PATCH] Reset port EOF flag when seeking |
Date: |
Sun, 31 Mar 2019 13:04:16 +0200 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
On Sun, Mar 31, 2019 at 12:54:33PM +0200, address@hidden wrote:
> The subject explains it all. I think that’s the correct thing to do.
>
> This fixes the tailf example of the inotify egg.
> --- a/posix-common.scm
> +++ b/posix-common.scm
> @@ -357,8 +357,9 @@ 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) ) )
> + (when (eq? (##sys#slot port 7) 'stream)
> + (##sys#setislot port 6 #f) ;; Reset EOF status
> + (##core#inline "C_fseek" port pos whence) ) )
I think this isn't entirely correct; your code returns either
#<unspecified> or whatever C_fseek returns. The wrapping "unless"
will thus see #<unspecified> if the when's condition is false.
Perhaps something more like
(cond ((port? port)
(and (eq? (##sys#slot port 7) 'stream)
(begin (##sys#setislot port 6 #f) ;; Reset EOF status
(##core#inline "C_fseek" port pos whence) )) ...)
though I don't really like the nested (and ... (begin ...)).
Cheers,
Peter
signature.asc
Description: PGP signature