#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}, {
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;
}
/* 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;
}
}
if (pat->op == M_HEADER) {
if (*(buf = mutt_read_rfc822_line (fp, buf, &blen)) == '\0')
break;
- } if (fgets (buf, blen - 1, fp) == NULL)
+ } else if (fgets (buf, blen - 1, fp) == NULL)
break; /* don't loop forever */
if (patmatch (pat, buf) == 0) {
match = 1;
int r;
memset (&buf, 0, sizeof (buf));
+
if (mutt_extract_token (&buf, s, M_TOKEN_PATTERN | M_TOKEN_COMMENT) != 0 ||
!buf.data) {
snprintf (err->data, err->dsize, _("Error in expression: %s"), s->dptr);
return (-1);
}
+ if (!*buf.data) {
+ snprintf (err->data, err->dsize, _("Empty expression"));
+ return (-1);
+ }
+
#if 0
/* If there are no RE metacharacters, use simple search anyway */
if (!pat->stringmatch && !strpbrk (buf.data, "|[{.*+?^$"))
pattern_t *last = NULL;
int not = 0;
int alladdr = 0;
- int stringmatch = 0;
int or = 0;
int implicit = 1; /* used to detect logical AND operator */
struct pattern_flags *entry;
implicit = 0;
not = 0;
alladdr = 0;
- stringmatch = 0;
break;
case '=':
- stringmatch = 1;
/* fallthrough */
case '~':
if (implicit && or) {
tmp = new_pattern ();
tmp->not = not;
tmp->alladdr = alladdr;
- tmp->stringmatch = stringmatch;
+ tmp->stringmatch = (*ps.dptr == '=') ? 1 : 0;
not = 0;
alladdr = 0;
- stringmatch = 0;
if (last)
last->next = tmp;
case M_WHOLE_MSG:
#ifdef USE_IMAP
/* IMAP search sets h->matched at search compile time */
- if (Context->magic == M_IMAP && pat->stringmatch)
+ if (ctx->magic == M_IMAP && pat->stringmatch)
return (h->matched);
#endif
return (pat->not ^ msg_search (ctx, pat, h->msgno));
&& 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:
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)
+ if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
return (-1);
- if (!buf[0]) {
- if (op == M_LIMIT)
- strncpy (buf, "~A", sizeof (buf));
- else
- return (-1);
- }
mutt_message _("Compiling search pattern...");