~ubuntu-dev/ubuntu/lucid/mutt/lucid-201002110857

« back to all changes in this revision

Viewing changes to pattern.c

  • Committer: Bazaar Package Importer
  • Author(s): أحمد المحمودي (Ahmed El-Mahmoudy)
  • Date: 2009-06-17 17:17:28 UTC
  • mfrom: (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20090617171728-61dkl7w5fgn7ybdq
Tags: upstream-1.5.20
Import upstream version 1.5.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
  { 'z', M_SIZE,                0,              eat_range },
98
98
  { '=', M_DUPLICATED,          0,              NULL },
99
99
  { '$', M_UNREFERENCED,        0,              NULL },
100
 
  { 0 }
 
100
  { 0,   0,                     0,              NULL }
101
101
};
102
102
 
103
103
static pattern_t *SearchPattern = NULL; /* current search pattern */
182
182
          mx_close_message (&msg);
183
183
          if (s.fpout)
184
184
          {
185
 
            fclose (s.fpout);
 
185
            safe_fclose (&s.fpout);
186
186
            unlink (tempfile);
187
187
          }
188
188
          return (0);
242
242
 
243
243
    if (option (OPTTHOROUGHSRC))
244
244
    {
245
 
      fclose (fp);
 
245
      safe_fclose (&fp);
246
246
      unlink (tempfile);
247
247
    }
248
248
  }
277
277
  if (pat->stringmatch)
278
278
  {
279
279
    pat->p.str = safe_strdup (buf.data);
 
280
    pat->ign_case = mutt_which_case (buf.data) == REG_ICASE;
280
281
    FREE (&buf.data);
281
282
  }
282
283
  else if (pat->groupmatch)
700
701
static int patmatch (const pattern_t* pat, const char* buf)
701
702
{
702
703
  if (pat->stringmatch)
703
 
    return !strstr (buf, pat->p.str);
 
704
    return pat->ign_case ? !strcasestr (buf, pat->p.str) :
 
705
                           !strstr (buf, pat->p.str);
704
706
  else if (pat->groupmatch)
705
707
    return !mutt_group_match (pat->p.g, buf);
706
708
  else
1153
1155
    case M_SIZE:
1154
1156
      return (pat->not ^ (h->content->length >= pat->min && (pat->max == M_MAXRANGE || h->content->length <= pat->max)));
1155
1157
    case M_REFERENCE:
1156
 
      return (pat->not ^ match_reference (pat, h->env->references));
 
1158
      return (pat->not ^ (match_reference (pat, h->env->references) ||
 
1159
                          match_reference (pat, h->env->in_reply_to)));
1157
1160
    case M_ADDRESS:
1158
1161
      return (pat->not ^ match_adrlist (pat, flags & M_MATCH_FULL_ADDRESS, 4,
1159
1162
                                        h->env->from, h->env->sender,
1398
1401
  progress_t progress;
1399
1402
  const char* msg = NULL;
1400
1403
 
1401
 
  if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE)
 
1404
  if (!*LastSearch || (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE))
1402
1405
  {
1403
 
    strfcpy (buf, LastSearch, sizeof (buf));
1404
 
    if (mutt_get_field ((op == OP_SEARCH) ? _("Search for: ") :
1405
 
                      _("Reverse search for: "), buf, sizeof (buf),
 
1406
    strfcpy (buf, *LastSearch ? LastSearch : "", sizeof (buf));
 
1407
    if (mutt_get_field ((op == OP_SEARCH || op == OP_SEARCH_NEXT) ?
 
1408
                        _("Search for: ") : _("Reverse search for: "),
 
1409
                        buf, sizeof (buf),
1406
1410
                      M_CLEAR | M_PATTERN) != 0 || !buf[0])
1407
1411
      return (-1);
1408
1412
 
1409
 
    if (op == OP_SEARCH)
 
1413
    if (op == OP_SEARCH || op == OP_SEARCH_NEXT)
1410
1414
      unset_option (OPTSEARCHREVERSE);
1411
1415
    else
1412
1416
      set_option (OPTSEARCHREVERSE);
1417
1421
    mutt_check_simple (temp, sizeof (temp), NONULL (SimpleSearch));
1418
1422
 
1419
1423
    if (!SearchPattern || mutt_strcmp (temp, LastSearchExpn))
1420
 
    {
 
1424
     {
1421
1425
      set_option (OPTSEARCHINVALID);
1422
1426
      strfcpy (LastSearch, buf, sizeof (LastSearch));
1423
1427
      mutt_message _("Compiling search pattern...");
1425
1429
      err.data = error;
1426
1430
      err.dsize = sizeof (error);
1427
1431
      if ((SearchPattern = mutt_pattern_comp (temp, M_FULL_MSG, &err)) == NULL)
1428
 
      {
 
1432
       {
1429
1433
        mutt_error ("%s", error);
1430
1434
        return (-1);
1431
1435
      }
1432
1436
      mutt_clear_error ();
1433
1437
    }
1434
1438
  }
1435
 
  else if (!SearchPattern)
1436
 
  {
1437
 
    mutt_error _("No search pattern.");
1438
 
    return (-1);
1439
 
  }
1440
1439
 
1441
1440
  if (option (OPTSEARCHINVALID))
1442
1441
  {