worst aberrations, but the feature is still a performance hog.
case 'X':
{
- int count;
-
- if (hdr->content->parts)
- count = mutt_count_body_parts(hdr, 0);
- else
- {
- mutt_parse_mime_message(ctx, hdr);
- count = mutt_count_body_parts(hdr, 0);
- mutt_free_body(&hdr->content->parts);
- }
+ int count = mutt_count_body_parts (ctx, hdr);
/* The recursion allows messages without depth to return 0. */
if (optional)
regex_t minor_rx;
} ATTACH_MATCH;
-/* Flags for mutt_count_body_parts() */
#define M_PARTS_TOPLEVEL (1<<0) /* is the top-level part */
-#define M_PARTS_RECOUNT (1<<1) /* force recount */
#include "ascii.h"
#include "protos.h"
void mutt_parse_mime_message (CONTEXT *ctx, HEADER *cur)
{
MESSAGE *msg;
- int flags = 0;
do {
if (cur->content->type != TYPEMESSAGE &&
}
} while (0);
- mutt_count_body_parts(cur, flags|M_PARTS_RECOUNT);
+ cur->attach_valid = 0;
}
int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short user_hdrs, short weed,
return count < 0 ? 0 : count;
}
-int mutt_count_body_parts (HEADER *hdr, int flags)
+int mutt_count_body_parts (CONTEXT *ctx, HEADER *hdr)
{
- if (hdr->attach_valid && !(flags & M_PARTS_RECOUNT))
- return hdr->attach_total;
+ short keep_parts = 0;
+ if (hdr->attach_valid)
+ return hdr->attach_total;
+
+ if (hdr->content->parts)
+ keep_parts = 1;
+ else
+ mutt_parse_mime_message (ctx, hdr);
+
if (AttachAllow || AttachExclude || InlineAllow || InlineExclude)
- hdr->attach_total = count_body_parts(hdr->content, flags | M_PARTS_TOPLEVEL);
+ hdr->attach_total = count_body_parts(hdr->content, M_PARTS_TOPLEVEL);
else
hdr->attach_total = 0;
hdr->attach_valid = 1;
+
+ if (!keep_parts)
+ mutt_free_body (&hdr->content->parts);
+
return hdr->attach_total;
}
return (pat->not ^ (h->thread && h->thread->duplicate_thread));
case M_MIMEATTACH:
{
- int count;
-
- if (h->content->parts)
- count = mutt_count_body_parts(h, 0);
- else
- {
- mutt_parse_mime_message(ctx, h);
- count = mutt_count_body_parts(h, 0);
- mutt_free_body(&h->content->parts);
- }
-
+ int count = mutt_count_body_parts (ctx, h);
return (pat->not ^ (count >= pat->min && (pat->max == M_MAXRANGE ||
count <= pat->max)));
}
void mutt_buffy (char *, size_t);
int mutt_buffy_list (void);
void mutt_canonical_charset (char *, size_t, const char *);
-int mutt_count_body_parts (HEADER *hdr, int flags);
+int mutt_count_body_parts (CONTEXT *, HEADER *);
void mutt_check_rescore (CONTEXT *);
void mutt_clear_error (void);
void mutt_create_alias (ENVELOPE *, ADDRESS *);