#include "mx.h"
#include "init.h"
-#include "lib/list.h"
-
/*
* prototypes
*/
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 */
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;
/* 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;
}
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;
}
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)