X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=pattern.c;h=35cdbd91f3e8bf419483f01c37e13dee8d1561e2;hp=a02e96ea239243aca2a284d1c9c0fdec8d7487ac;hb=63b91e68a864bbd052b4b421cb77a0fd2a748ea4;hpb=238b70e39b78f585c586bd51aef41988b3cc73d1 diff --git a/pattern.c b/pattern.c index a02e96e..35cdbd9 100644 --- a/pattern.c +++ b/pattern.c @@ -17,21 +17,18 @@ #include #include #include +#include + +#include #include "mutt.h" #include "handler.h" #include "enter.h" #include "mx.h" -#include "mapping.h" #include "keymap.h" #include "copy.h" -#include "mime.h" - -#ifdef USE_IMAP -#include "mx.h" -#include "imap/imap.h" -#endif +#include #include #include @@ -40,7 +37,7 @@ #include #include -#include "mutt_crypt.h" +#include static int eat_regexp (pattern_t * pat, BUFFER *, BUFFER *); static int eat_date (pattern_t * pat, BUFFER *, BUFFER *); @@ -159,7 +156,7 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) int match = 0; HEADER *h = ctx->hdrs[msgno]; char* buf; - size_t blen; + ssize_t blen; if ((msg = mx_open_message (ctx, msgno)) != NULL) { if (option (OPTTHOROUGHSRC)) { @@ -179,8 +176,8 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) if (pat->op != M_HEADER) { mutt_parse_mime_message (ctx, h); - if (WithCrypto && (h->security & ENCRYPT) - && !crypt_valid_passphrase (h->security)) { + if ((h->security & ENCRYPT) && !crypt_valid_passphrase (h->security)) + { mx_close_message (&msg); if (fp) { fclose (fp); @@ -218,7 +215,7 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) /* search the file "fp" */ while (lng > 0) { if (pat->op == M_HEADER) { - if (*(buf = mutt_read_rfc822_line (fp, buf, &blen)) == '\0') + if (!mutt_read_rfc822_line(fp, &buf, &blen)) break; } else if (fgets (buf, blen - 1, fp) == NULL) break; /* don't loop forever */ @@ -290,7 +287,7 @@ static int patmatch (const pattern_t* pat, const char* buf) { return regexec (pat->rx, buf, 0, NULL, 0); } -int eat_range (pattern_t * pat, BUFFER * s, BUFFER * err) +int eat_range (pattern_t * pat, BUFFER * s, BUFFER * err __attribute__ ((unused))) { char *tmp; int do_exclusive = 0; @@ -359,8 +356,7 @@ int eat_range (pattern_t * pat, BUFFER * s, BUFFER * err) if (skip_quote && *tmp == '"') tmp++; - SKIPWS (tmp); - s->dptr = tmp; + s->dptr = vskipspaces(tmp); return 0; } @@ -468,7 +464,7 @@ static const char *parse_date_range (const char *pc, struct tm *min, const char *pt; char ch = *pc++; - SKIPWS (pc); + pc = vskipspaces(pc); switch (ch) { case '-': { @@ -524,7 +520,7 @@ static const char *parse_date_range (const char *pc, struct tm *min, default: flag |= M_PDR_ERRORDONE; } - SKIPWS (pc); + pc = vskipspaces(pc); } if ((flag & M_PDR_ERROR) && !(flag & M_PDR_ABSOLUTE)) { /* getDate has its own error message, don't overwrite it here */ snprintf (err->data, err->dsize, _("Invalid relative date: %s"), pc - 1); @@ -608,11 +604,11 @@ static int eat_date (pattern_t * pat, BUFFER * s, BUFFER * err) return (-1); } haveMin = TRUE; - SKIPWS (pc); + pc = vskipspaces(pc); if (*pc == '-') { - const char *pt = pc + 1; + const char *pt; - SKIPWS (pt); + pt = skipspaces(pc + 1); untilNow = (*pt == '\0'); } } @@ -718,7 +714,7 @@ pattern_t *mutt_pattern_comp ( /* const */ char *s, int flags, BUFFER * err) ps.dsize = m_strlen(s); while (*ps.dptr) { - SKIPWS (ps.dptr); + ps.dptr = vskipspaces(ps.dptr); switch (*ps.dptr) { case '^': ps.dptr++; @@ -792,8 +788,7 @@ pattern_t *mutt_pattern_comp ( /* const */ char *s, int flags, BUFFER * err) } tmp->op = entry->op; - ps.dptr++; /* eat the operator and any optional whitespace */ - SKIPWS (ps.dptr); + ps.dptr = vskipspaces(ps.dptr + 1); if (entry->eat_arg) { if (!*ps.dptr) { @@ -817,7 +812,7 @@ pattern_t *mutt_pattern_comp ( /* const */ char *s, int flags, BUFFER * err) return NULL; } /* compile the sub-expression */ - buf = str_substrdup (ps.dptr + 1, p); + buf = p_dupstr(ps.dptr + 1, p - ps.dptr - 1); if ((tmp = mutt_pattern_comp (buf, flags, err)) == NULL) { p_delete(&buf); mutt_pattern_free (&curlist); @@ -874,15 +869,15 @@ perform_or (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT * ctx, return 0; } -static int match_adrlist (pattern_t* pat, int match_personal, int alladdr, +static int match_adrlist (pattern_t* pat, int match_personal, int alladdr __attribute__ ((unused)), int n, ...) { va_list ap; - ADDRESS *a; + address_t *a; va_start (ap, n); for (; n; n--) { - for (a = va_arg (ap, ADDRESS *); a; a = a->next) { + for (a = va_arg (ap, address_t *); a; a = a->next) { if (pat->alladdr ^ ((a->mailbox && patmatch (pat, a->mailbox) == 0) || (match_personal && a->personal && @@ -904,7 +899,7 @@ static int match_reference (pattern_t* pat, LIST * refs) return 0; } -int mutt_is_list_recipient (int alladdr, ADDRESS * a1, ADDRESS * a2) +int mutt_is_list_recipient (int alladdr, address_t * a1, address_t * a2) { for (; a1; a1 = a1->next) if (alladdr ^ mutt_is_subscribed_list (a1)) @@ -915,7 +910,7 @@ int mutt_is_list_recipient (int alladdr, ADDRESS * a1, ADDRESS * a2) return alladdr; } -int mutt_is_list_cc (int alladdr, ADDRESS * a1, ADDRESS * a2) +int mutt_is_list_cc (int alladdr, address_t * a1, address_t * a2) { for (; a1; a1 = a1->next) if (alladdr ^ mutt_is_mail_list (a1)) @@ -926,7 +921,7 @@ int mutt_is_list_cc (int alladdr, ADDRESS * a1, ADDRESS * a2) return alladdr; } -static int match_user (int alladdr, ADDRESS * a1, ADDRESS * a2) +static int match_user (int alladdr, address_t * a1, address_t * a2) { for (; a1; a1 = a1->next) if (alladdr ^ mutt_addr_is_user (a1)) @@ -1001,11 +996,9 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, case M_BODY: case M_HEADER: case M_WHOLE_MSG: -#ifdef USE_IMAP /* IMAP search sets h->matched at search compile time */ if (ctx->magic == M_IMAP && pat->stringmatch) return (h->matched); -#endif return (pat->not ^ msg_search (ctx, pat, h->msgno)); case M_SENDER: return (pat->not ^ match_adrlist (pat, flags & M_MATCH_FULL_ADDRESS, @@ -1070,20 +1063,12 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, case M_COLLAPSED: return (pat->not ^ (h->collapsed && h->num_hidden > 1)); case M_CRYPT_SIGN: - if (!WithCrypto) - break; return (pat->not ^ ((h->security & SIGN) ? 1 : 0)); case M_CRYPT_VERIFIED: - if (!WithCrypto) - break; return (pat->not ^ ((h->security & GOODSIGN) ? 1 : 0)); case M_CRYPT_ENCRYPT: - if (!WithCrypto) - break; return (pat->not ^ ((h->security & ENCRYPT) ? 1 : 0)); case M_PGP_KEY: - if (!(WithCrypto & APPLICATION_PGP)) - break; return (pat->not ^ ((h->security & APPLICATION_PGP) && (h->security & PGPKEY))); case M_XLABEL: @@ -1146,9 +1131,9 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, return (-1); } -static void quote_simple (char *tmp, size_t len, const char *p) +static void quote_simple (char *tmp, ssize_t len, const char *p) { - int i = 0; + ssize_t i = 0; tmp[i++] = '"'; while (*p && i < len - 3) { @@ -1221,10 +1206,8 @@ int mutt_pattern_func (int op, char *prompt) return (-1); } -#ifdef USE_IMAP if (Context->magic == M_IMAP && imap_search (Context, pat) < 0) return -1; -#endif mutt_message _("Executing command on matching messages..."); @@ -1352,10 +1335,8 @@ int mutt_search_command (int cur, int op) if (option (OPTSEARCHINVALID)) { for (i = 0; i < Context->msgcount; i++) Context->hdrs[i]->searched = 0; -#ifdef USE_IMAP if (Context->magic == M_IMAP && imap_search (Context, SearchPattern) < 0) return -1; -#endif unset_option (OPTSEARCHINVALID); }