Patch by Marian ??urkovi??: Support header values longer than two lines
authorJoey Schulze <joey@infodrom.org>
Mon, 21 Apr 2008 14:31:39 +0000 (14:31 +0000)
committerJoey Schulze <joey@infodrom.org>
Mon, 21 Apr 2008 14:31:39 +0000 (14:31 +0000)
mbox.c

diff --git a/mbox.c b/mbox.c
index 5860abb..cb2e9f3 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -1,5 +1,5 @@
 /*
-    Copyright (c) 2004  Joey Schulze <joey@infodrom.org>
+    Copyright (c) 2004,8  Joey Schulze <joey@infodrom.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
 /* #define FROM_DETECTION */
 
+#define HDR_LEN        1024
+
 struct mail {
-  char from[128];
-  char subject[128];
+  char from[HDR_LEN];
+  char subject[HDR_LEN];
   int priority;
   off_t size;
 };
 
-#define HDR_LEN        1024
 #define TAB    0x09
 #define LWSP   0x20
 
@@ -182,8 +183,7 @@ int inspect_mbox(char *path, char *prefix, off_t size, int opt_flags)
        buf[strlen(buf)-1] = '\0';
 
       if (inheader && !feof(f)) {
-       lookahead = fgetc(f);
-       if (lookahead == TAB || lookahead == LWSP) {
+       while ((lookahead=fgetc(f)) == TAB || lookahead == LWSP) {
          if (buf[strlen(buf)-1] != LWSP)
            strncat (buf, " ", sizeof(buf)-strlen(buf)-1);
          if ((cp = fgets(tmp, sizeof(tmp), f)) != NULL) {
@@ -201,10 +201,10 @@ int inspect_mbox(char *path, char *prefix, off_t size, int opt_flags)
              }
            }
          }
-       } else
-         /* Rewind by one character for next read */
-         if (lookahead != EOF)
-           fseek(f, -1, SEEK_CUR);
+       }
+       /* Rewind by one character for next read */
+       if (lookahead != EOF)
+         fseek(f, -1, SEEK_CUR);
       }
     } else {
       /* Read the remainder */