X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/14c29200cb58d3c4a0830265f2433849781858d0..17be5eecfc074a5af14fb415d41be6a317273b07:/query.c diff --git a/query.c b/query.c index 787af78..f2464b9 100644 --- a/query.c +++ b/query.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1996-2000 Michael R. Elkins + * Copyright (C) 1996-2000,2003 Michael R. Elkins * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,6 @@ #include "mutt_menu.h" #include "mutt_idna.h" #include "mapping.h" -#include "sort.h" #include #include @@ -52,20 +51,16 @@ static struct mapping_t QueryHelp[] = { { N_("Make Alias"), OP_CREATE_ALIAS }, { N_("Search"), OP_SEARCH }, { N_("Help"), OP_HELP }, - { NULL } + { NULL, 0 } }; -/* Variables for outsizing output format */ -static int FirstColumn; -static int SecondColumn; - static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf); static ADDRESS *result_to_addr (QUERY *r) { static ADDRESS *tmp; - if (!(tmp = rfc822_cpy_adr (r->addr))) + if (!(tmp = rfc822_cpy_adr (r->addr, 0))) return NULL; if(!tmp->next && !tmp->personal) @@ -87,7 +82,6 @@ static QUERY *run_query (char *s, int quiet) char msg[STRING]; char *p; pid_t thepid; - int l; mutt_expand_file_fmt (cmd, sizeof(cmd), QueryCmd, s); @@ -102,14 +96,12 @@ static QUERY *run_query (char *s, int quiet) fgets (msg, sizeof (msg), fp); if ((p = strrchr (msg, '\n'))) *p = '\0'; - while ((buf = mutt_read_line (buf, &buflen, fp, &dummy)) != NULL) + while ((buf = mutt_read_line (buf, &buflen, fp, &dummy, 0)) != NULL) { if ((p = strtok(buf, "\t\n"))) { if (first == NULL) { - FirstColumn = 0; - SecondColumn = 0; first = (QUERY *) safe_calloc (1, sizeof (QUERY)); cur = first; } @@ -119,28 +111,19 @@ static QUERY *run_query (char *s, int quiet) cur = cur->next; } - l = mutt_strwidth (p); - if (l > SecondColumn) - SecondColumn = l; - cur->addr = rfc822_parse_adrlist (cur->addr, p); p = strtok(NULL, "\t\n"); if (p) { - l = mutt_strwidth (p); - if (l > FirstColumn) - FirstColumn = l; cur->name = safe_strdup (p); p = strtok(NULL, "\t\n"); if (p) - { cur->other = safe_strdup (p); - } } } } FREE (&buf); - fclose (fp); + safe_fclose (&fp); if (mutt_wait_filter (thepid)) { dprint (1, (debugfile, "Error: %s\n", msg)); @@ -202,7 +185,7 @@ static const char * query_format_str (char *dest, size_t destlen, size_t col, break; case 'c': snprintf (tmp, sizeof (tmp), "%%%sd", fmt); - snprintf (dest, destlen, tmp, query->num); + snprintf (dest, destlen, tmp, query->num + 1); break; case 'e': if (!optional) @@ -317,11 +300,10 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf) snprintf (title, sizeof (title), _("Query")); /* FIXME */ - menu = mutt_new_menu (); + menu = mutt_new_menu (MENU_QUERY); menu->make_entry = query_entry; menu->search = query_search; menu->tag = query_tag; - menu->menu = MENU_QUERY; menu->title = title; menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_QUERY, QueryHelp); @@ -390,11 +372,10 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf) menu->current = 0; mutt_menuDestroy (&menu); - menu = mutt_new_menu (); + menu = mutt_new_menu (MENU_QUERY); menu->make_entry = query_entry; menu->search = query_search; menu->tag = query_tag; - menu->menu = MENU_QUERY; menu->title = title; menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_QUERY, QueryHelp); @@ -445,7 +426,7 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf) if (QueryTable[i].tagged) { ADDRESS *a = result_to_addr(QueryTable[i].data); - rfc822_append (&naddr, a); + rfc822_append (&naddr, a, 0); rfc822_free_address (&a); } @@ -480,7 +461,7 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf) if (QueryTable[i].tagged) { ADDRESS *a = result_to_addr(QueryTable[i].data); - rfc822_append (&msg->env->to, a); + rfc822_append (&msg->env->to, a, 0); rfc822_free_address (&a); } }