This commit changes the -F option so that it may be passed multiple
times.
---
 init.c | 57 +++++++++++++++++++++++++++++++++++++--------------------
 main.c |  8 ++++----
 mutt.h |  2 +-
 3 files changed, 42 insertions(+), 25 deletions(-)

diff --git a/init.c b/init.c
index 808ebc7..bdc5345 100644
--- a/init.c
+++ b/init.c
@@ -2963,12 +2963,13 @@ static char* mutt_find_sys_cfg (char *path, const char 
**files)
   return NULL;
 }
 
-void mutt_init (int skip_sys_rc, LIST *commands, const char *muttrc)
+void mutt_init (int skip_sys_rc, LIST *commands, LIST *muttrcs)
 {
   struct passwd *pw;
   struct utsname utsname;
   char *p, buffer[STRING];
   char *domain = NULL;
+  char *muttrc = NULL;
   int i, need_pause = 0;
   BUFFER err;
 
@@ -3218,7 +3219,7 @@ void mutt_init (int skip_sys_rc, LIST *commands, const 
char *muttrc)
     }
   }
 
-  if (!muttrc)
+  if (!muttrcs)
   {
     char *xdg_cfg_home = getenv ("XDG_CONFIG_HOME");
 
@@ -3229,35 +3230,51 @@ void mutt_init (int skip_sys_rc, LIST *commands, const 
char *muttrc)
     }
 
     muttrc = mutt_find_cfg (Homedir, xdg_cfg_home);
+    if (muttrc)
+    {
+      if (!option (OPTNOCURSES))
+        endwin ();
+      if (source_rc (muttrc, &err))
+      {
+        fputs (err.data, stderr);
+        fputc ('\n', stderr);
+        need_pause = 1;
+      }
+    }
   }
   else
   {
-    strfcpy (buffer, muttrc, sizeof (buffer));
-    mutt_expand_path (buffer, sizeof (buffer));
-    muttrc = safe_strdup (buffer);
-    if (access (muttrc, F_OK))
+    if (!option (OPTNOCURSES))
+        endwin ();
+
+    for (; muttrcs; muttrcs = muttrcs->next)
     {
-      snprintf (buffer, sizeof (buffer), "%s: %s", muttrc, strerror (errno));
-      mutt_endwin (buffer);
-      exit (1);
+      strfcpy (buffer, muttrcs->data, sizeof (buffer));
+      mutt_expand_path (buffer, sizeof (buffer));
+      FREE (&muttrc);
+      muttrc = safe_strdup (buffer);
+      if (access (muttrc, F_OK) == 0)
+      {
+        if (source_rc (muttrc, &err))
+        {
+          fputs (err.data, stderr);
+          fputc ('\n', stderr);
+          need_pause = 1;
+        }
+      }
+      else
+      {
+        snprintf (buffer, sizeof (buffer), "%s: %s", muttrc, strerror (errno));
+        mutt_endwin (buffer);
+        exit (1);
+      }
     }
   }
 
-  /* Read the user's initialization file.  */
   if (muttrc)
   {
     FREE (&AliasFile);
     AliasFile = safe_strdup (muttrc);
-
-    if (!option (OPTNOCURSES))
-      endwin ();
-    if (source_rc (muttrc, &err) != 0)
-    {
-      fputs (err.data, stderr);
-      fputc ('\n', stderr);
-      need_pause = 1;
-    }
-
     FREE (&muttrc);
   }
 
diff --git a/main.c b/main.c
index 709f2b2..13c1990 100644
--- a/main.c
+++ b/main.c
@@ -578,10 +578,10 @@ int main (int argc, char **argv)
   char *includeFile = NULL;
   char *draftFile = NULL;
   char *newMagic = NULL;
-  char *muttrc = NULL;
   HEADER *msg = NULL;
   LIST *attach = NULL;
   LIST *commands = NULL;
+  LIST *muttrcs = NULL;
   LIST *queries = NULL;
   LIST *alias_queries = NULL;
   int sendflags = 0;
@@ -654,7 +654,7 @@ int main (int argc, char **argv)
        break;
 
       case 'F':
-        muttrc = safe_strdup (optarg);
+        muttrcs = mutt_add_list (muttrcs, optarg);
         break;
 
       case 'f':
@@ -801,9 +801,9 @@ int main (int argc, char **argv)
   }
 
   /* set defaults and read init files */
-  mutt_init (flags & MUTT_NOSYSRC, commands, muttrc);
+  mutt_init (flags & MUTT_NOSYSRC, commands, muttrcs);
   mutt_free_list (&commands);
-  FREE (&muttrc);
+  mutt_free_list (&muttrcs);
 
   /* Initialize crypto backends.  */
   crypt_init ();
diff --git a/mutt.h b/mutt.h
index 64e4fa5..ee01bd6 100644
--- a/mutt.h
+++ b/mutt.h
@@ -591,7 +591,7 @@ LIST *mutt_add_list_n (LIST*, const void *, size_t);
 LIST *mutt_find_list (LIST *, const char *);
 int mutt_remove_from_rx_list (RX_LIST **l, const char *str);
 
-void mutt_init (int, LIST *, const char *muttrc);
+void mutt_init (int, LIST *, LIST *);
 
 typedef struct alias
 {
-- 
2.10.2

Reply via email to