Improved detection of new mail, there's always a newline at the end of
authorJoey Schulze <joey@infodrom.org>
Tue, 23 Nov 2004 09:06:49 +0000 (09:06 +0000)
committerJoey Schulze <joey@infodrom.org>
Tue, 23 Nov 2004 09:06:49 +0000 (09:06 +0000)
a mail.

mbox.c

diff --git a/mbox.c b/mbox.c
index 0e69ecd..15887f7 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -135,6 +135,7 @@ int inspect_mbox(char *path, char *prefix, off_t size, int opt_flags)
   char tmp[512];
   char *cp;
   int inheader = 1;
+  int readnewline = 0;
   int newmail = 0;
 
   char from_[HDR_LEN] = "";
@@ -200,10 +201,14 @@ int inspect_mbox(char *path, char *prefix, off_t size, int opt_flags)
        else if (strncasecmp(buf, "X-Priority: 1", 13) == 0 && buf[13] == '\0')
          priority = 1;
       }
-    } else if (strncasecmp(buf, "From ", 5) == 0) {
+    } else if (strlen(buf) == 0) {
+      readnewline = 1;
+    } else if (readnewline && strncasecmp(buf, "From ", 5) == 0) {
       inheader = 1;
+      readnewline = 0;
       stringcopy(from_, buf+5, sizeof(from_));
-    }
+    } else
+      readnewline = 0;
   }
 
   fclose(f);