X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=pattern.c;h=eb371fc2d1e7146b39ecd292c4e08d1faf7132de;hp=dec82b508ce3944c4d632a5ccc86e945ceb57526;hb=ebad7634114993e2e96fa66fda4b705d05832193;hpb=c8ceef3ed6424dcb5a6ec835e7d8d9cc00595372 diff --git a/pattern.c b/pattern.c index dec82b5..eb371fc 100644 --- a/pattern.c +++ b/pattern.c @@ -11,6 +11,8 @@ # include "config.h" #endif +#include + #include "mutt.h" #include "buffer.h" #include "handler.h" @@ -22,7 +24,6 @@ #include "copy.h" #include "mime.h" -#include "lib/mem.h" #include "lib/intl.h" #include "lib/str.h" @@ -101,7 +102,7 @@ struct pattern_flags { '=', M_DUPLICATED, 0, NULL}, { '$', M_UNREFERENCED, 0, NULL}, { '*', M_REALNAME, 0, NULL}, { - 0} + 0, 0, 0, NULL} }; static pattern_t *SearchPattern = NULL; /* current search pattern */ @@ -211,8 +212,7 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) } } - blen = STRING; - buf = mem_malloc (blen); + buf = p_new(char, blen = STRING); /* search the file "fp" */ while (lng > 0) { @@ -228,7 +228,7 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) lng -= str_len (buf); } - mem_free (&buf); + p_delete(&buf); mx_close_message (&msg); @@ -267,15 +267,15 @@ int eat_regexp (pattern_t * pat, BUFFER * s, BUFFER * err) if (pat->stringmatch) { pat->str = str_dup (buf.data); - mem_free (&buf.data); + p_delete(&buf.data); } else { - pat->rx = mem_malloc (sizeof (regex_t)); + pat->rx = p_new(regex_t, 1); r = REGCOMP (pat->rx, buf.data, REG_NEWLINE | REG_NOSUB | mutt_which_case (buf.data)); - mem_free (&buf.data); + p_delete(&buf.data); if (r) { regerror (r, pat->rx, err->data, err->dsize); regfree (pat->rx); - mem_free (&pat->rx); + p_delete(&pat->rx); return (-1); } } @@ -603,7 +603,7 @@ static int eat_date (pattern_t * pat, BUFFER * s, BUFFER * err) if (isdigit ((unsigned char) *pc)) { /* mininum date specified */ if ((pc = getDate (pc, &min, err)) == NULL) { - mem_free (&buffer.data); + p_delete(&buffer.data); return (-1); } haveMin = TRUE; @@ -636,7 +636,7 @@ static int eat_date (pattern_t * pat, BUFFER * s, BUFFER * err) max.tm_mday = min.tm_mday; if (!parse_date_range (pc, &min, &max, haveMin, &baseMin, err)) { /* bail out on any parsing error */ - mem_free (&buffer.data); + p_delete(&buffer.data); return (-1); } } @@ -648,7 +648,7 @@ static int eat_date (pattern_t * pat, BUFFER * s, BUFFER * err) pat->min = mutt_mktime (&min, 1); pat->max = mutt_mktime (&max, 1); - mem_free (&buffer.data); + p_delete(&buffer.data); return 0; } @@ -689,12 +689,12 @@ void mutt_pattern_free (pattern_t ** pat) if (tmp->rx) { regfree (tmp->rx); - mem_free (&tmp->rx); + p_delete(&tmp->rx); } - mem_free (&tmp->str); + p_delete(&tmp->str); if (tmp->child) mutt_pattern_free (&tmp->child); - mem_free (&tmp); + p_delete(&tmp); } } @@ -818,11 +818,11 @@ pattern_t *mutt_pattern_comp ( /* const */ char *s, int flags, BUFFER * err) /* compile the sub-expression */ buf = str_substrdup (ps.dptr + 1, p); if ((tmp = mutt_pattern_comp (buf, flags, err)) == NULL) { - mem_free (&buf); + p_delete(&buf); mutt_pattern_free (&curlist); return NULL; } - mem_free (&buf); + p_delete(&buf); if (last) last->next = tmp; else @@ -1204,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..."); @@ -1221,7 +1215,7 @@ int mutt_pattern_func (int op, char *prompt) err.data = error; err.dsize = sizeof (error); if ((pat = mutt_pattern_comp (buf, M_FULL_MSG, &err)) == NULL) { - mem_free (&simple); + p_delete(&simple); mutt_error ("%s", err.data); return (-1); } @@ -1286,7 +1280,7 @@ int mutt_pattern_func (int op, char *prompt) if (op == M_LIMIT) { /* drop previous limit pattern */ - mem_free (&Context->pattern); + p_delete(&Context->pattern); if (Context->limit_pattern) mutt_pattern_free (&Context->limit_pattern); if (Context->msgcount && !Context->vcount) { @@ -1300,7 +1294,7 @@ int mutt_pattern_func (int op, char *prompt) Context->limit_pattern = mutt_pattern_comp (buf, M_FULL_MSG, &err); } } - mem_free (&simple); + p_delete(&simple); mutt_pattern_free (&pat); return 0; }