chicken-janitors
[Top][All Lists]
Advanced

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

[Chicken-janitors] [Chicken-bugs] #444: (file-position) fails on files >


From: Chicken Scheme
Subject: [Chicken-janitors] [Chicken-bugs] #444: (file-position) fails on files >1GB (on 32-bit systems, at least)
Date: Tue, 27 Jan 2009 11:56:56 -0000

#444: (file-position) fails on files >1GB (on 32-bit systems, at least)
--------------------+-------------------------------------------------------
 Reporter:  alaric  |        Type:  defect        
   Status:  new     |    Priority:  minor         
Milestone:          |   Component:  core libraries
  Version:  3.0.0   |    Keywords:                
--------------------+-------------------------------------------------------
 Hello there folks,

 Trying to get the file position of a file that happens to be cresting
 over a gigabyte produces:

 Error: (file-position) cannot retrieve file position of port -
 Undefined error: 0: 5

 (the FD in question is 5, 0 is what errno contains).

 (file-position) in posixunix.scm from the chicken 4 head (as taken
 from the git mirror) shows:

   (let ([pos (cond [(port? port)
                     (if (eq? (##sys#slot port 7) 'stream)
                         (##core#inline "C_ftell" port)
                         -1) ]
                    [(fixnum? port) (##core#inline "C_lseek" port 0
 _seek_cur)]
                    [else (##sys#signal-hook #:type-error 'file-
 position "invalid file" port)] ) ] )
     (when (fx< pos 0)
       (posix-error #:file-error 'file-position "cannot retrieve file
 position of port" port) )
     pos) )

 I think the problem is that ##core#inline, seeing an int to big for a
 fixnum, is making a flonum, and fx< is then barfing upon it.

 The simple fix is s/fx</</ - and, ideally, bignum promotion, as
 exactness is a bonus with file positions ;-)

-- 
Ticket URL: <http://trac.callcc.org/ticket/444>
Chicken Scheme <http://www.call-with-current-continuation.org/>
The CHICKEN Scheme-to-C compiler

reply via email to

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