SummaryRefsLogTreeCommitDiffStats
diff options
context:
space:
mode:
authorMathieu Lirzin <mthl@gnu.org>2018-04-01 21:44:28 +0200
committerMathieu Lirzin <mthl@gnu.org>2018-04-01 22:23:40 +0200
commitef452ce43b80959ab25b4a8bd90942c2ea1a9122 (patch)
tree0632599733eda8b341279a6a9f165030b6e1ba99
parentd8127a386c4474543c17d0641ed0fd2f1b21f97b (diff)
downloadmcron-ef452ce43b80959ab25b4a8bd90942c2ea1a9122.tar.gz
mcron-ef452ce43b80959ab25b4a8bd90942c2ea1a9122.tar.bz2
mcron-ef452ce43b80959ab25b4a8bd90942c2ea1a9122.zip
vixie-time: Adapt to '%find-best-next' possible infinite result
This is a follow up to commit ae6deb8ea23570c02a7b575a53bba37048aab59f. * src/mcron/vixie-time.scm (increment-time-component): Check if '%find-best-next' returns '+inf.0' not 9999.
-rw-r--r--src/mcron/vixie-time.scm23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/mcron/vixie-time.scm b/src/mcron/vixie-time.scm
index c4d6bd9..0a39e41 100644
--- a/src/mcron/vixie-time.scm
+++ b/src/mcron/vixie-time.scm
@@ -1,5 +1,6 @@
;;;; vixie-time.scm -- parse Vixie-style times
;;; Copyright © 2003 Dale Mellor <dale_mellor@users.sourceforge.net>
+;;; Copyright © 2018 Mathieu Lirzin <mthl@gnu.org>
;;;
;;; This file is part of GNU Mcron.
;;;
@@ -17,6 +18,7 @@
;;; along with GNU Mcron. If not, see <http://www.gnu.org/licenses/>.
(define-module (mcron vixie-time)
+ #:use-module (ice-9 match)
#:use-module (ice-9 regex)
#:use-module (mcron job-specifier)
#:use-module (srfi srfi-1)
@@ -176,16 +178,17 @@
;; simply unreadable without all of these aliases.
(define (increment-time-component time time-spec)
- (let* ((time-list (time-spec:list time-spec))
- (getter (time-spec:getter time-spec))
- (setter (time-spec:setter time-spec))
- (find-best-next (@@ (mcron job-specifier) %find-best-next))
- (next-best (find-best-next (getter time) time-list))
- (wrap-around (eqv? (cdr next-best) 9999)))
- (setter time ((if wrap-around car cdr) next-best))
- wrap-around))
-
-
+ (let ((time-list (time-spec:list time-spec))
+ (getter (time-spec:getter time-spec))
+ (setter (time-spec:setter time-spec))
+ (find-best-next (@@ (mcron job-specifier) %find-best-next)))
+ (match (find-best-next (getter time) time-list)
+ ((smallest . closest+)
+ (let ((infinite (inf? closest+)))
+ (if infinite
+ (setter time smallest)
+ (setter time closest+))
+ infinite)))))
;; There now follows a set of procedures for adjusting an element of time,
;; i.e. taking it to the next acceptable value. In each case, the head of the