]> granicus.if.org Git - mutt/commitdiff
Hack: mutt_restore_default() now stores the latest value of a
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 16 May 2000 15:49:17 +0000 (15:49 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 16 May 2000 15:49:17 +0000 (15:49 +0000)
variable as it's default if there was no default before.  The code
in question is executed precisely once: when mutt_restore_default() is
invoked from mutt_init().

init.c

diff --git a/init.c b/init.c
index a7ef2a3b3422e7e25d8ceab49d0cb92b5e70640e..b4d858ff1f2b63a6a5fc960b53d348f1eb1b3430 100644 (file)
--- a/init.c
+++ b/init.c
@@ -648,6 +648,8 @@ 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)
@@ -658,6 +660,8 @@ 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)
@@ -665,6 +669,12 @@ 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)
@@ -691,6 +701,7 @@ static void mutt_restore_default (struct option_t *p)
          regfree (pp->rx);
          FREE (&pp->rx);
        }
+
        if (p->init)
        {
          char *s = (char *) p->init;
@@ -715,9 +726,12 @@ 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;
   }
+
   if (p->flags & R_INDEX)
     set_option (OPTFORCEREDRAWINDEX);
   if (p->flags & R_PAGER)