summaryrefslogtreecommitdiffstats
path: root/init.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>2000-05-16 15:57:36 +0000
committerThomas Roessler <roessler@does-not-exist.org>2000-05-16 15:57:36 +0000
commit54de007bacd09934fbbb23bdb6320ef33593ff31 (patch)
treeb139b7fb76a6ac170accb128c9655b98c11b8c98 /init.c
parentf8064719de611d44ef16aede62aa61c309e86bcc (diff)
More default setting. This can easily be done much cleaner than the
last version of the patch.
Diffstat (limited to 'init.c')
-rw-r--r--init.c49
1 files changed, 37 insertions, 12 deletions
diff --git a/init.c b/init.c
index b4d858ff..1b414137 100644
--- a/init.c
+++ b/init.c
@@ -641,6 +641,40 @@ parse_sort (short *val, const char *s, const struct mapping_t *map, BUFFER *err)
return 0;
}
+static void mutt_set_default (struct option_t *p)
+{
+ switch (p->type & DT_MASK)
+ {
+ case DT_STR:
+ if (*((char **) p->data))
+ p->init = (unsigned long) safe_strdup (* ((char **) p->data));
+ break;
+ case DT_PATH:
+ if (*((char **) p->data))
+ {
+ char *cp = safe_strdup (*((char **) p->data));
+ mutt_pretty_mailbox (cp);
+ p->init = (unsigned long) cp;
+ }
+ break;
+ case DT_ADDR:
+ if (*((ADDRESS **) p->data))
+ {
+ char tmp[HUGE_STRING];
+ rfc822_write_address (tmp, sizeof (tmp), *((ADDRESS **) p->data));
+ p->init = (unsigned long) safe_strdup (tmp);
+ }
+ break;
+ case DT_RX:
+ {
+ REGEXP *pp = (REGEXP *) p->data;
+ if (pp->pattern)
+ p->init = (unsigned long) safe_strdup (pp->pattern);
+ break;
+ }
+ }
+}
+
static void mutt_restore_default (struct option_t *p)
{
switch (p->type & DT_MASK)
@@ -648,8 +682,6 @@ static void mutt_restore_default (struct option_t *p)
case DT_STR:
if (p->init)
mutt_str_replace ((char **) p->data, (char *) p->init);
- else if (*((char **) p->data))
- p->init = (unsigned long) safe_strdup (* ((char **) p->data));
break;
case DT_PATH:
if (p->init)
@@ -660,8 +692,6 @@ static void mutt_restore_default (struct option_t *p)
mutt_expand_path (path, sizeof (path));
mutt_str_replace ((char **) p->data, path);
}
- else if (*((char **) p->data))
- p->init = (unsigned long) safe_strdup (* ((char **) p->data));
break;
case DT_ADDR:
if (p->init)
@@ -669,12 +699,6 @@ static void mutt_restore_default (struct option_t *p)
rfc822_free_address ((ADDRESS **) p->data);
*((ADDRESS **) p->data) = rfc822_parse_adrlist (NULL, (char *) p->init);
}
- else if (*((ADDRESS **) p->data))
- {
- char tmp[HUGE_STRING];
- rfc822_write_address (tmp, sizeof (tmp), *((ADDRESS **) p->data));
- p->init = (unsigned long) safe_strdup (tmp);
- }
break;
case DT_BOOL:
if (p->init)
@@ -726,8 +750,6 @@ static void mutt_restore_default (struct option_t *p)
FREE (&pp->rx);
}
}
- else if (pp->pattern)
- p->init = (unsigned long) safe_strdup (pp->pattern);
}
break;
}
@@ -1789,7 +1811,10 @@ void mutt_init (int skip_sys_rc, LIST *commands)
/* Set standard defaults */
for (i = 0; MuttVars[i].option; i++)
+ {
+ mutt_set_default (&MuttVars[i]);
mutt_restore_default (&MuttVars[i]);
+ }
CurrentMenu = MENU_MAIN;