>From fa2524bd41641d18bad51ca0a99986102d900568 Mon Sep 17 00:00:00 2001 From: Marcin Borkowski Date: Sat, 19 Mar 2016 08:05:17 +0100 Subject: [PATCH] Make the `parse-time-tokenize' more readable * lisp/calendar/parse-time.el (parse-time-string-chars) (parse-time-tokenize): Make code more readable --- lisp/calendar/parse-time.el | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lisp/calendar/parse-time.el b/lisp/calendar/parse-time.el index 6ba26a4..33e936c 100644 --- a/lisp/calendar/parse-time.el +++ b/lisp/calendar/parse-time.el @@ -40,15 +40,18 @@ (defvar parse-time-elt) (defvar parse-time-val) -(defsubst parse-time-string-chars (char) - (cond ((<= ?a char ?z) ?a) - ((<= ?0 char ?9) ?0) - ((eq char ?+) 1) - ((eq char ?-) -1) - ((eq char ?:) ?d))) +(defsubst parse-time-string-chars (character) + "Classify CHARACTER for `parse-time-tokenize'." + (cond ((<= ?a character ?z) ?a) + ((<= ?0 character ?9) ?0) + ((eq character ?+) 1) + ((eq character ?-) -1) + ((eq character ?:) ?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) @@ -57,9 +60,10 @@ parse-time-tokenize (c nil)) (while (< index end) (while (and (< index end) ;Skip invalid characters. - (not (setq c (parse-time-string-chars (aref string index))))) + (null (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)))) -- 2.4.3