Re: smtp-end-of-line for SMTP over SSL

Hiroya Murata <[email protected]> Wed, 15 Feb 2006 16:47:05 +0900
Newsgroups gmane.mail.wanderlust.general.japanese,gmane.mail.emacs.mime.japanese
Message-ID <uwtfxf4hy.wl%[email protected]>
In the message [Wanderlust : No.13900]
   on Wed, 15 Feb 2006 13:10:06 +0900, Hiroya Murata wrote:

> このパッチで問題がなければ, flim-1_14 に commit しますが, 宜しいで
> しょうか?

decoder が指定されていた場合の処理が, 駄目々々だったので, 差し替え
て下さい.

-- 
Hiroya Murata (村田 浩也) <[email protected]>
PGP fingerprint: 53B6 1B4A 8193 A2D4 1526  BC9E 9AEF 2F6D 249D 5F17
smtp.el.patch (application/octet-stream, 1.9 KB)
Index: smtp.el
===================================================================
RCS file: /cvs/root/flim/smtp.el,v
retrieving revision 1.5.2.22
diff -u -w -r1.5.2.22 smtp.el
--- smtp.el	25 Jul 2005 01:51:09 -0000	1.5.2.22
+++ smtp.el	15 Feb 2006 07:41:17 -0000
@@ -653,26 +653,31 @@
 	response)
     (while response-continue
       (goto-char smtp-read-point)
-      (while (not (search-forward smtp-end-of-line nil t))
+      (while (not (re-search-forward "\r?\n" nil t))
 	(unless (smtp-connection-opened connection)
 	  (signal 'smtp-error "Connection closed"))
 	(accept-process-output (smtp-connection-process-internal connection))
 	(goto-char smtp-read-point))
-      (if decoder
-	  (let ((string (buffer-substring smtp-read-point (- (point) 2))))
-	    (delete-region smtp-read-point (point))
-	    (insert (funcall decoder string) smtp-end-of-line)))
+      (let ((bol smtp-read-point)
+	    (eol (match-beginning 0))
+	    (reply-code nil))
+	(when decoder
+	  (let ((string (buffer-substring bol eol)))
+	    (delete-region bol (point))
+	    (insert (funcall decoder string))
+	    (setq eol (point))
+	    (insert smtp-end-of-line)))
+	(setq smtp-read-point (point))
+	(goto-char bol)
+	(when (looking-at "[1-5][0-9][0-9]\\([ -]\\)")
+	  (when (string= (match-string 1) " ")
+	    (setq reply-code (read (point-marker))))
       (setq response
 	    (nconc response
-		   (list (buffer-substring
-			  (+ 4 smtp-read-point)
-			  (- (point) 2)))))
-      (goto-char
-       (prog1 smtp-read-point
-	 (setq smtp-read-point (point))))
-      (if (looking-at "[1-5][0-9][0-9] ")
-	  (setq response (cons (read (point-marker)) response)
-		response-continue nil)))
+		       (list (buffer-substring (match-end 0) eol))))
+	  (when reply-code
+	    (setq response (cons reply-code response)
+		  response-continue nil)))))
     response))
 
 (defun smtp-send-command (connection command)