Changeset 14554 in project for chicken/trunk/posixwin.scm


Ignore:
Timestamp:
05/07/09 11:59:34 (11 years ago)
Author:
felix winkelmann
Message:

fixed bug #16 (setter for file-position accepts list, now)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/posixwin.scm

    r13167 r14554  
    11211121
    11221122(define file-position
    1123   (lambda (port)
    1124     (let ([pos (cond [(port? port)
    1125                       (if (eq? (##sys#slot port 7) 'stream)
    1126                           (##core#inline "C_ftell" port)
    1127                           -1) ]
    1128                      [(fixnum? port) (##core#inline "C_lseek" port 0 _seek_cur)]
    1129                      [else (##sys#signal-hook #:type-error 'file-position "invalid file" port)] ) ] )
    1130       (when (fx< pos 0)
    1131         (##sys#update-errno)
    1132         (##sys#signal-hook #:file-error 'file-position "cannot retrieve file position of port" port) )
    1133       pos) ) )
    1134 
    1135 (define set-file-position!
    1136   (lambda (port pos . whence)
     1123  (getter-with-setter
     1124   (lambda (port)
     1125     (let ([pos (cond [(port? port)
     1126                       (if (eq? (##sys#slot port 7) 'stream)
     1127                           (##core#inline "C_ftell" port)
     1128                           -1) ]
     1129                      [(fixnum? port) (##core#inline "C_lseek" port 0 _seek_cur)]
     1130                      [else (##sys#signal-hook #:type-error 'file-position "invalid file" port)] ) ] )
     1131       (when (fx< pos 0)
     1132         (##sys#update-errno)
     1133         (##sys#signal-hook #:file-error 'file-position "cannot retrieve file position of port" port) )
     1134       pos) )
     1135   (lambda (port pos . whence)
    11371136    (let ([whence (if (pair? whence) (car whence) _seek_set)])
     1137      (when (and (list? pos) (fx= 2 (length pos)))
     1138        (set! whence (cadr pos))
     1139        (set! pos (car pos)))
    11381140      (##sys#check-exact pos 'set-file-position!)
    11391141      (##sys#check-exact whence 'set-file-position!)
     
    11451147                    [else (##sys#signal-hook #:type-error 'set-file-position! "invalid file" port)] )
    11461148        (##sys#update-errno)
    1147         (##sys#signal-hook #:file-error 'set-file-position! "cannot set file position" port pos) ) ) ) )
     1149        (##sys#signal-hook #:file-error 'set-file-position! "cannot set file position" port pos) ) ) ) ) )
    11481150
    11491151
Note: See TracChangeset for help on using the changeset viewer.