<<< Date Index >>>     <<< Thread Index >>>

[PATCH] allow initial blank lines in local mailboxes



# HG changeset patch
# User David Champion <dgc@xxxxxxxxxxxx>
# Date 1286988263 18000
# Branch HEAD
# Node ID 95302d58ea75b010c99ed42b651e9d143b10e20e
# Parent  0b159a8327b751def2ad8f0a89957e2288fe2abb
allow initial blank lines in local mailboxes

Some mailbox-creation tools erroneously append a blank line to a file
before appending a UNIXv7-format mail message, resulting in mailboxes
that are intended to me valid "mbox" folders but are not.  Notably old
versions of Mailman do this, making archive files that cannot be read by
mutt.

This patch causes mutt to skip leading NLs and CRs when detecting magic.

diff -r 0b159a8327b7 -r 95302d58ea75 mx.c
--- a/mx.c      Tue May 04 22:52:32 2010 -0500
+++ b/mx.c      Wed Oct 13 11:44:23 2010 -0500
@@ -388,6 +388,11 @@
   else if ((f = fopen (path, "r")) != NULL)
   {
     struct utimbuf times;
+    int ch = 0;
+
+    while ((ch = fgetc(f)) && (ch == '\n' || ch == '\r'));
+    if (!feof(f) && ch)
+      ungetc(ch, f);
 
     fgets (tmp, sizeof (tmp), f);
     if (mutt_strncmp ("From ", tmp, 5) == 0)