AboutSummaryRefsLogTreeCommitDiffStats
path: root/vixie-specification.scm
diff options
context:
space:
mode:
authordale_mellor <dale_mellor>2006-04-16 22:10:43 +0000
committerdale_mellor <dale_mellor>2006-04-16 22:10:43 +0000
commit011df9b8fd152554619f76ea1e35a68ef206762d (patch)
tree2bee99d42aa1f0e984b0af546c6f92e7aaf8416f /vixie-specification.scm
parent4c3a7cc36c29ecbb8574454f0f5bdbed7ef66f8b (diff)
downloadmcron-011df9b8fd152554619f76ea1e35a68ef206762d.tar.gz
mcron-011df9b8fd152554619f76ea1e35a68ef206762d.tar.bz2
mcron-011df9b8fd152554619f76ea1e35a68ef206762d.zip
Update to 1.0.3. Lots of small changes, mainly to work with guile 1.8.0. Daylight savings time is now handled okay. Bug fix in Vixie parser. User gets option to correct bad crontab entries.1.0.3
Diffstat (limited to 'vixie-specification.scm')
-rw-r--r--vixie-specification.scm77
1 files changed, 47 insertions, 30 deletions
diff --git a/vixie-specification.scm b/vixie-specification.scm
index 08a8699..0bf4328 100644
--- a/vixie-specification.scm
+++ b/vixie-specification.scm
@@ -54,8 +54,8 @@
(define (parse-user-vixie-line line)
(let ((match (regexp-exec parse-user-vixie-line-regexp line)))
- (if (not match) (begin (display "Bad job line in Vixie file.\n")
- (primitive-exit 10)))
+ (if (not match)
+ (throw 'mcron-error 10 "Bad job line in Vixie file."))
(job (match:substring match 1)
(lambda () (with-mail-out (match:substring match 3)))
(match:substring match 3))))
@@ -71,8 +71,8 @@
(define (parse-system-vixie-line line)
(let ((match (regexp-exec parse-system-vixie-line-regexp line)))
- (if (not match) (begin (display "Bad job line in /etc/crontab.\n")
- (primitive-exit 11)))
+ (if (not match)
+ (throw 'mcron-error 11 "Bad job line in /etc/crontab."))
(let ((user (match:substring match 3)))
(set-configuration-user user)
(job (match:substring match 1)
@@ -92,7 +92,7 @@
"^[ \t]*([[:alpha:]_][[:alnum:]_]*)[ \t]*=[ \t]*\"(.*)\"[ \t]*$"))
(define parse-vixie-environment-regexp2
(make-regexp
- "^[ \t]*([[:alpha:]_][[:alnum:]_]*)[ \t]*=[ \t]*\'(.*)\'[ \t]*$"))
+ "^[ \t]*([[:alpha:]_][[:alnum:]_]*)[ \t]*=[ \t]*'(.*)'[ \t]*$"))
(define parse-vixie-environment-regexp3
(make-regexp
"^[ \t]*([[:alpha:]_][[:alnum:]_]*)[ \t]*=[ \t]*(.*[^ \t])[ \t]*$"))
@@ -136,26 +136,39 @@
(let ((parse-vixie-line
(if (null? parse-vixie-line) parse-user-vixie-line
(car parse-vixie-line))))
- (do ((line (read-line port) (read-line port)))
+ (do ((line (read-line port) (read-line port))
+ (line-number 1 (1+ line-number)))
((eof-object? line))
-
- ;; If the line ends with \, append the next line.
- (while (and (>= (string-length line) 1)
- (char=? (string-ref line
- (- (string-length line) 1))
- #\\))
- (let ((next-line (read-line port)))
- (if (eof-object? next-line)
- (set! next-line ""))
- (set! line
- (string-append
- (substring line 0 (- (string-length line) 1))
- next-line))))
-
- ;; Consider the three cases mentioned in the description.
- (or (regexp-exec read-vixie-file-comment-regexp line)
- (parse-vixie-environment line)
- (parse-vixie-line line))))))
+
+ (let ((report-line line-number))
+ ;; If the line ends with \, append the next line.
+ (while (and (>= (string-length line) 1)
+ (char=? (string-ref line
+ (- (string-length line) 1))
+ #\\))
+ (let ((next-line (read-line port)))
+ (if (eof-object? next-line)
+ (set! next-line ""))
+ (set! line-number (1+ line-number))
+ (set! line
+ (string-append
+ (substring line 0 (- (string-length line) 1))
+ next-line))))
+
+ (catch 'mcron-error
+ (lambda ()
+ ;; Consider the three cases mentioned in the description.
+ (or (regexp-exec read-vixie-file-comment-regexp line)
+ (parse-vixie-environment line)
+ (parse-vixie-line line)))
+ (lambda (key exit-code . msg)
+ (throw
+ 'mcron-error
+ exit-code
+ (apply string-append
+ (number->string report-line)
+ ": "
+ msg)))))))))
@@ -168,12 +181,16 @@
(catch #t (lambda () (set! port (open-input-file file-path)))
(lambda (key . args) (set! port #f)))
(if port
- (begin
- (if (null? parse-vixie-line)
- (read-vixie-port port)
- (read-vixie-port port (car parse-vixie-line)))
- (close port)))))
-
+ (catch 'mcron-error
+ (lambda ()
+ (if (null? parse-vixie-line)
+ (read-vixie-port port)
+ (read-vixie-port port (car parse-vixie-line)))
+ (close port))
+ (lambda (key exit-code . msg)
+ (close port)
+ (throw 'mcron-error exit-code
+ (apply string-append file-path ":" msg)))))))
;; A procedure which determines if the /etc/crontab file has been recently