This variable is only used to pass the '-F' argument from main to
mutt_init, so it can be changed to be local.
---
 globals.h |  1 -
 init.c    | 23 ++++++++++++-----------
 main.c    |  8 +++++---
 mutt.h    |  2 +-
 4 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/globals.h b/globals.h
index 30ad441..cfcaa21 100644
--- a/globals.h
+++ b/globals.h
@@ -95,7 +95,6 @@ WHERE char *Mixmaster;
 WHERE char *MixEntryFormat;
 #endif
 
-WHERE char *Muttrc INITVAL (NULL);
 WHERE char *Outbox;
 WHERE char *Pager;
 WHERE char *PagerFmt;
diff --git a/init.c b/init.c
index ab2b398..808ebc7 100644
--- a/init.c
+++ b/init.c
@@ -2963,7 +2963,7 @@ static char* mutt_find_sys_cfg (char *path, const char 
**files)
   return NULL;
 }
 
-void mutt_init (int skip_sys_rc, LIST *commands)
+void mutt_init (int skip_sys_rc, LIST *commands, const char *muttrc)
 {
   struct passwd *pw;
   struct utsname utsname;
@@ -3218,7 +3218,7 @@ void mutt_init (int skip_sys_rc, LIST *commands)
     }
   }
 
-  if (!Muttrc)
+  if (!muttrc)
   {
     char *xdg_cfg_home = getenv ("XDG_CONFIG_HOME");
 
@@ -3228,36 +3228,37 @@ void mutt_init (int skip_sys_rc, LIST *commands)
       xdg_cfg_home = buffer;
     }
 
-    Muttrc = mutt_find_cfg (Homedir, xdg_cfg_home);
+    muttrc = mutt_find_cfg (Homedir, xdg_cfg_home);
   }
   else
   {
-    strfcpy (buffer, Muttrc, sizeof (buffer));
-    FREE (&Muttrc);
+    strfcpy (buffer, muttrc, sizeof (buffer));
     mutt_expand_path (buffer, sizeof (buffer));
-    Muttrc = safe_strdup (buffer);
-    if (access (Muttrc, F_OK))
+    muttrc = safe_strdup (buffer);
+    if (access (muttrc, F_OK))
     {
-      snprintf (buffer, sizeof (buffer), "%s: %s", Muttrc, strerror (errno));
+      snprintf (buffer, sizeof (buffer), "%s: %s", muttrc, strerror (errno));
       mutt_endwin (buffer);
       exit (1);
     }
   }
 
   /* Read the user's initialization file.  */
-  if (Muttrc)
+  if (muttrc)
   {
     FREE (&AliasFile);
-    AliasFile = safe_strdup (Muttrc);
+    AliasFile = safe_strdup (muttrc);
 
     if (!option (OPTNOCURSES))
       endwin ();
-    if (source_rc (Muttrc, &err) != 0)
+    if (source_rc (muttrc, &err) != 0)
     {
       fputs (err.data, stderr);
       fputc ('\n', stderr);
       need_pause = 1;
     }
+
+    FREE (&muttrc);
   }
 
   if (mutt_execute_commands (commands) != 0)
diff --git a/main.c b/main.c
index 25b1d04..709f2b2 100644
--- a/main.c
+++ b/main.c
@@ -578,6 +578,7 @@ 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;
@@ -653,8 +654,8 @@ int main (int argc, char **argv)
        break;
 
       case 'F':
-       mutt_str_replace (&Muttrc, optarg);
-       break;
+        muttrc = safe_strdup (optarg);
+        break;
 
       case 'f':
        strfcpy (folder, optarg, sizeof (folder));
@@ -800,8 +801,9 @@ int main (int argc, char **argv)
   }
 
   /* set defaults and read init files */
-  mutt_init (flags & MUTT_NOSYSRC, commands);
+  mutt_init (flags & MUTT_NOSYSRC, commands, muttrc);
   mutt_free_list (&commands);
+  FREE (&muttrc);
 
   /* Initialize crypto backends.  */
   crypt_init ();
diff --git a/mutt.h b/mutt.h
index 6339613..64e4fa5 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 *);
+void mutt_init (int, LIST *, const char *muttrc);
 
 typedef struct alias
 {
-- 
2.10.2

Reply via email to