From: Thomas Roessler Date: Tue, 22 Sep 1998 18:13:12 +0000 (+0000) Subject: Some fixes and code clean-ups. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80803f949aabcfc5a89823a9d99dcec861fbf6cf;p=neomutt Some fixes and code clean-ups. --- diff --git a/mh.c b/mh.c index b8a90132e..f880a9d83 100644 --- a/mh.c +++ b/mh.c @@ -34,6 +34,42 @@ #include #include +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 a0d70a373..3522a07a9 100644 --- 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;