|
@@ -126,27 +126,21 @@
|
126
|
126
|
(loop-file-until s (lambda (x) (declare (ignore x))) #'parse-line hash))
|
127
|
127
|
hash))
|
128
|
128
|
|
129
|
|
-(defun make-message-regex-test (regex)
|
130
|
|
- (lambda (string)
|
131
|
|
- (cl-ppcre:scan regex string)))
|
132
|
|
-
|
133
|
|
-(defun message-match (message pattern)
|
134
|
|
- (let* ((test-func (make-message-regex-test (gethash "regex" pattern)))
|
135
|
|
- (sb-impl::*default-external-format* :latin-1)
|
136
|
|
- (stream (mel:message-header-stream message))
|
137
|
|
- (test))
|
138
|
|
- (loop for line = (read-line stream nil 'eof) do
|
139
|
|
- (or (eq line 'eof) (setf test (funcall test-func line)))
|
140
|
|
- until (or (eq line 'eof) test))
|
|
129
|
+(defun message-match (stream pattern)
|
|
130
|
+ (let ((regex (gethash "regex" pattern))
|
|
131
|
+ (test))
|
|
132
|
+ (labels ((test-func (string) (cl-ppcre:scan regex string)))
|
|
133
|
+ (loop for line = (read-line stream nil 'eof) do
|
|
134
|
+ (or (eq line 'eof) (setf test (test-func line)))
|
|
135
|
+ until (or (eq line 'eof) test)))
|
141
|
136
|
test))
|
142
|
137
|
|
143
|
|
-(defun make-message-match (message)
|
144
|
|
- (lambda (pattern)
|
145
|
|
- (message-match message pattern)))
|
146
|
|
-
|
147
|
138
|
(defun handle-message (message patterns)
|
148
|
|
- (labels ((my-message-match (pattern) (message-match message pattern)))
|
149
|
|
- (find-if #'my-message-match patterns)))
|
|
139
|
+ (let* ((sb-impl::*default-external-format* :latin-1)
|
|
140
|
+ (stream (mel:message-header-stream message)))
|
|
141
|
+ (labels ((my-message-match (pattern) (message-match stream pattern)))
|
|
142
|
+ (find-if #'my-message-match patterns)
|
|
143
|
+ (close stream))))
|
150
|
144
|
|
151
|
145
|
(defun filter-maildir-folder (mailfilter)
|
152
|
146
|
(let* ((mailfilter-rules (read-mailfilter-file mailfilter))
|