X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/44c01adf506b1087bff724dcb65b92a12b012836..84b9ea1689a8189d41ea4a821a1fd6cc446b9332:/pattern.c diff --git a/pattern.c b/pattern.c index 489a1d0..dbd73bd 100644 --- a/pattern.c +++ b/pattern.c @@ -35,6 +35,7 @@ #include "mutt_crypt.h" #include "mutt_curses.h" +#include "group.h" #ifdef USE_IMAP #include "mx.h" @@ -162,7 +163,7 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) memset (&s, 0, sizeof (s)); s.fpin = msg->fp; s.flags = M_CHARCONV; - mutt_mktemp (tempfile); + mutt_mktemp (tempfile, sizeof (tempfile)); if ((s.fpout = safe_fopen (tempfile, "w+")) == NULL) { mutt_perror (tempfile); @@ -253,6 +254,7 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno) static int eat_regexp (pattern_t *pat, BUFFER *s, BUFFER *err) { BUFFER buf; + char errmsg[STRING]; int r; memset (&buf, 0, sizeof (buf)); @@ -289,14 +291,15 @@ static int eat_regexp (pattern_t *pat, BUFFER *s, BUFFER *err) { pat->p.rx = safe_malloc (sizeof (regex_t)); r = REGCOMP (pat->p.rx, buf.data, REG_NEWLINE | REG_NOSUB | mutt_which_case (buf.data)); - FREE (&buf.data); if (r) { - regerror (r, pat->p.rx, err->data, err->dsize); - regfree (pat->p.rx); + regerror (r, pat->p.rx, errmsg, sizeof (errmsg)); + mutt_buffer_printf (err, "'%s': %s", buf.data, errmsg); + FREE (&buf.data); FREE (&pat->p.rx); return (-1); } + FREE (&buf.data); } return 0; @@ -822,7 +825,13 @@ pattern_t *mutt_pattern_comp (/* const */ char *s, int flags, BUFFER *err) case '%': case '=': case '~': - if (*(ps.dptr + 1) == '(') + if (!*(ps.dptr + 1)) + { + snprintf (err->data, err->dsize, _("missing pattern: %s"), ps.dptr); + mutt_pattern_free (&curlist); + return NULL; + } + if (*(ps.dptr + 1) == '(') { ps.dptr ++; /* skip ~ */ p = find_matching_paren (ps.dptr + 1); @@ -1293,6 +1302,7 @@ int mutt_pattern_func (int op, char *prompt) simple = safe_strdup (buf); mutt_check_simple (buf, sizeof (buf), NONULL (SimpleSearch)); + memset (&err, 0, sizeof(err)); err.data = error; err.dsize = sizeof (error); if ((pat = mutt_pattern_comp (buf, M_FULL_MSG, &err)) == NULL) @@ -1395,7 +1405,6 @@ int mutt_search_command (int cur, int op) char buf[STRING]; char temp[LONG_STRING]; char error[STRING]; - BUFFER err; int incr; HEADER *h; progress_t progress; @@ -1421,7 +1430,9 @@ int mutt_search_command (int cur, int op) mutt_check_simple (temp, sizeof (temp), NONULL (SimpleSearch)); if (!SearchPattern || mutt_strcmp (temp, LastSearchExpn)) - { + { + BUFFER err; + memset(&err, 0, sizeof(err)); set_option (OPTSEARCHINVALID); strfcpy (LastSearch, buf, sizeof (LastSearch)); mutt_message _("Compiling search pattern..."); @@ -1429,8 +1440,9 @@ int mutt_search_command (int cur, int op) err.data = error; err.dsize = sizeof (error); if ((SearchPattern = mutt_pattern_comp (temp, M_FULL_MSG, &err)) == NULL) - { + { mutt_error ("%s", error); + LastSearch[0] = '\0'; return (-1); } mutt_clear_error ();