]> granicus.if.org Git - neomutt/commitdiff
Some fixes and code clean-ups.
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 22 Sep 1998 18:13:12 +0000 (18:13 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 22 Sep 1998 18:13:12 +0000 (18:13 +0000)
mh.c
mx.c

diff --git a/mh.c b/mh.c
index b8a90132ef1676a648e441c28c8d9c28dc22e4a2..f880a9d8387e0c2230922906cd43de5f09ca84d1 100644 (file)
--- a/mh.c
+++ b/mh.c
 #include <errno.h>
 #include <string.h>
 
+static void maildir_parse_flags(HEADER *h)
+{
+  char *p;
+
+  h->flagged = 0;
+  h->read = 0;
+  h->replied = 0;
+  
+  if ((p = strchr (h->path, ':')) != NULL && strncmp (p + 1, "2,", 2) == 0)
+  {
+    p += 3;
+    while (*p)
+    {
+      switch (*p)
+      {
+       case 'F':
+       
+       h->flagged = 1;
+       break;
+       
+       case 'S': /* seen */
+       
+       h->read = 1;
+       break;
+       
+       case 'R': /* replied */
+       
+       h->replied = 1;
+       break;
+      }
+      p++;
+    }
+  }
+}
+
+
 void mh_parse_message (CONTEXT *ctx,
                       const char *subdir,
                       const char *fname,
@@ -41,7 +77,6 @@ void mh_parse_message (CONTEXT *ctx,
                       int isOld)
 {
   char path[_POSIX_PATH_MAX];
-  char *p;
   FILE *f;
   HEADER *h;
   struct stat st;
@@ -95,34 +130,8 @@ void mh_parse_message (CONTEXT *ctx,
        */
 
       h->old = isOld;
-
-      if ((p = strchr (h->path, ':')) != NULL && strncmp (p + 1, "2,", 2) == 0)
-      {
-       p += 3;
-       while (*p)
-       {
-         switch (*p)
-         {
-           case 'F':
-
-             h->flagged = 1;
-             break;
-
-           case 'S': /* seen */
-
-             h->read = 1;
-             break;
-
-           case 'R': /* replied */
-
-             h->replied = 1;
-             break;
-         }
-         p++;
-       }
-      }
+      maildir_parse_flags(h);
     }
-
     /* set flags and update context info */
     mx_update_context (ctx);
   }
diff --git a/mx.c b/mx.c
index a0d70a37370db9cdfe04f484af9c92cc3e8bb799..3522a07a98331424865d8a6a6e0882660aa53388 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -1144,10 +1144,9 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
     Sort = old_sort;
   }
 
-  /* save the old headers */
-  old_msgcount = ctx->msgcount;
-  old_hdrs = ctx->hdrs;
-
+  old_hdrs = NULL;
+  old_msgcount = 0;
+  
   /* simulate a close */
   hash_destroy (&ctx->id_hash, NULL);
   hash_destroy (&ctx->subj_hash, NULL);
@@ -1156,10 +1155,15 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
   {
     for (i = 0; i < ctx->msgcount; i++)
       mutt_free_header (&(ctx->hdrs[i])); /* nothing to do! */
-      safe_free ((void **) &ctx->hdrs);
+    safe_free ((void **) &ctx->hdrs);
   }
   else
+  {
+      /* save the old headers */
+    old_msgcount = ctx->msgcount;
+    old_hdrs = ctx->hdrs;
     ctx->hdrs = NULL;
+  }
 
   ctx->hdrmax = 0;     /* force allocation of new headers */
   ctx->msgcount = 0;