Ignore:
Timestamp:
05/01/20 18:18:42 (13 months ago)
Author:
Kon Lovett
Message:

remove redundant -local, use -strict-types (#t is-a type? see -io zone-reader NOTE), isolate tm:ctm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/5/srfi-19/trunk/srfi-19-io.scm

    r38336 r38668  
    4040(import scheme)
    4141(import (chicken base))
     42(import (chicken type))
    4243#;(import srfi-6)
    4344(import (only (srfi 1) drop))
     
    425426(define (format-date dest fmt . r)
    426427  (let (
    427     (port #f)
     428    (port (the (or boolean output-port) #f))
    428429    (date (optional r #f)) )
    429430    (cond
     
    517518
    518519(define (zone-reader port)
    519   (let ((offset 0)
    520         (is-pos #t)
    521         (ch (read-char port)) )
     520  ;NOTE original is-pos & offset were in top let, w/ is-pos value set!, w/
     521  ;-strict-types the compiler assumed is-pos didn't change its' value from the
     522  ;initial #t!
     523  (define (optdec off fac)
     524    (let ((ch (read-char port)))
     525      (if (eof-object? ch)
     526        off
     527        (+ off (* (digit->int ch) fac)))) )
     528  (let ((ch (read-char port)))
    522529    (when (eof-object? ch)
    523       (error-bad-date-template 'string->date
    524        "invalid time zone +/-" 'eof-object))
     530      (error-bad-date-template 'string->date "invalid time zone +/-" 'eof-object))
    525531    (if (or (char=? ch #\Z) (char=? ch #\z))
    526532      0
    527       (begin
    528         (cond
    529           ((char=? ch #\+) (set! is-pos #t))
    530           ((char=? ch #\-) (set! is-pos #f))
    531           (else
    532             (error-bad-date-template 'string->date "invalid time zone +/-" ch)))
    533         (let ((ch (read-char port)))
    534           (when (eof-object? ch)
    535             (error-bad-date-template 'string->date
    536              "invalid time zone number" 'eof-object))
    537           (set! offset (* (digit->int ch) (* 10 SEC/HR))))
     533      (let* (
     534        (is-pos
     535          (cond
     536            ((char=? ch #\+) #t)
     537            ((char=? ch #\-) #f)
     538            (else
     539              (error-bad-date-template 'string->date "invalid time zone +/-" ch))))
     540        (offset
     541          (let ((ch (read-char port)))
     542            (when (eof-object? ch)
     543              (error-bad-date-template 'string->date "invalid time zone number" 'eof-object))
     544            (* (digit->int ch) (* 10 SEC/HR))))
    538545        ;non-existing values are considered zero
    539         (let ((ch (read-char port)))
    540           (unless (eof-object? ch)
    541             (set! offset (+ offset (* (digit->int ch) SEC/HR)))))
    542         (let ((ch (read-char port)))
    543           (unless (eof-object? ch)
    544             (set! offset (+ offset (* (digit->int ch) 600)))))
    545         (let ((ch (read-char port)))
    546           (unless (eof-object? ch)
    547             (set! offset (+ offset (* (digit->int ch) 60)))))
     546        (offset (optdec offset SEC/HR))
     547        (offset (optdec offset (* 10 SEC/MIN)))
     548        (offset (optdec offset SEC/MIN)) )
    548549        (if is-pos offset (- offset)))) ) )
    549550
Note: See TracChangeset for help on using the changeset viewer.