(nnheader-insert-head): Make it work even if the file
authorKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 27 Jul 2006 09:27:45 +0000 (09:27 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 27 Jul 2006 09:27:45 +0000 (09:27 +0000)
 uses CRLF for the line-break code.

lisp/ChangeLog
lisp/nnheader.el

index 7de7934..0c498ce 100644 (file)
@@ -1,3 +1,8 @@
+2006-07-27  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * nnheader.el (nnheader-insert-head): Make it work even if the file
+       uses CRLF for the line-break code.
+
 2006-07-25  Daiki Ueno  <ueno@unixuser.org>
 
        * mml2015.el: Require mml-sec instead of password.
index dc1f090..31601c8 100644 (file)
@@ -597,17 +597,27 @@ the line could be found."
     (if (eq nnheader-max-head-length t)
        ;; Just read the entire file.
        (nnheader-insert-file-contents file)
-      ;; Read 1K blocks until we find a separator.
+      ;; Read blocks of the size specified by `nnheader-head-chop-length'
+      ;; until we find a separator.
       (let ((beg 0)
-           format-alist)
+           (start (point))
+           ;; Use `binary' to prevent the contents from being decoded,
+           ;; or it will change the number of characters that
+           ;; `insert-file-contents' returns.
+           (coding-system-for-read 'binary))
        (while (and (eq nnheader-head-chop-length
-                       (nth 1 (nnheader-insert-file-contents
+                       (nth 1 (mm-insert-file-contents
                                file nil beg
                                (incf beg nnheader-head-chop-length))))
-                   (prog1 (not (search-forward "\n\n" nil t))
+                   ;; CRLF might be used for the line-break code.
+                   (prog1 (not (re-search-forward "\n\r?\n" nil t))
                      (goto-char (point-max)))
                    (or (null nnheader-max-head-length)
-                       (< beg nnheader-max-head-length))))))
+                       (< beg nnheader-max-head-length))))
+       ;; Finally decode contents.
+       (when (mm-coding-system-p nnheader-file-coding-system)
+         (mm-decode-coding-region start (point-max)
+                                  nnheader-file-coding-system))))
     t))
 
 (defun nnheader-article-p ()