Changeset 14779 in project for chicken/trunk


Ignore:
Timestamp:
05/25/09 10:16:55 (11 years ago)
Author:
felix winkelmann
Message:

-debug e; added set-file-position! again

Location:
chicken/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/batch-driver.scm

    r14511 r14779  
    3535  compiler-arguments process-command-line dump-nodes dump-undefined-globals
    3636  default-standard-bindings default-extended-bindings
    37   foldable-bindings
     37  foldable-bindings dump-defined-globals
    3838  compiler-cleanup-hook disabled-warnings local-definitions inline-output-file
    3939  file-io-only undefine-shadowed-macros profiled-procedures
     
    564564                     (when first-analysis
    565565                       (when (memq 'u debugging-chicken)
    566                          (dump-undefined-globals db)) )
     566                         (dump-undefined-globals db))
     567                       (when (memq 'd debugging-chicken)
     568                         (dump-defined-globals db)) )
    567569                     (set! first-analysis #f)
    568570                     (end-time "analysis")
  • chicken/trunk/chicken-install.scm

    r14705 r14779  
    318318           (dbfile (make-pathname tmpdir +module-db+))
    319319           (rx (regexp ".*/([^/]+)\\.import\\.(scm|so)")))
     320      (print "loading import libraries ...")
    320321      (fluid-let ((##sys#warnings-enabled #f))
    321322        (for-each
  • chicken/trunk/manual/Unit posix

    r14554 r14779  
    406406
    407407<procedure>(file-position FILE)</procedure>
    408 <procedure>(set! (file-position FILE) POSITION)</procedure>
    409 
    410 {{file-position}} Returns the current file position of {{FILE}}, which should be a
     408
     409Returns the current file position of {{FILE}}, which should be a
    411410port or a file-descriptor.
    412 
    413 {{(set! (file-position FILE) POSITION)}} Sets the current read/write position of {{FILE}} to
    414 {{POSITION}}, which should be an exact integer or a list of two elements. {{FILE}}
    415 should be a port or a file-descriptor. If {{POSITION}} is a list, it should
    416 be of the form {{(POSITION WHENCE)}} where {{WHENCE}} specifies
    417 how the position is to interpreted and should be one of the values
    418 {{seek/set, seek/cur}} and {{seek/end}}. It defaults to
    419 {{seek/set}}.
    420 
    421 Exceptions: {{(exn bounds)}}, {{(exn i/o file)}}
    422 
    423411
    424412==== file-size
     
    494482{{OFFSET}} then nothing is done.  {{FILE}} should be a filename
    495483or a file-descriptor.
     484
     485==== set-file-position!
     486
     487<procedure>(set-file-position! FILE POSITION [WHENCE])</procedure>
     488<procedure>(set! (file-position FILE) POSITION)</procedure>
     489
     490Sets the current read/write position of {{FILE}} to
     491{{POSITION}}, which should be an exact integer. {{FILE}}
     492should be a port or a file-descriptor.  {{WHENCE}} specifies
     493how the position is to interpreted and should be one of the values
     494{{seek/set, seek/cur}} and {{seek/end}}. It defaults to
     495{{seek/set}}.
     496
     497Exceptions: {{(exn bounds)}}, {{(exn i/o file)}}
    496498
    497499==== change-file-mode
  • chicken/trunk/manual/Using the compiler

    r14511 r14779  
    4949     c          print every expression before macro-expansion
    5050     u          lists all unassigned global variable references
     51     d          lists all assigned global variables
    5152     x          display information about experimental features
    5253     D          when printing nodes, use node-tree output
  • chicken/trunk/posix.import.scm

    r12937 r14779  
    114114   file-permissions
    115115   file-position
     116   set-file-position!
    116117   file-read
    117118   file-read-access?
  • chicken/trunk/posixunix.scm

    r14554 r14779  
    825825    (foreign-value "C_issock" bool))
    826826
    827 (define file-position
    828   (getter-with-setter
    829    (lambda (port)
    830     (let ([pos (cond [(port? port)
    831                       (if (eq? (##sys#slot port 7) 'stream)
    832                           (##core#inline "C_ftell" port)
    833                           -1) ]
    834                      [(fixnum? port) (##core#inline "C_lseek" port 0 _seek_cur)]
    835                      [else (##sys#signal-hook #:type-error 'file-position "invalid file" port)] ) ] )
    836       (when (fx< pos 0)
    837         (posix-error #:file-error 'file-position "cannot retrieve file position of port" port) )
    838       pos) )
     827(define set-file-position!
    839828   (lambda (port pos . whence)
    840      (let ((whence (if (pair? whence) (car whence) _seek_set)))
    841        (when (and (list? pos) (fx= 2 (length pos)))
    842          (set! whence (cadr pos))
    843          (set! pos (car pos)))
     829     (let ([whence (if (pair? whence) (car whence) _seek_set)])
    844830       (##sys#check-exact pos 'set-file-position!)
    845831       (##sys#check-exact whence 'set-file-position!)
     
    850836                     [(fixnum? port) (##core#inline "C_lseek" port pos whence)]
    851837                     [else (##sys#signal-hook #:type-error 'set-file-position! "invalid file" port)] )
    852          (posix-error #:file-error 'set-file-position! "cannot set file position" port pos) ) ) ) ) )
     838         (posix-error #:file-error 'set-file-position! "cannot set file position" port pos) ) ) ) )
     839
     840(define file-position
     841  (getter-with-setter
     842   (lambda (port)
     843     (let ([pos (cond [(port? port)
     844                       (if (eq? (##sys#slot port 7) 'stream)
     845                           (##core#inline "C_ftell" port)
     846                           -1) ]
     847                      [(fixnum? port) (##core#inline "C_lseek" port 0 _seek_cur)]
     848                      [else (##sys#signal-hook #:type-error 'file-position "invalid file" port)] ) ] )
     849       (when (fx< pos 0)
     850         (posix-error #:file-error 'file-position "cannot retrieve file position of port" port) )
     851       pos) )
     852   set-file-position!) )                ; doesn't accept WHENCE
    853853
    854854
  • chicken/trunk/posixwin.scm

    r14554 r14779  
    11201120    (set! stat-socket? (stat-type 'stat-socket?)))
    11211121
     1122(define set-file-position!
     1123  (lambda (port pos . whence)
     1124    (let ([whence (if (pair? whence) (car whence) _seek_set)])
     1125      (##sys#check-exact pos 'set-file-position!)
     1126      (##sys#check-exact whence 'set-file-position!)
     1127      (when (fx< pos 0) (##sys#signal-hook #:bounds-error 'set-file-position! "invalid negative port position" pos port))
     1128      (unless (cond [(port? port)
     1129                     (and (eq? (##sys#slot port 7) 'stream)
     1130                          (##core#inline "C_fseek" port pos whence) ) ]
     1131                    [(fixnum? port) (##core#inline "C_lseek" port pos whence)]
     1132                    [else (##sys#signal-hook #:type-error 'set-file-position! "invalid file" port)] )
     1133        (##sys#update-errno)
     1134        (##sys#signal-hook #:file-error 'set-file-position! "cannot set file position" port pos) ) ) ) )
     1135
    11221136(define file-position
    11231137  (getter-with-setter
     
    11331147         (##sys#signal-hook #:file-error 'file-position "cannot retrieve file position of port" port) )
    11341148       pos) )
    1135    (lambda (port pos . whence)
    1136     (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)))
    1140       (##sys#check-exact pos 'set-file-position!)
    1141       (##sys#check-exact whence 'set-file-position!)
    1142       (when (fx< pos 0) (##sys#signal-hook #:bounds-error 'set-file-position! "invalid negative port position" pos port))
    1143       (unless (cond [(port? port)
    1144                      (and (eq? (##sys#slot port 7) 'stream)
    1145                           (##core#inline "C_fseek" port pos whence) ) ]
    1146                     [(fixnum? port) (##core#inline "C_lseek" port pos whence)]
    1147                     [else (##sys#signal-hook #:type-error 'set-file-position! "invalid file" port)] )
    1148         (##sys#update-errno)
    1149         (##sys#signal-hook #:file-error 'set-file-position! "cannot set file position" port pos) ) ) ) ) )
     1149   set-file-position!) )                ; doesn't accept WHENCE argument
    11501150
    11511151
  • chicken/trunk/support.scm

    r14533 r14779  
    3232  compiler-arguments process-command-line dump-nodes dump-undefined-globals
    3333  default-standard-bindings default-extended-bindings
    34   foldable-bindings compiler-macro-environment
     34  foldable-bindings compiler-macro-environment dump-defined-globals
    3535  installation-home optimization-iterations compiler-cleanup-hook decompose-lambda-list
    3636  file-io-only banner disabled-warnings internal-bindings
     
    809809     (when (and (assq 'global plist)
    810810                (not (assq 'assigned plist)) )
     811       (write sym)
     812       (newline) ) )
     813   db) )
     814
     815(define (dump-defined-globals db)
     816  (##sys#hash-table-for-each
     817   (lambda (sym plist)
     818     (when (and (assq 'global plist)
     819                (assq 'assigned plist))
    811820       (write sym)
    812821       (newline) ) )
Note: See TracChangeset for help on using the changeset viewer.