Rocco Rutte:
[apps/madmutt.git] / init.c
diff --git a/init.c b/init.c
index 3573ff9..ff8c03b 100644 (file)
--- a/init.c
+++ b/init.c
 #include "mutt_crypt.h"
 #include "mutt_idna.h"
 
-#if defined(USE_SSL) || defined(USE_NSS) || defined(USE_GNUTLS)
+#if defined(USE_SSL) || defined(USE_GNUTLS)
 #include "mutt_ssl.h"
 #endif
 
 #include "mx.h"
 #include "init.h"
-#include "mailbox.h"
 
 #include "lib/mem.h"
 #include "lib/intl.h"
 #include "lib/str.h"
 #include "lib/rx.h"
+#include "lib/list.h"
+#include "lib/debug.h"
 
 #include <ctype.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/wait.h>
 
+/* for synonym warning reports: synonym found during parsing */
+typedef struct {
+  char* f;      /* file */
+  int l;        /* line */
+  int n;        /* new name (index) */
+  int o;        /* old name (index) */
+} syn_t;
+
+/* for synonym warning reports: list of synonyms found */
+list2_t* Synonyms;
+/* for synonym warning reports: current rc file */
+char* CurRCFile = NULL;
+/* for synonym warning reports: current rc line */
+int CurRCLine = 0;
+
+/* for synonym warning reports: adds synonym to end of list */
+static void syn_add (int n, int o) {
+  syn_t* tmp = safe_malloc (sizeof (syn_t));
+  tmp->f = str_dup (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) {
+  FREE(&(*(syn_t**) p)->f);
+  FREE(p);
+}
+
 void toggle_quadoption (int opt)
 {
   int n = opt / 4;
@@ -92,9 +124,12 @@ int mutt_option_index (char *s)
   int i;
 
   for (i = 0; MuttVars[i].option; i++)
-    if (safe_strcmp (s, MuttVars[i].option) == 0)
+    if (str_cmp (s, MuttVars[i].option) == 0) {
+      if (MuttVars[i].type == DT_SYN)
+        syn_add (mutt_option_index ((char *) MuttVars[i].data), i);
       return (MuttVars[i].type ==
               DT_SYN ? mutt_option_index ((char *) MuttVars[i].data) : i);
+    }
   return (-1);
 }
 
@@ -197,14 +232,12 @@ int mutt_extract_token (BUFFER * dest, BUFFER * tok, int flags)
         }
       } while (pc && *pc != '`');
       if (!pc) {
-        dprint (1, (debugfile, "mutt_get_token: mismatched backtics\n"));
+        debug_print (1, ("mismatched backtics\n"));
         return (-1);
       }
       cmd = str_substrdup (tok->dptr, pc);
       if ((pid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0) {
-        dprint (1,
-                (debugfile, "mutt_get_token: unable to fork command: %s",
-                 cmd));
+        debug_print (1, ("unable to fork command: %s\n", cmd));
         FREE (&cmd);
         return (-1);
       }
@@ -227,8 +260,8 @@ int mutt_extract_token (BUFFER * dest, BUFFER * tok, int flags)
         FREE (&expn.data);
       }
       else if (expn.data) {
-        expnlen = safe_strlen (expn.data);
-        tok->dsize = expnlen + safe_strlen (tok->dptr) + 1;
+        expnlen = str_len (expn.data);
+        tok->dsize = expnlen + str_len (tok->dptr) + 1;
         ptr = safe_malloc (tok->dsize);
         memcpy (ptr, expn.data, expnlen);
         strcpy (ptr + expnlen, tok->dptr);      /* __STRCPY_CHECKED__ */
@@ -253,7 +286,7 @@ int mutt_extract_token (BUFFER * dest, BUFFER * tok, int flags)
         }
       }
       else {
-        for (pc = tok->dptr; isalpha ((unsigned char) *pc) || *pc == '_';
+        for (pc = tok->dptr; isalnum ((unsigned char) *pc) || *pc == '_';
              pc++);
         var = str_substrdup (tok->dptr, pc);
         tok->dptr = pc;
@@ -291,7 +324,7 @@ static void add_to_list (LIST ** list, const char *str)
 
   if (!*list || last) {
     t = (LIST *) safe_calloc (1, sizeof (LIST));
-    t->data = safe_strdup (str);
+    t->data = str_dup (str);
     if (last) {
       last->next = t;
       last = last->next;
@@ -369,7 +402,7 @@ static int add_to_spam_list (SPAM_LIST ** list, const char *pat,
   }
 
   /* Now t is the SPAM_LIST* that we want to modify. It is prepared. */
-  t->template = safe_strdup (templ);
+  t->template = str_dup (templ);
 
   /* Find highest match number in template string */
   t->nmatch = 0;
@@ -396,7 +429,9 @@ static int remove_from_spam_list (SPAM_LIST ** list, const char *pat)
 
   /* Being first is a special case. */
   spam = *list;
-  if (spam->rx && !safe_strcmp (spam->rx->pattern, pat)) {
+  if (!spam)
+    return 0;
+  if (spam->rx && !str_cmp (spam->rx->pattern, pat)) {
     *list = spam->next;
     rx_free (&spam->rx);
     FREE(&spam->template);
@@ -406,7 +441,7 @@ static int remove_from_spam_list (SPAM_LIST ** list, const char *pat)
 
   prev = spam;
   for (spam = prev->next; spam;) {
-    if (!safe_strcmp (spam->rx->pattern, pat)) {
+    if (!str_cmp (spam->rx->pattern, pat)) {
       prev->next = spam->next;
       rx_free (&spam->rx);
       FREE(spam->template);
@@ -426,7 +461,7 @@ static void remove_from_list (LIST ** l, const char *str)
 {
   LIST *p, *last = NULL;
 
-  if (safe_strcmp ("*", str) == 0)
+  if (str_cmp ("*", str) == 0)
     mutt_free_list (l);         /* ``unCMD *'' means delete all current entries */
   else {
     p = *l;
@@ -452,8 +487,8 @@ static int remove_from_rx_list (list2_t** l, const char *str)
 {
   int i = 0;
 
-  if (safe_strcmp ("*", str) == 0) {
-    list_del (l, rx_free);
+  if (str_cmp ("*", str) == 0) {
+    list_del (l, (list_del_t*) rx_free);
     return (0);
   }
   else {
@@ -485,8 +520,8 @@ static int parse_ifdef (BUFFER * tmp, BUFFER * s, unsigned long data,
         continue;
 
       for (j = 0; b[j].name; j++)
-        if (!ascii_strncasecmp (tmp->data, b[j].name, safe_strlen (tmp->data))
-            && (safe_strlen (b[j].name) == safe_strlen (tmp->data))) {
+        if (!ascii_strncasecmp (tmp->data, b[j].name, str_len (tmp->data))
+            && (str_len (b[j].name) == str_len (tmp->data))) {
           res = 1;
           break;
         }
@@ -496,13 +531,13 @@ static int parse_ifdef (BUFFER * tmp, BUFFER * s, unsigned long data,
     char *p = NULL;
 
     i = 0;
-    j = safe_strlen (tmp->data);
+    j = str_len (tmp->data);
     /* need at least input of 'feature_X' */
     if (j >= 7) {
       p = tmp->data + 7;
       j -= 7;
       while (Features[i].name) {
-        if (safe_strlen (Features[i].name) == j &&
+        if (str_len (Features[i].name) == j &&
             ascii_strncasecmp (Features[i].name, p, j)) {
           res = 1;
           break;
@@ -608,7 +643,7 @@ static int parse_unalternates (BUFFER * buf, BUFFER * s, unsigned long data,
     mutt_extract_token (buf, s, 0);
     remove_from_rx_list (&Alternates, buf->data);
 
-    if (safe_strcmp (buf->data, "*") &&
+    if (str_cmp (buf->data, "*") &&
         add_to_rx_list (&UnAlternates, buf->data, REG_ICASE, err) != 0)
       return -1;
 
@@ -664,9 +699,9 @@ static int parse_spam_list (BUFFER * buf, BUFFER * s, unsigned long data,
     /* nospam only ever has one parameter. */
 
     /* "*" is a special case. */
-    if (!safe_strcmp (buf->data, "*")) {
+    if (!str_cmp (buf->data, "*")) {
       mutt_free_spam_list (&SpamList);
-      list_del (&NoSpamList, rx_free);
+      list_del (&NoSpamList, (list_del_t*) rx_free);
       return 0;
     }
 
@@ -694,7 +729,7 @@ static int parse_unlist (BUFFER * buf, BUFFER * s, unsigned long data,
     /*
      * Check for deletion of entire list
      */
-    if (safe_strcmp (buf->data, "*") == 0) {
+    if (str_cmp (buf->data, "*") == 0) {
       mutt_free_list ((LIST **) data);
       break;
     }
@@ -728,7 +763,7 @@ static int parse_unlists (BUFFER * buf, BUFFER * s, unsigned long data,
     remove_from_rx_list (&SubscribedLists, buf->data);
     remove_from_rx_list (&MailLists, buf->data);
 
-    if (safe_strcmp (buf->data, "*") &&
+    if (str_cmp (buf->data, "*") &&
         add_to_rx_list (&UnMailLists, buf->data, REG_ICASE, err) != 0)
       return -1;
   }
@@ -762,7 +797,7 @@ static int parse_unsubscribe (BUFFER * buf, BUFFER * s, unsigned long data,
     mutt_extract_token (buf, s, 0);
     remove_from_rx_list (&SubscribedLists, buf->data);
 
-    if (safe_strcmp (buf->data, "*") &&
+    if (str_cmp (buf->data, "*") &&
         add_to_rx_list (&UnSubscribedLists, buf->data, REG_ICASE, err) != 0)
       return -1;
   }
@@ -779,7 +814,7 @@ static int parse_unalias (BUFFER * buf, BUFFER * s, unsigned long data,
   do {
     mutt_extract_token (buf, s, 0);
 
-    if (safe_strcmp ("*", buf->data) == 0) {
+    if (str_cmp ("*", buf->data) == 0) {
       if (CurrentMenu == MENU_ALIAS) {
         for (tmp = Aliases; tmp; tmp = tmp->next)
           tmp->del = 1;
@@ -791,7 +826,7 @@ static int parse_unalias (BUFFER * buf, BUFFER * s, unsigned long data,
     }
     else
       for (tmp = Aliases; tmp; tmp = tmp->next) {
-        if (safe_strcasecmp (buf->data, tmp->name) == 0) {
+        if (str_casecmp (buf->data, tmp->name) == 0) {
           if (CurrentMenu == MENU_ALIAS) {
             tmp->del = 1;
             set_option (OPTFORCEREDRAWINDEX);
@@ -827,11 +862,11 @@ static int parse_alias (BUFFER * buf, BUFFER * s, unsigned long data,
 
   mutt_extract_token (buf, s, 0);
 
-  dprint (2, (debugfile, "parse_alias: First token is '%s'.\n", buf->data));
+  debug_print (2, ("first token is '%s'.\n", buf->data));
 
   /* check to see if an alias with this name already exists */
   for (; tmp; tmp = tmp->next) {
-    if (!safe_strcasecmp (tmp->name, buf->data))
+    if (!str_casecmp (tmp->name, buf->data))
       break;
     last = tmp;
   }
@@ -840,7 +875,7 @@ static int parse_alias (BUFFER * buf, BUFFER * s, unsigned long data,
     /* create a new alias */
     tmp = (ALIAS *) safe_calloc (1, sizeof (ALIAS));
     tmp->self = tmp;
-    tmp->name = safe_strdup (buf->data);
+    tmp->name = str_dup (buf->data);
     /* give the main addressbook code a chance */
     if (CurrentMenu == MENU_ALIAS)
       set_option (OPTMENUCALLER);
@@ -854,7 +889,7 @@ static int parse_alias (BUFFER * buf, BUFFER * s, unsigned long data,
 
   mutt_extract_token (buf, s,
                       M_TOKEN_QUOTE | M_TOKEN_SPACE | M_TOKEN_SEMICOLON);
-  dprint (2, (debugfile, "parse_alias: Second token is '%s'.\n", buf->data));
+  debug_print (2, ("second token is '%s'.\n", buf->data));
   tmp->addr = mutt_parse_adrlist (tmp->addr, buf->data);
   if (last)
     last->next = tmp;
@@ -866,14 +901,14 @@ static int parse_alias (BUFFER * buf, BUFFER * s, unsigned long data,
     return -1;
   }
 #ifdef DEBUG
-  if (debuglevel >= 2) {
+  if (DebugLevel >= 2) {
     ADDRESS *a;
 
     for (a = tmp->addr; a; a = a->next) {
       if (!a->group)
-        dprint (2, (debugfile, "parse_alias:   %s\n", a->mailbox));
+        debug_print (2, ("%s\n", a->mailbox));
       else
-        dprint (2, (debugfile, "parse_alias:   Group %s\n", a->mailbox));
+        debug_print (2, ("group %s\n", a->mailbox));
     }
   }
 #endif
@@ -890,13 +925,13 @@ parse_unmy_hdr (BUFFER * buf, BUFFER * s, unsigned long data, BUFFER * err)
 
   do {
     mutt_extract_token (buf, s, 0);
-    if (safe_strcmp ("*", buf->data) == 0)
+    if (str_cmp ("*", buf->data) == 0)
       mutt_free_list (&UserHeader);
     else {
       tmp = UserHeader;
       last = NULL;
 
-      l = safe_strlen (buf->data);
+      l = str_len (buf->data);
       if (buf->data[l - 1] == ':')
         l--;
 
@@ -968,12 +1003,12 @@ parse_sort (short *val, const char *s, const struct mapping_t *map,
 {
   int i, flags = 0;
 
-  if (safe_strncmp ("reverse-", s, 8) == 0) {
+  if (str_ncmp ("reverse-", s, 8) == 0) {
     s += 8;
     flags = SORT_REVERSE;
   }
 
-  if (safe_strncmp ("last-", s, 5) == 0) {
+  if (str_ncmp ("last-", s, 5) == 0) {
     s += 5;
     flags |= SORT_LAST;
   }
@@ -993,11 +1028,11 @@ static void mutt_set_default (struct option_t *p)
   switch (p->type & DT_MASK) {
   case DT_STR:
     if (!p->init && *((char **) p->data))
-      p->init = (unsigned long) safe_strdup (*((char **) p->data));
+      p->init = (unsigned long) str_dup (*((char **) p->data));
     break;
   case DT_PATH:
     if (!p->init && *((char **) p->data)) {
-      char *cp = safe_strdup (*((char **) p->data));
+      char *cp = str_dup (*((char **) p->data));
 
       /* mutt_pretty_mailbox (cp); */
       p->init = (unsigned long) cp;
@@ -1009,7 +1044,7 @@ static void mutt_set_default (struct option_t *p)
 
       *tmp = '\0';
       rfc822_write_address (tmp, sizeof (tmp), *((ADDRESS **) p->data), 0);
-      p->init = (unsigned long) safe_strdup (tmp);
+      p->init = (unsigned long) str_dup (tmp);
     }
     break;
   case DT_RX:
@@ -1017,7 +1052,7 @@ static void mutt_set_default (struct option_t *p)
       rx_t* pp = (rx_t*) p->data;
 
       if (!p->init && pp->pattern)
-        p->init = (unsigned long) safe_strdup (pp->pattern);
+        p->init = (unsigned long) str_dup (pp->pattern);
       break;
     }
   }
@@ -1074,9 +1109,9 @@ static void mutt_restore_default (struct option_t *p)
         char *s = (char *) p->init;
 
         pp->rx = safe_calloc (1, sizeof (regex_t));
-        if (safe_strcmp (p->option, "mask") != 0)
+        if (str_cmp (p->option, "mask") != 0)
           flags |= mutt_which_case ((const char *) p->init);
-        if (safe_strcmp (p->option, "mask") == 0 && *s == '!') {
+        if (str_cmp (p->option, "mask") == 0 && *s == '!') {
           s++;
           pp->not = 1;
         }
@@ -1126,11 +1161,11 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data,
       query = 1;
       s->dptr++;
     }
-    else if (safe_strncmp ("no", s->dptr, 2) == 0) {
+    else if (str_ncmp ("no", s->dptr, 2) == 0) {
       s->dptr += 2;
       unset = !unset;
     }
-    else if (safe_strncmp ("inv", s->dptr, 3) == 0) {
+    else if (str_ncmp ("inv", s->dptr, 3) == 0) {
       s->dptr += 3;
       inv = !inv;
     }
@@ -1143,7 +1178,7 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data,
     mutt_extract_token (tmp, s, M_TOKEN_EQUAL);
 
     if ((idx = mutt_option_index (tmp->data)) == -1 &&
-        !(reset && !safe_strcmp ("all", tmp->data))) {
+        !(reset && !str_cmp ("all", tmp->data))) {
       snprintf (err->data, err->dsize, _("%s: unknown variable"), tmp->data);
       return (-1);
     }
@@ -1160,7 +1195,7 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data,
         return (-1);
       }
 
-      if (!safe_strcmp ("all", tmp->data)) {
+      if (!str_cmp ("all", tmp->data)) {
         for (idx = 0; MuttVars[idx].option; idx++)
           mutt_restore_default (&MuttVars[idx]);
         return 0;
@@ -1240,11 +1275,11 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data,
         if (DTYPE (MuttVars[idx].type) == DT_PATH) {
           strfcpy (scratch, tmp->data, sizeof (scratch));
           mutt_expand_path (scratch, sizeof (scratch));
-          *((char **) MuttVars[idx].data) = safe_strdup (scratch);
+          *((char **) MuttVars[idx].data) = str_dup (scratch);
         }
         else if (DTYPE (MuttVars[idx].type) == DT_STR) {
-          *((char **) MuttVars[idx].data) = safe_strdup (tmp->data);
-          if (safe_strcmp (MuttVars[idx].option, "charset") == 0)
+          *((char **) MuttVars[idx].data) = str_dup (tmp->data);
+          if (str_cmp (MuttVars[idx].option, "charset") == 0)
             mutt_set_charset (Charset);
         }
         else {
@@ -1266,7 +1301,7 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data,
       }
 
       if (option (OPTATTACHMSG)
-          && !safe_strcmp (MuttVars[idx].option, "reply_regexp")) {
+          && !str_cmp (MuttVars[idx].option, "reply_regexp")) {
         snprintf (err->data, err->dsize,
                   "Operation not permitted when in attach-message mode.");
         r = -1;
@@ -1278,15 +1313,15 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data,
       /* copy the value of the string */
       mutt_extract_token (tmp, s, 0);
 
-      if (!ptr->pattern || safe_strcmp (ptr->pattern, tmp->data) != 0) {
+      if (!ptr->pattern || str_cmp (ptr->pattern, tmp->data) != 0) {
         int not = 0;
 
         /* $mask is case-sensitive */
-        if (safe_strcmp (MuttVars[idx].option, "mask") != 0)
+        if (str_cmp (MuttVars[idx].option, "mask") != 0)
           flags |= mutt_which_case (tmp->data);
 
         p = tmp->data;
-        if (safe_strcmp (MuttVars[idx].option, "mask") == 0) {
+        if (str_cmp (MuttVars[idx].option, "mask") == 0) {
           if (*p == '!') {
             not = 1;
             p++;
@@ -1308,14 +1343,14 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data,
           FREE (&ptr->rx);
         }
 
-        ptr->pattern = safe_strdup (tmp->data);
+        ptr->pattern = str_dup (tmp->data);
         ptr->rx = rx;
         ptr->not = not;
 
         /* $reply_regexp and $alterantes require special treatment */
 
         if (Context && Context->msgcount &&
-            safe_strcmp (MuttVars[idx].option, "reply_regexp") == 0) {
+            str_cmp (MuttVars[idx].option, "reply_regexp") == 0) {
           regmatch_t pmatch[1];
           int i;
 
@@ -1391,12 +1426,12 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data,
         *ptr = (short) val;
 
       /* these ones need a sanity check */
-      if (safe_strcmp (MuttVars[idx].option, "history") == 0) {
+      if (str_cmp (MuttVars[idx].option, "history") == 0) {
         if (*ptr < 0)
           *ptr = 0;
         mutt_init_history ();
       }
-      else if (safe_strcmp (MuttVars[idx].option, "pager_index_lines") == 0) {
+      else if (str_cmp (MuttVars[idx].option, "pager_index_lines") == 0) {
         if (*ptr < 0)
           *ptr = 0;
       }
@@ -1523,7 +1558,9 @@ static int source_rc (const char *rcfile, BUFFER * err)
   size_t buflen;
   pid_t pid;
 
-  dprint (2, (debugfile, "Reading configuration file '%s'.\n", rcfile));
+  debug_print (2, ("reading configuration file '%s'.\n", rcfile));
+  str_replace (&CurRCFile, rcfile);
+  CurRCLine = 0;
 
   if ((f = mutt_open_read (rcfile, &pid)) == NULL) {
     snprintf (err->data, err->dsize, "%s: %s", rcfile, strerror (errno));
@@ -1532,9 +1569,10 @@ static int source_rc (const char *rcfile, BUFFER * err)
 
   memset (&token, 0, sizeof (token));
   while ((linebuf = mutt_read_line (linebuf, &buflen, f, &line)) != NULL) {
+    CurRCLine++;
     conv = ConfigCharset && (*ConfigCharset) && Charset;
     if (conv) {
-      currentline = safe_strdup (linebuf);
+      currentline = str_dup (linebuf);
       if (!currentline)
         continue;
       mutt_convert_string (&currentline, ConfigCharset, Charset, 0);
@@ -1614,7 +1652,7 @@ int mutt_parse_rc_line ( /* const */ char *line, BUFFER * token, BUFFER * err)
 
   memset (&expn, 0, sizeof (expn));
   expn.data = expn.dptr = line;
-  expn.dsize = safe_strlen (line);
+  expn.dsize = str_len (line);
 
   *err->data = 0;
 
@@ -1628,7 +1666,7 @@ int mutt_parse_rc_line ( /* const */ char *line, BUFFER * token, BUFFER * err)
     }
     mutt_extract_token (token, &expn, 0);
     for (i = 0; Commands[i].name; i++) {
-      if (!safe_strcmp (token->data, Commands[i].name)) {
+      if (!str_cmp (token->data, Commands[i].name)) {
         if (Commands[i].func (token, &expn, Commands[i].data, err) != 0)
           goto finish;
         break;
@@ -1726,18 +1764,18 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs)
     /* return the completed command */
     strncpy (buffer, Completed, len - spaces);
   }
-  else if (!safe_strncmp (buffer, "set", 3)
-           || !safe_strncmp (buffer, "unset", 5)
-           || !safe_strncmp (buffer, "reset", 5)
-           || !safe_strncmp (buffer, "toggle", 6)) {    /* complete variables */
+  else if (!str_ncmp (buffer, "set", 3)
+           || !str_ncmp (buffer, "unset", 5)
+           || !str_ncmp (buffer, "reset", 5)
+           || !str_ncmp (buffer, "toggle", 6)) {    /* complete variables */
     char *prefixes[] = { "no", "inv", "?", "&", 0 };
 
     pt++;
     /* loop through all the possible prefixes (no, inv, ...) */
-    if (!safe_strncmp (buffer, "set", 3)) {
+    if (!str_ncmp (buffer, "set", 3)) {
       for (num = 0; prefixes[num]; num++) {
-        if (!safe_strncmp (pt, prefixes[num], safe_strlen (prefixes[num]))) {
-          pt += safe_strlen (prefixes[num]);
+        if (!str_ncmp (pt, prefixes[num], str_len (prefixes[num]))) {
+          pt += str_len (prefixes[num]);
           break;
         }
       }
@@ -1774,7 +1812,7 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs)
 
     strncpy (pt, Completed, buffer + len - pt - spaces);
   }
-  else if (!safe_strncmp (buffer, "exec", 4)) {
+  else if (!str_ncmp (buffer, "exec", 4)) {
     struct binding_t *menu = km_get_table (CurrentMenu);
 
     if (!menu && CurrentMenu != MENU_PAGER)
@@ -1842,12 +1880,12 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos)
   if (*pt == '=')               /* abort if no var before the '=' */
     return 0;
 
-  if (safe_strncmp (buffer, "set", 3) == 0) {
+  if (str_ncmp (buffer, "set", 3) == 0) {
     int idx;
 
     strfcpy (var, pt, sizeof (var));
     /* ignore the trailing '=' when comparing */
-    var[safe_strlen (var) - 1] = 0;
+    var[str_len (var) - 1] = 0;
     if ((idx = mutt_option_index (var)) == -1)
       return 0;                 /* no such variable. */
     else {
@@ -1902,6 +1940,26 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos)
                   "reverse-" : "",
                   (*((short *) MuttVars[idx].data) & SORT_LAST) ? "last-" :
                   "", p);
+      } 
+      else if (DTYPE (MuttVars[idx].type) == DT_MAGIC) {
+        char *p;
+        switch (DefaultMagic) {
+          case M_MBOX:
+            p = "mbox";
+            break;
+          case M_MMDF:
+            p = "MMDF";
+            break;
+          case M_MH:
+            p = "MH";
+          break;
+          case M_MAILDIR:
+            p = "Maildir";
+            break;
+          default:
+            p = "unknown";
+        }
+        strfcpy (tmp, p, sizeof (tmp));
       }
       else if (DTYPE (MuttVars[idx].type) == DT_BOOL)
         strfcpy (tmp, option (MuttVars[idx].data) ? "yes" : "no",
@@ -1975,31 +2033,6 @@ int mutt_getvaluebyname (const char *name, const struct mapping_t *map)
   return (-1);
 }
 
-#ifdef DEBUG
-static void start_debug (void)
-{
-  time_t t;
-  int i;
-  char buf[_POSIX_PATH_MAX];
-  char buf2[_POSIX_PATH_MAX];
-
-  /* rotate the old debug logs */
-  for (i = 3; i >= 0; i--) {
-    snprintf (buf, sizeof (buf), "%s/.muttdebug%d", NONULL (Homedir), i);
-    snprintf (buf2, sizeof (buf2), "%s/.muttdebug%d", NONULL (Homedir),
-              i + 1);
-    rename (buf, buf2);
-  }
-  if ((debugfile = safe_fopen (buf, "w")) != NULL) {
-    t = time (0);
-    setbuf (debugfile, NULL);   /* don't buffer the debugging output! */
-    fprintf (debugfile,
-             "Mutt-ng %s started at %s.\nDebugging at level %d.\n\n",
-             MUTT_VERSION, asctime (localtime (&t)), debuglevel);
-  }
-}
-#endif
-
 static int mutt_execute_commands (LIST * p)
 {
   BUFFER err, token;
@@ -2041,18 +2074,18 @@ void mutt_init (int skip_sys_rc, LIST * commands)
   /* on one of the systems I use, getcwd() does not return the same prefix
      as is listed in the passwd file */
   if ((p = getenv ("HOME")))
-    Homedir = safe_strdup (p);
+    Homedir = str_dup (p);
 
   /* Get some information about the user */
   if ((pw = getpwuid (getuid ()))) {
     char rnbuf[STRING];
 
-    Username = safe_strdup (pw->pw_name);
+    Username = str_dup (pw->pw_name);
     if (!Homedir)
-      Homedir = safe_strdup (pw->pw_dir);
+      Homedir = str_dup (pw->pw_dir);
 
-    Realname = safe_strdup (mutt_gecos_name (rnbuf, sizeof (rnbuf), pw));
-    Shell = safe_strdup (pw->pw_shell);
+    Realname = str_dup (mutt_gecos_name (rnbuf, sizeof (rnbuf), pw));
+    Shell = str_dup (pw->pw_shell);
   }
   else {
     if (!Homedir) {
@@ -2061,20 +2094,16 @@ void mutt_init (int skip_sys_rc, LIST * commands)
       exit (1);
     }
     if ((p = getenv ("USER")))
-      Username = safe_strdup (p);
+      Username = str_dup (p);
     else {
       mutt_endwin (NULL);
       fputs (_("unable to determine username"), stderr);
       exit (1);
     }
-    Shell = safe_strdup ((p = getenv ("SHELL")) ? p : "/bin/sh");
+    Shell = str_dup ((p = getenv ("SHELL")) ? p : "/bin/sh");
   }
 
-#ifdef DEBUG
-  /* Start up debugging mode if requested */
-  if (debuglevel > 0)
-    start_debug ();
-#endif
+  debug_start(Homedir);
 
   /* And about the host... */
   uname (&utsname);
@@ -2085,20 +2114,20 @@ void mutt_init (int skip_sys_rc, LIST * commands)
     strfcpy (buffer, p, sizeof (buffer));       /* save the domain for below */
   }
   else
-    Hostname = safe_strdup (utsname.nodename);
+    Hostname = str_dup (utsname.nodename);
 
 #ifndef DOMAIN
 #define DOMAIN buffer
   if (!p && getdnsdomainname (buffer, sizeof (buffer)) == -1)
-    Fqdn = safe_strdup ("@");
+    Fqdn = str_dup ("@");
   else
 #endif /* DOMAIN */
   if (*DOMAIN != '@') {
-    Fqdn = safe_malloc (safe_strlen (DOMAIN) + safe_strlen (Hostname) + 2);
+    Fqdn = safe_malloc (str_len (DOMAIN) + str_len (Hostname) + 2);
     sprintf (Fqdn, "%s.%s", NONULL (Hostname), DOMAIN); /* __SPRINTF_CHECKED__ */
   }
   else
-    Fqdn = safe_strdup (NONULL (Hostname));
+    Fqdn = str_dup (NONULL (Hostname));
 
 #ifdef USE_NNTP
   {
@@ -2115,37 +2144,37 @@ void mutt_init (int skip_sys_rc, LIST * commands)
              && (*i != '\n'))
         i++;
       *i = '\0';
-      NewsServer = safe_strdup (p);
+      NewsServer = str_dup (p);
       fclose (f);
     }
   }
   if ((p = getenv ("NNTPSERVER")))
-    NewsServer = safe_strdup (p);
+    NewsServer = str_dup (p);
 #endif
 
   if ((p = getenv ("MAIL")))
-    Spoolfile = safe_strdup (p);
+    Spoolfile = str_dup (p);
   else if ((p = getenv ("MAILDIR")))
-    Spoolfile = safe_strdup (p);
+    Spoolfile = str_dup (p);
   else {
 #ifdef HOMESPOOL
     mutt_concat_path (buffer, NONULL (Homedir), MAILPATH, sizeof (buffer));
 #else
     mutt_concat_path (buffer, MAILPATH, NONULL (Username), sizeof (buffer));
 #endif
-    Spoolfile = safe_strdup (buffer);
+    Spoolfile = str_dup (buffer);
   }
 
   if ((p = getenv ("MAILCAPS")))
-    MailcapPath = safe_strdup (p);
+    MailcapPath = str_dup (p);
   else {
     /* Default search path from RFC1524 */
     MailcapPath =
-      safe_strdup ("~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR
+      str_dup ("~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR
                    "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap");
   }
 
-  Tempdir = safe_strdup ((p = getenv ("TMPDIR")) ? p : "/tmp");
+  Tempdir = str_dup ((p = getenv ("TMPDIR")) ? p : "/tmp");
 
   p = getenv ("VISUAL");
   if (!p) {
@@ -2153,8 +2182,8 @@ void mutt_init (int skip_sys_rc, LIST * commands)
     if (!p)
       p = "vi";
   }
-  Editor = safe_strdup (p);
-  Visual = safe_strdup (p);
+  Editor = str_dup (p);
+  Visual = str_dup (p);
 
   if ((p = getenv ("REPLYTO")) != NULL) {
     BUFFER buf, token;
@@ -2163,7 +2192,7 @@ void mutt_init (int skip_sys_rc, LIST * commands)
 
     memset (&buf, 0, sizeof (buf));
     buf.data = buf.dptr = buffer;
-    buf.dsize = safe_strlen (buffer);
+    buf.dsize = str_len (buffer);
 
     memset (&token, 0, sizeof (token));
     parse_my_hdr (&token, &buf, 0, &err);
@@ -2231,16 +2260,16 @@ void mutt_init (int skip_sys_rc, LIST * commands)
                 NONULL (Homedir));
 
     default_rc = 1;
-    Muttrc = safe_strdup (buffer);
+    Muttrc = str_dup (buffer);
   }
   else {
     strfcpy (buffer, Muttrc, sizeof (buffer));
     FREE (&Muttrc);
     mutt_expand_path (buffer, sizeof (buffer));
-    Muttrc = safe_strdup (buffer);
+    Muttrc = str_dup (buffer);
   }
   FREE (&AliasFile);
-  AliasFile = safe_strdup (NONULL (Muttrc));
+  AliasFile = str_dup (NONULL (Muttrc));
 
   /* Process the global rc file if it exists and the user hasn't explicity
      requested not to via "-n".  */
@@ -2283,6 +2312,23 @@ void mutt_init (int skip_sys_rc, LIST * commands)
   if (mutt_execute_commands (commands) != 0)
     need_pause = 1;
 
+  /* warn about synonym variables */
+  if (!list_empty(Synonyms)) {
+    int i = 0;
+    fprintf (stderr, _("Warning: the following synonym variables were found:\n"));
+    for (i = 0; i < Synonyms->length; i++)
+      fprintf (stderr, "$%s ($%s should be used) (%s:%d)\n",
+               MuttVars[((syn_t*) Synonyms->data[i])->o].option,
+               MuttVars[((syn_t*) Synonyms->data[i])->n].option,
+               NONULL(((syn_t*) Synonyms->data[i])->f),
+               ((syn_t*) Synonyms->data[i])->l);
+    fprintf (stderr, _("Warning: Synonym variables are scheduled for removal.\n"));
+    list_del (&Synonyms, syn_del);
+    need_pause = 1;
+  }
+  /* this is not needed during runtime */
+  FREE(&CurRCFile);
+
   if (need_pause && !option (OPTNOCURSES)) {
     if (mutt_any_key_to_continue (NULL) == -1)
       mutt_exit (1);
@@ -2302,3 +2348,50 @@ int mutt_get_hook_type (const char *name)
       return c->data;
   return 0;
 }
+
+static int opt_cmp (const void* a, const void* b) {
+  return (str_cmp ((*(struct option_t**) a)->option,
+                       (*(struct option_t**) b)->option));
+}
+
+/* dump out the value of all the variables we have */
+int mutt_dump_variables (void) {
+  int i;
+
+  char errbuff[STRING];
+  char command[STRING];
+  list2_t* tmp = NULL;
+
+  BUFFER err, token;
+
+  memset (&err, 0, sizeof (err));
+  memset (&token, 0, sizeof (token));
+
+  err.data = errbuff;
+  err.dsize = sizeof (errbuff);
+
+  /* get all non-synonyms into list... */
+  for (i = 0; MuttVars[i].option; i++) {
+    if (MuttVars[i].type == DT_SYN)
+      continue;
+    list_push_back (&tmp, &MuttVars[i]);
+  }
+  if (!list_empty(tmp)) {
+    /* ...and dump list sorted */
+    qsort (tmp->data, tmp->length, sizeof (void*), opt_cmp);
+    for (i = 0; i < tmp->length; i++) {
+      snprintf (command, sizeof (command), "set ?%s\n",
+                ((struct option_t*) tmp->data[i])->option);
+      if (mutt_parse_rc_line (command, &token, &err) == -1) {
+        fprintf (stderr, "%s\n", err.data);
+        FREE (&token.data);
+        list_del (&tmp, NULL);
+        return 1;
+      }
+      printf("%s\n", err.data);
+    }
+  }
+  FREE (&token.data);
+  list_del (&tmp, NULL);
+  return 0;
+}