- for (bp = body; bp != NULL; bp = bp->next) {
- /* Initial disposition is to count and not to recurse this part. */
- AT_COUNT("default");
- shallrecurse = 0;
-
- debug_print(5, ("bp: desc=\"%s\"; fn=\"%s\", type=\"%d/%s\"\n",
- bp->description ? bp->description : ("none"),
- bp->filename ? bp->filename :
- bp->d_filename ? bp->d_filename : "(none)",
- bp->type, bp->subtype ? bp->subtype : "*"));
-
- if (bp->type == TYPEMESSAGE) {
- shallrecurse = 1;
-
- /* If it's an external body pointer, don't recurse it. */
- if (mime_which_token(bp->subtype, -1) == MIME_EXTERNAL_BODY)
- shallrecurse = 0;
-
- /* Don't count containers if they're top-level. */
- if (flags & M_PARTS_TOPLEVEL)
- AT_NOCOUNT("top-level message/*");
- } else if (bp->type == TYPEMULTIPART) {
- /* Always recurse multiparts, except multipart/alternative. */
- shallrecurse = 1;
- if (mime_which_token(bp->subtype, -1) == MIME_ALTERNATIVE)
- shallrecurse = 0;
-
- /* Don't count containers if they're top-level. */
- if (flags & M_PARTS_TOPLEVEL)
- AT_NOCOUNT("top-level multipart");
- }
+ /* don't recurse in external bodies or multipart/alternatives */
+ shallrecurse = (bp->type == TYPEMESSAGE && tok != MIME_EXTERNAL_BODY)
+ || (bp->type == TYPEMULTIPART && tok != MIME_ALTERNATIVE);