Mercurial > emacs
changeset 48411:827133772385
(parse-time-elt): Var renamed from `elt'.
(parse-time-val): Var renamed from `val'. All uses changed.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 18 Nov 2002 04:58:53 +0000 |
parents | 4718d25e1500 |
children | 7fe609827b4c |
files | lisp/calendar/parse-time.el |
diffstat | 1 files changed, 43 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/calendar/parse-time.el Mon Nov 18 04:57:40 2002 +0000 +++ b/lisp/calendar/parse-time.el Mon Nov 18 04:58:53 2002 +0000 @@ -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 @@ (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 @@ (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)