X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=init.c;h=983a620a7a59bef934e3a06fc50e1f3732b06e8e;hp=447db37ddffadfa0cf6fb045436508828486dfc6;hb=284454918cc95058b026d057195eaa5279135c36;hpb=250e22d7ca2420a08b34711713839780fd042ba9 diff --git a/init.c b/init.c index 447db37..983a620 100644 --- a/init.c +++ b/init.c @@ -34,8 +34,6 @@ #include "mx.h" #include "init.h" -#include "lib/list.h" - /* * prototypes */ @@ -47,15 +45,24 @@ static int parse_sort (struct option_t* dst, const char *s, static HASH *ConfigOptions = NULL; /* for synonym warning reports: synonym found during parsing */ -typedef struct { +typedef struct syn_t { + struct syn_t *next; char* f; /* file */ int l; /* line */ struct option_t* n; /* new */ struct option_t* o; /* old */ } syn_t; +DO_INIT(syn_t, syn); +static void syn_wipe(syn_t *syn) { + p_delete(&syn->f); +} +DO_NEW(syn_t, syn); +DO_DELETE(syn_t, syn); +DO_SLIST(syn_t, syn, syn_delete); + /* for synonym warning reports: list of synonyms found */ -static list2_t* Synonyms; +static syn_t *Synonyms = NULL; /* for synonym warning reports: current rc file */ static const char* CurRCFile = NULL; /* for synonym warning reports: current rc line */ @@ -535,22 +542,6 @@ int mutt_option_value (const char* val, char* dst, ssize_t dstlen) { return (1); } -/* for synonym warning reports: adds synonym to end of list */ -static void syn_add (struct option_t* n, struct option_t* o) { - syn_t* tmp = p_new(syn_t, 1); - tmp->f = m_strdup(CurRCFile); - tmp->l = CurRCLine; - tmp->n = n; - tmp->o = o; - list_push_back (&Synonyms, tmp); -} - -/* for synonym warning reports: free single item (for list_del()) */ -static void syn_del (void** p) { - p_delete(&(*(syn_t**) p)->f); - p_delete(p); -} - static void toggle_quadoption (int opt) { int n = opt / 4; @@ -1798,9 +1789,15 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, /* resolve synonyms */ if ((option = hash_find (ConfigOptions, tmp->data)) != NULL && - DTYPE (option->type == DT_SYN)) { + DTYPE (option->type == DT_SYN)) + { struct option_t* newopt = hash_find (ConfigOptions, (char*) option->data); - syn_add (newopt, option); + syn_t* tmp = syn_new(); + tmp->f = m_strdup(CurRCFile); + tmp->l = CurRCLine; + tmp->n = newopt; + tmp->o = option; + syn_list_push(&Synonyms, tmp); option = newopt; } @@ -2724,22 +2721,20 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) need_pause = 1; /* warn about synonym variables */ - if (!list_empty(Synonyms)) { - i = 0; + if (Synonyms) { + syn_t *syn; + fprintf (stderr, _("Warning: the following synonym variables were found:\n")); - for (i = 0; i < Synonyms->length; i++) { - struct option_t* newopt = NULL, *oldopt = NULL; - newopt = (struct option_t*) ((syn_t*) Synonyms->data[i])->n; - oldopt = (struct option_t*) ((syn_t*) Synonyms->data[i])->o; - fprintf (stderr, "$%s ($%s should be used) (%s:%d)\n", - oldopt ? NONULL (oldopt->option) : "", - newopt ? NONULL (newopt->option) : "", - NONULL(((syn_t*) Synonyms->data[i])->f), - ((syn_t*) Synonyms->data[i])->l); + + for (syn = Synonyms; syn; syn = syn->next) { + fprintf(stderr, "$%s ($%s should be used) (%s:%d)\n", + syn->o ? NONULL(syn->o->option) : "", + syn->n ? NONULL(syn->n->option) : "", + NONULL(syn->f), syn->l); } fprintf (stderr, _("Warning: synonym variables are scheduled" " for removal.\n")); - list_del (&Synonyms, syn_del); + syn_list_wipe(&Synonyms); need_pause = 1; } @@ -2747,10 +2742,6 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) if (mutt_any_key_to_continue (NULL) == -1) mutt_exit (1); } - -#if 0 - set_option (OPTWEED); /* turn weeding on by default */ -#endif } int mutt_get_hook_type (const char *name) @@ -2781,10 +2772,12 @@ int mutt_dump_variables (int full) { continue; } + printf("set "); FuncTable[DTYPE(option->type)].opt_to_string (buf, sizeof(buf), option); printf ("%s\n", buf); } + printf ("\n# vi""m:set ft=muttrc:\n"); return 0; }