list2_t --
[apps/madmutt.git] / init.c
diff --git a/init.c b/init.c
index ce0bd20..447db37 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1681,7 +1681,7 @@ check_dsn_notify (const char* option __attribute__ ((unused)),
 {
     const char *p = (const char*)val;
 
-    while (*p) {
+    while (p && *p) {
         const char *q = m_strchrnul(p, ',');
         int len = q - p;
 
@@ -2763,61 +2763,28 @@ int mutt_get_hook_type (const char *name)
   return 0;
 }
 
-/* compare two option_t*'s for sorting -t/-T output */
-static int opt_cmp (const void* a, const void* b) {
-  return (m_strcmp((*(struct option_t**) a)->option,
-                       (*(struct option_t**) b)->option));
-}
-
-/* callback for hash_map() to put all non-synonym vars into list */
-static void opt_sel_full (const char* key __attribute__ ((unused)),
-                          void* data,
-                          unsigned long more) {
-  list2_t** l = (list2_t**) more;
-  struct option_t* option = (struct option_t*) data;
-
-  if (DTYPE (option->type) == DT_SYN)
-    return;
-  list_push_back (l, option);
-}
-
-/* callback for hash_map() to put all changed non-synonym vars into list */
-static void opt_sel_diff (const char* key __attribute__ ((unused)),
-                          void* data,
-                          unsigned long more) {
-  list2_t** l = (list2_t**) more;
-  struct option_t* option = (struct option_t*) data;
-  char buf[LONG_STRING];
+/* dump out the value of all the variables we have */
+int mutt_dump_variables (int full) {
+    ssize_t i = 0;
 
-  if (DTYPE (option->type) == DT_SYN)
-    return;
+    /* get all non-synonyms into list... */
+    for (i = 0; MuttVars[i].option; i++) {
+        struct option_t *option = MuttVars + i;
+        char buf[LONG_STRING];
 
-  mutt_option_value (option->option, buf, sizeof(buf));
-  if (m_strcmp(buf, option->init) != 0)
-    list_push_back (l, option);
-}
+        if (DTYPE(option->type) == DT_SYN)
+            continue;
 
-/* dump out the value of all the variables we have */
-int mutt_dump_variables (int full) {
-  ssize_t i = 0;
-  char outbuf[STRING];
-  list2_t* tmp = NULL;
-  struct option_t* option = NULL;
+        if (!full) {
+            mutt_option_value(option->option, buf, sizeof(buf));
+            if (!m_strcmp(buf, option->init))
+                continue;
+        }
 
-  /* get all non-synonyms into list... */
-  hash_map (ConfigOptions, full ? opt_sel_full : opt_sel_diff,
-            (unsigned long) &tmp);
-
-  if (!list_empty(tmp)) {
-    /* ...and dump list sorted */
-    qsort (tmp->data, tmp->length, sizeof(void*), opt_cmp);
-    for (i = 0; i < tmp->length; i++) {
-      option = (struct option_t*) tmp->data[i];
-      FuncTable[DTYPE (option->type)].opt_to_string
-        (outbuf, sizeof(outbuf), option);
-      printf ("%s\n", outbuf);
+        FuncTable[DTYPE(option->type)].opt_to_string
+            (buf, sizeof(buf), option);
+        printf ("%s\n", buf);
     }
-  }
-  list_del (&tmp, NULL);
-  return 0;
+
+    return 0;
 }