Commit 183ca06e authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(parse-time-elt): Var renamed from `elt'.

(parse-time-val): Var renamed from `val'.  All uses changed.
parent fecddd0d
......@@ -32,7 +32,7 @@
;; `parse-time-string' parses a time in a string and returns a list of 9
;; values, just like `decode-time', where unspecified elements in the
;; string are returned as nil. `encode-time' may be applied on these
;; valuse to obtain an internal time value.
;; values to obtain an internal time value.
;;; Code:
......@@ -42,8 +42,8 @@
(defvar parse-time-digits (make-vector 256 nil))
;; Byte-compiler warnings
(defvar elt)
(defvar val)
(defvar parse-time-elt)
(defvar parse-time-val)
(unless (aref parse-time-digits ?0)
(loop for i from ?0 to ?9
......@@ -132,43 +132,46 @@
((4) parse-time-months)
((5) (100 4038))
((2 1 0)
,#'(lambda () (and (stringp elt)
(= (length elt) 8)
(= (aref elt 2) ?:)
(= (aref elt 5) ?:)))
,#'(lambda () (and (stringp parse-time-elt)
(= (length parse-time-elt) 8)
(= (aref parse-time-elt 2) ?:)
(= (aref parse-time-elt 5) ?:)))
[0 2] [3 5] [6 8])
((8 7) parse-time-zoneinfo
,#'(lambda () (car val))
,#'(lambda () (cadr val)))
,#'(lambda () (car parse-time-val))
,#'(lambda () (cadr parse-time-val)))
((8)
,#'(lambda ()
(and (stringp elt)
(= 5 (length elt))
(or (= (aref elt 0) ?+) (= (aref elt 0) ?-))))
,#'(lambda () (* 60 (+ (parse-integer elt 3 5)
(* 60 (parse-integer elt 1 3)))
(if (= (aref elt 0) ?-) -1 1))))
(and (stringp parse-time-elt)
(= 5 (length parse-time-elt))
(or (= (aref parse-time-elt 0) ?+)
(= (aref parse-time-elt 0) ?-))))
,#'(lambda () (* 60 (+ (parse-integer parse-time-elt 3 5)
(* 60 (parse-integer parse-time-elt 1 3)))
(if (= (aref parse-time-elt 0) ?-) -1 1))))
((5 4 3)
,#'(lambda () (and (stringp elt)
(= (length elt) 10)
(= (aref elt 4) ?-)
(= (aref elt 7) ?-)))
,#'(lambda () (and (stringp parse-time-elt)
(= (length parse-time-elt) 10)
(= (aref parse-time-elt 4) ?-)
(= (aref parse-time-elt 7) ?-)))
[0 4] [5 7] [8 10])
((2 1 0)
,#'(lambda () (and (stringp elt) (= (length elt) 5) (= (aref elt 2) ?:)))
,#'(lambda () (and (stringp parse-time-elt)
(= (length parse-time-elt) 5)
(= (aref parse-time-elt 2) ?:)))
[0 2] [3 5] ,#'(lambda () 0))
((2 1 0)
,#'(lambda () (and (stringp elt)
(= (length elt) 4)
(= (aref elt 1) ?:)))
,#'(lambda () (and (stringp parse-time-elt)
(= (length parse-time-elt) 4)
(= (aref parse-time-elt 1) ?:)))
[0 1] [2 4] ,#'(lambda () 0))
((2 1 0)
,#'(lambda () (and (stringp elt)
(= (length elt) 7)
(= (aref elt 1) ?:)))
,#'(lambda () (and (stringp parse-time-elt)
(= (length parse-time-elt) 7)
(= (aref parse-time-elt 1) ?:)))
[0 1] [2 4] [5 7])
((5) (50 110) ,#'(lambda () (+ 1900 elt)))
((5) (0 49) ,#'(lambda () (+ 2000 elt))))
((5) (50 110) ,#'(lambda () (+ 1900 parse-time-elt)))
((5) (0 49) ,#'(lambda () (+ 2000 parse-time-elt))))
"(slots predicate extractor...)")
(defun parse-time-string (string)
......@@ -178,24 +181,24 @@ unknown are returned as nil."
(let ((time (list nil nil nil nil nil nil nil nil nil))
(temp (parse-time-tokenize (downcase string))))
(while temp
(let ((elt (pop temp))
(let ((parse-time-elt (pop temp))
(rules parse-time-rules)
(exit nil))
(while (and (not (null rules)) (not exit))
(let* ((rule (pop rules))
(slots (pop rule))
(predicate (pop rule))
(val))
(parse-time-val))
(when (and (not (nth (car slots) time)) ;not already set
(setq val (cond ((and (consp predicate)
(setq parse-time-val (cond ((and (consp predicate)
(not (eq (car predicate)
'lambda)))
(and (numberp elt)
(<= (car predicate) elt)
(<= elt (cadr predicate))
elt))
(and (numberp parse-time-elt)
(<= (car predicate) parse-time-elt)
(<= parse-time-elt (cadr predicate))
parse-time-elt))
((symbolp predicate)
(cdr (assoc elt
(cdr (assoc parse-time-elt
(symbol-value predicate))))
((funcall predicate)))))
(setq exit t)
......@@ -204,9 +207,11 @@ unknown are returned as nil."
(let ((this (pop rule)))
(if (vectorp this)
(parse-integer
elt (aref this 0) (aref this 1))
parse-time-elt
(aref this 0) (aref this 1))
(funcall this))))))
(rplaca (nthcdr (pop slots) time) (or new-val val)))))))))
(rplaca (nthcdr (pop slots) time)
(or new-val parse-time-val)))))))))
time))
(provide 'parse-time)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment