]> code.delx.au - gnu-emacs/blobdiff - lisp/calendar/parse-time.el
Doc string fix
[gnu-emacs] / lisp / calendar / parse-time.el
index b2b065ab65ec5b58898083b15d8af6ec8cabeea2..c17d04a8c10acadc68a94218920f86c0ab7e0ed0 100644 (file)
@@ -1,6 +1,6 @@
 ;;; parse-time.el --- parsing time strings
 
-;; Copyright (C) 1996, 2000-2015 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2000-2016 Free Software Foundation, Inc.
 
 ;; Author: Erik Naggum <erik@naggum.no>
 ;; Keywords: util
 (defvar parse-time-val)
 
 (defsubst parse-time-string-chars (char)
-  (save-match-data
-    (let (case-fold-search str)
-      (cond ((eq char ?+) 1)
-           ((eq char ?-) -1)
-           ((eq char ?:) ?d)
-           ((string-match "[[:upper:]]" (setq str (string char))) ?A)
-           ((string-match "[[:lower:]]" str) ?a)
-           ((string-match "[[:digit:]]" str) ?0)))))
+  (cond ((<= ?a char ?z) ?a)
+        ((<= ?0 char ?9) ?0)
+        ((eq char ?+) 1)
+        ((eq char ?-) -1)
+        ((eq char ?:) ?d)))
 
 (defun parse-time-tokenize (string)
-  "Tokenize STRING into substrings."
+  "Tokenize STRING into substrings.
+Each substring is a run of \"valid\" characters, i.e., lowercase
+letters, digits, plus or minus signs or colons."
   (let ((start nil)
        (end (length string))
        (all-digits nil)
@@ -62,7 +61,8 @@
       (while (and (< index end)                ;Skip invalid characters.
                  (not (setq c (parse-time-string-chars (aref string index)))))
        (cl-incf index))
-      (setq start index all-digits (eq c ?0))
+      (setq start index
+            all-digits (eq c ?0))
       (while (and (< (cl-incf index) end)      ;Scan valid characters.
                  (setq c (parse-time-string-chars (aref string index))))
        (setq all-digits (and all-digits (eq c ?0))))