/*
- * Copyright (C) 1996-2000,2006 Michael R. Elkins <me@mutt.org>, and others
+ * Copyright (C) 1996-2000,2006-7 Michael R. Elkins <me@mutt.org>, and others
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
static int eat_range (pattern_t *pat, BUFFER *, BUFFER *);
static int patmatch (const pattern_t *pat, const char *buf);
-struct pattern_flags
+static struct pattern_flags
{
int tag; /* character used to represent this op */
int op; /* operation to perform */
{ 'z', M_SIZE, 0, eat_range },
{ '=', M_DUPLICATED, 0, NULL },
{ '$', M_UNREFERENCED, 0, NULL },
- { 0 }
+ { 0, 0, 0, NULL }
};
static pattern_t *SearchPattern = NULL; /* current search pattern */
#define M_PDR_ERRORDONE (M_PDR_ERROR | M_PDR_DONE)
-int mutt_getvaluebychar (char ch, struct mapping_t *table)
-{
- int i;
-
- for (i = 0; table[i].name; i++)
- {
- if (ch == table[i].name[0])
- return table[i].value;
- }
-
- return (-1);
-}
-
/* if no uppercase letters are given, do a case-insensitive search */
int mutt_which_case (const char *s)
{
&& !crypt_valid_passphrase(h->security))
{
mx_close_message (&msg);
- if (fp)
+ if (s.fpout)
{
- fclose (fp);
+ safe_fclose (&s.fpout);
unlink (tempfile);
}
return (0);
if (option (OPTTHOROUGHSRC))
{
- fclose (fp);
+ safe_fclose (&fp);
unlink (tempfile);
}
}
return match;
}
-int eat_regexp (pattern_t *pat, BUFFER *s, BUFFER *err)
+static int eat_regexp (pattern_t *pat, BUFFER *s, BUFFER *err)
{
BUFFER buf;
int r;
if (pat->stringmatch)
{
pat->p.str = safe_strdup (buf.data);
+ pat->ign_case = mutt_which_case (buf.data) == REG_ICASE;
FREE (&buf.data);
}
else if (pat->groupmatch)
static int patmatch (const pattern_t* pat, const char* buf)
{
if (pat->stringmatch)
- return !strstr (buf, pat->p.str);
+ return pat->ign_case ? !strcasestr (buf, pat->p.str) :
+ !strstr (buf, pat->p.str);
else if (pat->groupmatch)
return !mutt_group_match (pat->p.g, buf);
else
case M_SIZE:
return (pat->not ^ (h->content->length >= pat->min && (pat->max == M_MAXRANGE || h->content->length <= pat->max)));
case M_REFERENCE:
- return (pat->not ^ match_reference (pat, h->env->references));
+ return (pat->not ^ (match_reference (pat, h->env->references) ||
+ match_reference (pat, h->env->in_reply_to)));
case M_ADDRESS:
return (pat->not ^ match_adrlist (pat, flags & M_MATCH_FULL_ADDRESS, 4,
h->env->from, h->env->sender,
progress_t progress;
const char* msg = NULL;
- if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE)
+ if (!*LastSearch || (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE))
{
- strfcpy (buf, LastSearch, sizeof (buf));
- if (mutt_get_field ((op == OP_SEARCH) ? _("Search for: ") :
- _("Reverse search for: "), buf, sizeof (buf),
+ strfcpy (buf, *LastSearch ? LastSearch : "", sizeof (buf));
+ if (mutt_get_field ((op == OP_SEARCH || op == OP_SEARCH_NEXT) ?
+ _("Search for: ") : _("Reverse search for: "),
+ buf, sizeof (buf),
M_CLEAR | M_PATTERN) != 0 || !buf[0])
return (-1);
- if (op == OP_SEARCH)
+ if (op == OP_SEARCH || op == OP_SEARCH_NEXT)
unset_option (OPTSEARCHREVERSE);
else
set_option (OPTSEARCHREVERSE);
mutt_check_simple (temp, sizeof (temp), NONULL (SimpleSearch));
if (!SearchPattern || mutt_strcmp (temp, LastSearchExpn))
- {
+ {
set_option (OPTSEARCHINVALID);
strfcpy (LastSearch, buf, sizeof (LastSearch));
mutt_message _("Compiling search pattern...");
err.data = error;
err.dsize = sizeof (error);
if ((SearchPattern = mutt_pattern_comp (temp, M_FULL_MSG, &err)) == NULL)
- {
+ {
mutt_error ("%s", error);
return (-1);
}
mutt_clear_error ();
}
}
- else if (!SearchPattern)
- {
- mutt_error _("No search pattern.");
- return (-1);
- }
if (option (OPTSEARCHINVALID))
{