diff options
| author | Richard M. Stallman | 2002-11-18 04:58:53 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-11-18 04:58:53 +0000 |
| commit | 183ca06edb64f1d5c59d23c581accb4ebefabac7 (patch) | |
| tree | fd698f7b2b498cb91bb5528c6e2665ec20482868 | |
| parent | fecddd0d1648a06234d675a7e4664ff9eb0003c4 (diff) | |
| download | emacs-183ca06edb64f1d5c59d23c581accb4ebefabac7.tar.gz emacs-183ca06edb64f1d5c59d23c581accb4ebefabac7.zip | |
(parse-time-elt): Var renamed from `elt'.
(parse-time-val): Var renamed from `val'. All uses changed.
| -rw-r--r-- | lisp/calendar/parse-time.el | 81 |
1 files changed, 43 insertions, 38 deletions
diff --git a/lisp/calendar/parse-time.el b/lisp/calendar/parse-time.el index bf593eb9d2b..7020e490b4b 100644 --- a/lisp/calendar/parse-time.el +++ b/lisp/calendar/parse-time.el | |||
| @@ -32,7 +32,7 @@ | |||
| 32 | ;; `parse-time-string' parses a time in a string and returns a list of 9 | 32 | ;; `parse-time-string' parses a time in a string and returns a list of 9 |
| 33 | ;; values, just like `decode-time', where unspecified elements in the | 33 | ;; values, just like `decode-time', where unspecified elements in the |
| 34 | ;; string are returned as nil. `encode-time' may be applied on these | 34 | ;; string are returned as nil. `encode-time' may be applied on these |
| 35 | ;; valuse to obtain an internal time value. | 35 | ;; values to obtain an internal time value. |
| 36 | 36 | ||
| 37 | ;;; Code: | 37 | ;;; Code: |
| 38 | 38 | ||
| @@ -42,8 +42,8 @@ | |||
| 42 | (defvar parse-time-digits (make-vector 256 nil)) | 42 | (defvar parse-time-digits (make-vector 256 nil)) |
| 43 | 43 | ||
| 44 | ;; Byte-compiler warnings | 44 | ;; Byte-compiler warnings |
| 45 | (defvar elt) | 45 | (defvar parse-time-elt) |
| 46 | (defvar val) | 46 | (defvar parse-time-val) |
| 47 | 47 | ||
| 48 | (unless (aref parse-time-digits ?0) | 48 | (unless (aref parse-time-digits ?0) |
| 49 | (loop for i from ?0 to ?9 | 49 | (loop for i from ?0 to ?9 |
| @@ -132,43 +132,46 @@ | |||
| 132 | ((4) parse-time-months) | 132 | ((4) parse-time-months) |
| 133 | ((5) (100 4038)) | 133 | ((5) (100 4038)) |
| 134 | ((2 1 0) | 134 | ((2 1 0) |
| 135 | ,#'(lambda () (and (stringp elt) | 135 | ,#'(lambda () (and (stringp parse-time-elt) |
| 136 | (= (length elt) 8) | 136 | (= (length parse-time-elt) 8) |
| 137 | (= (aref elt 2) ?:) | 137 | (= (aref parse-time-elt 2) ?:) |
| 138 | (= (aref elt 5) ?:))) | 138 | (= (aref parse-time-elt 5) ?:))) |
| 139 | [0 2] [3 5] [6 8]) | 139 | [0 2] [3 5] [6 8]) |
| 140 | ((8 7) parse-time-zoneinfo | 140 | ((8 7) parse-time-zoneinfo |
| 141 | ,#'(lambda () (car val)) | 141 | ,#'(lambda () (car parse-time-val)) |
| 142 | ,#'(lambda () (cadr val))) | 142 | ,#'(lambda () (cadr parse-time-val))) |
| 143 | ((8) | 143 | ((8) |
| 144 | ,#'(lambda () | 144 | ,#'(lambda () |
| 145 | (and (stringp elt) | 145 | (and (stringp parse-time-elt) |
| 146 | (= 5 (length elt)) | 146 | (= 5 (length parse-time-elt)) |
| 147 | (or (= (aref elt 0) ?+) (= (aref elt 0) ?-)))) | 147 | (or (= (aref parse-time-elt 0) ?+) |
| 148 | ,#'(lambda () (* 60 (+ (parse-integer elt 3 5) | 148 | (= (aref parse-time-elt 0) ?-)))) |
| 149 | (* 60 (parse-integer elt 1 3))) | 149 | ,#'(lambda () (* 60 (+ (parse-integer parse-time-elt 3 5) |
| 150 | (if (= (aref elt 0) ?-) -1 1)))) | 150 | (* 60 (parse-integer parse-time-elt 1 3))) |
| 151 | (if (= (aref parse-time-elt 0) ?-) -1 1)))) | ||
| 151 | ((5 4 3) | 152 | ((5 4 3) |
| 152 | ,#'(lambda () (and (stringp elt) | 153 | ,#'(lambda () (and (stringp parse-time-elt) |
| 153 | (= (length elt) 10) | 154 | (= (length parse-time-elt) 10) |
| 154 | (= (aref elt 4) ?-) | 155 | (= (aref parse-time-elt 4) ?-) |
| 155 | (= (aref elt 7) ?-))) | 156 | (= (aref parse-time-elt 7) ?-))) |
| 156 | [0 4] [5 7] [8 10]) | 157 | [0 4] [5 7] [8 10]) |
| 157 | ((2 1 0) | 158 | ((2 1 0) |
| 158 | ,#'(lambda () (and (stringp elt) (= (length elt) 5) (= (aref elt 2) ?:))) | 159 | ,#'(lambda () (and (stringp parse-time-elt) |
| 160 | (= (length parse-time-elt) 5) | ||
| 161 | (= (aref parse-time-elt 2) ?:))) | ||
| 159 | [0 2] [3 5] ,#'(lambda () 0)) | 162 | [0 2] [3 5] ,#'(lambda () 0)) |
| 160 | ((2 1 0) | 163 | ((2 1 0) |
| 161 | ,#'(lambda () (and (stringp elt) | 164 | ,#'(lambda () (and (stringp parse-time-elt) |
| 162 | (= (length elt) 4) | 165 | (= (length parse-time-elt) 4) |
| 163 | (= (aref elt 1) ?:))) | 166 | (= (aref parse-time-elt 1) ?:))) |
| 164 | [0 1] [2 4] ,#'(lambda () 0)) | 167 | [0 1] [2 4] ,#'(lambda () 0)) |
| 165 | ((2 1 0) | 168 | ((2 1 0) |
| 166 | ,#'(lambda () (and (stringp elt) | 169 | ,#'(lambda () (and (stringp parse-time-elt) |
| 167 | (= (length elt) 7) | 170 | (= (length parse-time-elt) 7) |
| 168 | (= (aref elt 1) ?:))) | 171 | (= (aref parse-time-elt 1) ?:))) |
| 169 | [0 1] [2 4] [5 7]) | 172 | [0 1] [2 4] [5 7]) |
| 170 | ((5) (50 110) ,#'(lambda () (+ 1900 elt))) | 173 | ((5) (50 110) ,#'(lambda () (+ 1900 parse-time-elt))) |
| 171 | ((5) (0 49) ,#'(lambda () (+ 2000 elt)))) | 174 | ((5) (0 49) ,#'(lambda () (+ 2000 parse-time-elt)))) |
| 172 | "(slots predicate extractor...)") | 175 | "(slots predicate extractor...)") |
| 173 | 176 | ||
| 174 | (defun parse-time-string (string) | 177 | (defun parse-time-string (string) |
| @@ -178,24 +181,24 @@ unknown are returned as nil." | |||
| 178 | (let ((time (list nil nil nil nil nil nil nil nil nil)) | 181 | (let ((time (list nil nil nil nil nil nil nil nil nil)) |
| 179 | (temp (parse-time-tokenize (downcase string)))) | 182 | (temp (parse-time-tokenize (downcase string)))) |
| 180 | (while temp | 183 | (while temp |
| 181 | (let ((elt (pop temp)) | 184 | (let ((parse-time-elt (pop temp)) |
| 182 | (rules parse-time-rules) | 185 | (rules parse-time-rules) |
| 183 | (exit nil)) | 186 | (exit nil)) |
| 184 | (while (and (not (null rules)) (not exit)) | 187 | (while (and (not (null rules)) (not exit)) |
| 185 | (let* ((rule (pop rules)) | 188 | (let* ((rule (pop rules)) |
| 186 | (slots (pop rule)) | 189 | (slots (pop rule)) |
| 187 | (predicate (pop rule)) | 190 | (predicate (pop rule)) |
| 188 | (val)) | 191 | (parse-time-val)) |
| 189 | (when (and (not (nth (car slots) time)) ;not already set | 192 | (when (and (not (nth (car slots) time)) ;not already set |
| 190 | (setq val (cond ((and (consp predicate) | 193 | (setq parse-time-val (cond ((and (consp predicate) |
| 191 | (not (eq (car predicate) | 194 | (not (eq (car predicate) |
| 192 | 'lambda))) | 195 | 'lambda))) |
| 193 | (and (numberp elt) | 196 | (and (numberp parse-time-elt) |
| 194 | (<= (car predicate) elt) | 197 | (<= (car predicate) parse-time-elt) |
| 195 | (<= elt (cadr predicate)) | 198 | (<= parse-time-elt (cadr predicate)) |
| 196 | elt)) | 199 | parse-time-elt)) |
| 197 | ((symbolp predicate) | 200 | ((symbolp predicate) |
| 198 | (cdr (assoc elt | 201 | (cdr (assoc parse-time-elt |
| 199 | (symbol-value predicate)))) | 202 | (symbol-value predicate)))) |
| 200 | ((funcall predicate))))) | 203 | ((funcall predicate))))) |
| 201 | (setq exit t) | 204 | (setq exit t) |
| @@ -204,9 +207,11 @@ unknown are returned as nil." | |||
| 204 | (let ((this (pop rule))) | 207 | (let ((this (pop rule))) |
| 205 | (if (vectorp this) | 208 | (if (vectorp this) |
| 206 | (parse-integer | 209 | (parse-integer |
| 207 | elt (aref this 0) (aref this 1)) | 210 | parse-time-elt |
| 211 | (aref this 0) (aref this 1)) | ||
| 208 | (funcall this)))))) | 212 | (funcall this)))))) |
| 209 | (rplaca (nthcdr (pop slots) time) (or new-val val))))))))) | 213 | (rplaca (nthcdr (pop slots) time) |
| 214 | (or new-val parse-time-val))))))))) | ||
| 210 | time)) | 215 | time)) |
| 211 | 216 | ||
| 212 | (provide 'parse-time) | 217 | (provide 'parse-time) |