X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=pattern.c;h=c30a381aaee8c14d787239ff0677ae99eba9a768;hp=63abd4e605927bae11dd8b81560d0bfb277f2740;hb=b0a700a4558d9bb59395ddcf08565a5e709841e1;hpb=b17296ba049d71986028ac83f0b415a021d0691c diff --git a/pattern.c b/pattern.c index 63abd4e..c30a381 100644 --- a/pattern.c +++ b/pattern.c @@ -95,6 +95,7 @@ struct pattern_flags { #endif { 'x', M_REFERENCE, 0, eat_regexp}, { + 'X', M_MIMEATTACH, 0, eat_range}, { 'y', M_XLABEL, 0, eat_regexp}, { 'z', M_SIZE, 0, eat_range}, { '=', M_DUPLICATED, 0, NULL}, { @@ -186,13 +187,13 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) return (0); } - fseek (msg->fp, h->offset, 0); + fseeko (msg->fp, h->offset, 0); mutt_body_handler (h->content, &s); } fp = s.fpout; fflush (fp); - fseek (fp, 0, 0); + fseeko (fp, 0, 0); fstat (fileno (fp), &st); lng = (long) st.st_size; } @@ -200,12 +201,12 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) /* raw header / body */ fp = msg->fp; if (pat->op != M_BODY) { - fseek (fp, h->offset, 0); + fseeko (fp, h->offset, 0); lng = h->content->offset - h->offset; } if (pat->op != M_HEADER) { if (pat->op == M_BODY) - fseek (fp, h->content->offset, 0); + fseeko (fp, h->content->offset, 0); lng += h->content->length; } } @@ -1094,6 +1095,23 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, && patmatch (pat, h->env->spam->data) == 0)); case M_DUPLICATED: 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); + } + + return (pat->not ^ (count >= pat->min && (pat->max == M_MAXRANGE || + count <= pat->max))); + } + case M_UNREFERENCED: return (pat->not ^ (h->thread && !h->thread->child)); case M_MULTIPART: @@ -1186,14 +1204,8 @@ int mutt_pattern_func (int op, char *prompt) strfcpy (buf, NONULL (Context->pattern), sizeof (buf)); if (prompt || op != M_LIMIT) - if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0) - return (-1); - if (!buf[0]) { - if (op == M_LIMIT) - strncpy (buf, "~A", sizeof (buf)); - else + if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0]) return (-1); - } mutt_message _("Compiling search pattern...");