X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=query.c;h=f7a7894facee1a661adb955e94bbf13386a26bfc;hp=9390bcf05b994793b94752c06d4ce3c26e30ab25;hb=9a1efcc01ddeca4106847f8eb28a704aca2dcf0b;hpb=0f44dc85fc1280372ffab911d701e703d803fb4b diff --git a/query.c b/query.c index 9390bcf..f7a7894 100644 --- a/query.c +++ b/query.c @@ -11,15 +11,17 @@ # include "config.h" #endif +#include +#include + #include "mutt.h" #include "mutt_menu.h" #include "mutt_idna.h" #include "mapping.h" #include "sort.h" -#include "lib/mem.h" -#include "lib/intl.h" #include "lib/str.h" +#include "lib/debug.h" #include #include @@ -44,7 +46,7 @@ static struct mapping_t QueryHelp[] = { {N_("Make Alias"), OP_CREATE_ALIAS}, {N_("Search"), OP_SEARCH}, {N_("Help"), OP_HELP}, - {NULL} + {NULL, OP_NULL} }; /* Variables for outsizing output format */ @@ -61,7 +63,7 @@ static ADDRESS *result_to_addr (QUERY * r) tmp = rfc822_cpy_adr (r->addr); if (!tmp->next && !tmp->personal) - tmp->personal = safe_strdup (r->name); + tmp->personal = str_dup (r->name); mutt_addrlist_to_idna (tmp, NULL); return tmp; @@ -85,7 +87,7 @@ static QUERY *run_query (char *s, int quiet) mutt_expand_file_fmt (cmd, sizeof (cmd), QueryCmd, s); if ((thepid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0) { - dprint (1, (debugfile, "unable to fork command: %s", cmd)); + debug_print (1, ("unable to fork command: %s\n", cmd)); return 0; } if (!quiet) @@ -99,11 +101,11 @@ static QUERY *run_query (char *s, int quiet) if (first == NULL) { FirstColumn = 0; SecondColumn = 0; - first = (QUERY *) safe_calloc (1, sizeof (QUERY)); + first = p_new(QUERY, 1); cur = first; } else { - cur->next = (QUERY *) safe_calloc (1, sizeof (QUERY)); + cur->next = p_new(QUERY, 1); cur = cur->next; } @@ -117,18 +119,18 @@ static QUERY *run_query (char *s, int quiet) l = mutt_strwidth (p); if (l > FirstColumn) FirstColumn = l; - cur->name = safe_strdup (p); + cur->name = str_dup (p); p = strtok (NULL, "\t\n"); if (p) { - cur->other = safe_strdup (p); + cur->other = str_dup (p); } } } } - FREE (&buf); + p_delete(&buf); fclose (fp); if (mutt_wait_filter (thepid)) { - dprint (1, (debugfile, "Error: %s\n", msg)); + debug_print (1, ("Error: %s\n", msg)); if (!quiet) mutt_error ("%s", msg); } @@ -155,11 +157,6 @@ static int query_search (MUTTMENU * m, regex_t * re, int n) if (table[n].data->addr->mailbox && !regexec (re, table[n].data->addr->mailbox, 0, NULL, 0)) return 0; -#ifdef EXACT_ADDRESS - if (table[n].data->addr->val && - !regexec (re, table[n].data->addr->val, 0, NULL, 0)) - return 0; -#endif } return REG_NOMATCH; @@ -189,7 +186,7 @@ static void query_entry (char *s, size_t slen, MUTTMENU * m, int num) mutt_format_string (buf2, sizeof (buf2), FirstColumn + 2, FirstColumn + 2, 0, ' ', table[num].data->name, - safe_strlen (table[num].data->name), 0); + str_len (table[num].data->name), 0); snprintf (s, slen, " %c %3d %s %-*.*s %s", table[num].tagged ? '*' : ' ', @@ -291,8 +288,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) for (queryp = results; queryp; queryp = queryp->next) menu->max++; - menu->data = QueryTable = - (ENTRY *) safe_calloc (menu->max, sizeof (ENTRY)); + menu->data = QueryTable = p_new(ENTRY, menu->max); for (i = 0, queryp = results; queryp; queryp = queryp->next, i++) QueryTable[i].data = queryp; @@ -314,14 +310,14 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) queryp = results; while (queryp) { rfc822_free_address (&queryp->addr); - FREE (&queryp->name); - FREE (&queryp->other); + p_delete(&queryp->name); + p_delete(&queryp->other); results = queryp->next; - FREE (&queryp); + p_delete(&queryp); queryp = results; } results = newresults; - FREE (&QueryTable); + p_delete(&QueryTable); } else { /* append */ @@ -348,8 +344,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) menu->max++; if (op == OP_QUERY) { - menu->data = QueryTable = - (ENTRY *) safe_calloc (menu->max, sizeof (ENTRY)); + menu->data = QueryTable = p_new(ENTRY, menu->max); for (i = 0, queryp = results; queryp; queryp = queryp->next, i++) @@ -359,7 +354,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) int clear = 0; /* append */ - safe_realloc (&QueryTable, menu->max * sizeof (ENTRY)); + p_realloc(&QueryTable, menu->max); menu->data = QueryTable; @@ -448,7 +443,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) mutt_addrlist_to_local (tmpa); tagged = 1; rfc822_write_address (buf, buflen, tmpa, 0); - curpos = safe_strlen (buf); + curpos = str_len (buf); rfc822_free_address (&tmpa); } else if (curpos + 2 < buflen) { @@ -458,7 +453,7 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) strcat (buf, ", "); /* __STRCAT_CHECKED__ */ rfc822_write_address ((char *) buf + curpos + 1, buflen - curpos - 1, tmpa, 0); - curpos = safe_strlen (buf); + curpos = str_len (buf); rfc822_free_address (&tmpa); } } @@ -477,13 +472,13 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf) queryp = results; while (queryp) { rfc822_free_address (&queryp->addr); - FREE (&queryp->name); - FREE (&queryp->other); + p_delete(&queryp->name); + p_delete(&queryp->other); results = queryp->next; - FREE (&queryp); + p_delete(&queryp); queryp = results; } - FREE (&QueryTable); + p_delete(&QueryTable); /* tell whoever called me to redraw the screen when I return */ set_option (OPTNEEDREDRAW);