* wl/wl-summary.el (wl-summary-mode): Check with fboundp before calling `make-local...
[elisp/wanderlust.git] / elmo / elmo-pop3.el
index 19d052b..aff5d75 100644 (file)
@@ -36,6 +36,7 @@
 (require 'elmo-map)
 
 (eval-when-compile
+  (require 'cl)
   (require 'elmo-util))
 
 (eval-and-compile
@@ -227,7 +228,8 @@ CODE is one of the following:
          (goto-char elmo-pop3-read-point))
        (setq match-end (point))
        (setq response-string
-             (buffer-substring elmo-pop3-read-point (- match-end 2)))
+             (buffer-substring elmo-pop3-read-point
+                               (max (- match-end 2) elmo-pop3-read-point)))
        (goto-char elmo-pop3-read-point)
        (if (looking-at "\\+.*$")
            (progn
@@ -299,7 +301,7 @@ CODE is one of the following:
     (car response)))
 
 (defun elmo-pop3-auth-apop (session)
-  (unless (string-match "^\+OK .*\\(<[^\>]+>\\)"
+  (unless (string-match "^\+OK .*\\(<[=!-;?-~]+@[=!-;?-~]+>\\)"
                        (elmo-network-session-greeting-internal session))
     (signal 'elmo-open-error '(elmo-pop3-auth-apop)))
   ;; good, APOP ready server
@@ -468,15 +470,15 @@ until the login delay period has expired"))
 (defun elmo-pop3-read-contents (process)
   (with-current-buffer (process-buffer process)
     (let ((case-fold-search nil)
-         match-end)
-      (goto-char elmo-pop3-read-point)
-      (while (not (re-search-forward "^\\.\r\n" nil t))
-       (accept-process-output process 1)
-       (goto-char elmo-pop3-read-point))
-      (setq match-end (point))
+         (point elmo-pop3-read-point))
+      (while (and (goto-char (- point 2))
+                 (not (search-forward "\r\n.\r\n" nil t)))
+       (setq point (max (- (point-max) 2) ; Care of \r\n.\r[EOF] case
+                        elmo-pop3-read-point))
+       (accept-process-output process 1))
       (elmo-delete-cr
        (buffer-substring elmo-pop3-read-point
-                        (- match-end 3))))))
+                        (- (point) 3))))))
 
 (luna-define-method elmo-folder-expand-msgdb-path ((folder elmo-pop3-folder))
   (convert-standard-filename
@@ -582,7 +584,7 @@ until the login delay period has expired"))
       (if elmo-pop3-list-done
          (progn
            (mapatoms (lambda (atom)
-                       (setq list (cons (string-to-int
+                       (setq list (cons (string-to-number
                                          (substring (symbol-name atom) 1))
                                         list)))
                      elmo-pop3-size-hash)
@@ -617,7 +619,7 @@ until the login delay period has expired"))
        (if (not (string-match "^\+OK[ \t]*\\([0-9]*\\)" response))
            (error "POP STAT command failed")
          (setq total
-               (string-to-int
+               (string-to-number
                 (substring response (match-beginning 1)(match-end 1 ))))
          (elmo-folder-close-internal folder)
          (cons total total))))))
@@ -638,8 +640,7 @@ until the login delay period has expired"))
     nil)))
 
 (defun elmo-pop3-retrieve-headers (process tobuffer articles)
-  (save-excursion
-    (set-buffer (process-buffer process))
+  (with-current-buffer (process-buffer process)
     (erase-buffer)
     (let ((count 0)
          (received 0)
@@ -651,7 +652,7 @@ until the login delay period has expired"))
          (elmo-pop3-send-command process
                                  (format "top %s 0" (car articles))
                                  'no-erase)
-         ;;;   (accept-process-output process 1)
+;;;      (accept-process-output process 1)
          (setq articles (cdr articles))
          (setq count (1+ count))
          ;; Every 200 requests we have to read the stream in
@@ -671,7 +672,7 @@ until the login delay period has expired"))
                     (< received count))
              (elmo-progress-notify 'elmo-retrieve-header :set received)
              (accept-process-output process 1)
-             ;;;           (accept-process-output process)
+;;;          (accept-process-output process)
              (discard-input)))))
       ;; Replace all CRLF with LF.
       (elmo-delete-cr-buffer)