Changeset 16155 in project for chicken


Ignore:
Timestamp:
10/08/09 09:07:24 (10 years ago)
Author:
felix
Message:

reverted backwards-incompatible changes to [set-]file-position[!]

Location:
chicken/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/posixunix.scm

    r16117 r16155  
    316316
    317317/* It is assumed that 'int' is-a 'long' */
    318 #define C_ftell(p)          (C_temporary_flonum = ftell(C_port_file(p)), C_SCHEME_UNDEFINED)
     318#define C_ftell(p)          C_fix(ftell(C_port_file(p)))
    319319#define C_fseek(p, n, w)    C_mk_nbool(fseek(C_port_file(p), C_num_to_int(n), C_unfix(w)))
    320 #define C_ftello(p)         (C_temporary_flonum = ftello(C_port_file(p)), C_SCHEME_UNDEFINED)
    321 #define C_fseeko(p, n, w)   C_mk_nbool(fseeko(C_port_file(p), C_num_to_int64(n), C_unfix(w)))
    322 #ifdef _POSIX_V6_ILP32_OFF32
    323 # define C_ftellX(p)        C_ftell(p)
    324 # define C_fseekX(p, n, w)  C_fseek(p, n, w)
    325 # define C_lseekX(fd, o, w) (C_temporary_flonum = lseek(C_unfix(fd), C_num_to_int(o), C_unfix(w)), C_SCHEME_UNDEFINED)
    326 #else
    327 # define C_ftellX(p)        C_ftello(p)
    328 # define C_fseekX(p, n, w)  C_fseeko(p, n, w)
    329 # define C_lseekX(fd, o, w) (C_temporary_flonum = lseek(C_unfix(fd), C_num_to_int64(o), C_unfix(w)), C_SCHEME_UNDEFINED)
    330 #endif
     320#define C_lseek(fd, o, w)     C_fix(lseek(C_unfix(fd), C_unfix(o), C_unfix(w)))
    331321
    332322#define C_zero_fd_set(i)      FD_ZERO(&C_fd_sets[ i ])
     
    844834   (lambda (port pos . whence)
    845835     (let ((whence (if (pair? whence) (car whence) _seek_set)))
    846        (##sys#check-number pos 'set-file-position!)
     836       (##sys#check-exact pos 'set-file-position!)
    847837       (##sys#check-exact whence 'set-file-position!)
    848838       (when (negative? pos)
     
    850840       (unless (cond ((port? port)
    851841                      (and (eq? (##sys#slot port 7) 'stream)
    852                            (##core#inline "C_fseekX" port pos whence) ) )
     842                           (##core#inline "C_fseek" port pos whence) ) )
    853843                     ((fixnum? port)
    854                       (##core#inline "C_lseekX" port pos whence))
     844                      (##core#inline "C_lseek" port pos whence))
    855845                     (else
    856846                      (##sys#signal-hook #:type-error 'set-file-position! "invalid file" port)) )
     
    862852     (let ((pos (cond ((port? port)
    863853                       (if (eq? (##sys#slot port 7) 'stream)
    864                            (begin (##core#inline "C_ftellX" port) (##sys#cons-flonum))
     854                           (##core#inline "C_ftell" port)
    865855                           -1) )
    866856                      ((fixnum? port)
    867                        (##core#inline "C_lseekX" port 0 _seek_cur)
    868                        (##sys#cons-flonum))
     857                       (##core#inline "C_lseek" port 0 _seek_cur) )
    869858                      (else
    870859                       (##sys#signal-hook #:type-error 'file-position "invalid file" port)) ) ) )
  • chicken/trunk/posixwin.scm

    r16120 r16155  
    320320
    321321/* It is assumed that 'int' is-a 'long' */
    322 #define C_ftell(p)          (C_temporary_flonum = ftell(C_port_file(p)), C_SCHEME_UNDEFINED)
     322#define C_ftell(p)          C_fix(ftell(C_port_file(p)))
    323323#define C_fseek(p, n, w)    C_mk_nbool(fseek(C_port_file(p), C_num_to_int(n), C_unfix(w)))
    324 #define C_ftello(p)         (C_temporary_flonum = _ftelli64(C_port_file(p)), C_SCHEME_UNDEFINED)
    325 #define C_fseeko(p, n, w)   C_mk_nbool(_fseeki64(C_port_file(p), C_num_to_int64(n), C_unfix(w)))
    326 /* Use ...o versions when we know what to link with */
    327 #define C_ftellX(p)         C_ftell(p)
    328 #define C_fseekX(p, n, w)   C_fseek(p, n, w)
    329 #define C_lseekX(fd, o, w)  (C_temporary_flonum = _lseeki64(C_unfix(fd), C_num_to_int64(o), C_unfix(w)), C_SCHEME_UNDEFINED)
     324#define C_lseek(fd, o, w)   C_fix(lseek(C_unfix(fd), C_unfix(o), C_unfix(w)))
    330325
    331326#define C_flushall()        C_fix(_flushall())
     
    11341129   (lambda (port pos . whence)
    11351130     (let ((whence (if (pair? whence) (car whence) _seek_set)))
    1136        (##sys#check-number pos 'set-file-position!)
     1131       (##sys#check-exact pos 'set-file-position!)
    11371132       (##sys#check-exact whence 'set-file-position!)
    11381133       (when (negative? pos)
     
    11401135       (unless (cond ((port? port)
    11411136                      (and (eq? (##sys#slot port 7) 'stream)
    1142                            (##core#inline "C_fseekX" port pos whence) ) )
     1137                           (##core#inline "C_fseek" port pos whence) ) )
    11431138                     ((fixnum? port)
    1144                       (##core#inline "C_lseekX" port pos whence))
     1139                      (##core#inline "C_lseek" port pos whence))
    11451140                     (else
    11461141                      (##sys#signal-hook #:type-error 'set-file-position! "invalid file" port)) )
     
    11521147     (let ((pos (cond ((port? port)
    11531148                       (if (eq? (##sys#slot port 7) 'stream)
    1154                            (begin (##core#inline "C_ftellX" port) (##sys#cons-flonum))
     1149                           (##core#inline "C_ftell" port)
    11551150                           -1) )
    11561151                      ((fixnum? port)
    1157                        (##core#inline "C_lseekX" port 0 _seek_cur)
    1158                        (##sys#cons-flonum))
     1152                       (##core#inline "C_lseek" port 0 _seek_cur))
    11591153                      (else
    11601154                       (##sys#signal-hook #:type-error 'file-position "invalid file" port)) ) ) )
  • chicken/trunk/tests/posix-tests.scm

    r16118 r16155  
    11(use files posix)
    22
    3 (define-constant SOME-FLONUM-POS 123456.0)
     3(define-constant SOME-POS 123456)
    44
    55(let ((tnpfilpn (create-temporary-file)))
    66  (let ((tmpfilno (file-open tnpfilpn (+ open/rdwr open/creat open/text))))
    7     (set-file-position! tmpfilno SOME-FLONUM-POS seek/end)
    8     (assert (= SOME-FLONUM-POS (file-position tmpfilno)))
     7    (set-file-position! tmpfilno SOME-POS seek/end)
     8    (assert (= SOME-POS (file-position tmpfilno)))
    99    (file-close tmpfilno)
    1010    (delete-file* tnpfilpn) ) )
     
    1313  (let ((tmpfilno (file-open tnpfilpn (+ open/rdwr open/creat open/text))))
    1414    (let ((port (open-output-file* tmpfilno)))
    15       (set-file-position! port SOME-FLONUM-POS seek/end)
    16       (assert (= SOME-FLONUM-POS (file-position port)))
     15      (set-file-position! port SOME-POS seek/end)
     16      (assert (= SOME-POS (file-position port)))
    1717      (close-output-port port)
    1818      (delete-file* tnpfilpn) ) ) )
Note: See TracChangeset for help on using the changeset viewer.