]> granicus.if.org Git - neomutt/commitdiff
refactor: init_locale()
authorRichard Russon <rich@flatcap.org>
Sat, 5 May 2018 15:20:59 +0000 (16:20 +0100)
committerRichard Russon <rich@flatcap.org>
Sat, 5 May 2018 15:20:59 +0000 (16:20 +0100)
init.c
main.c

diff --git a/init.c b/init.c
index 54182207aaea3ed8c9917f965a92a827dc8787a6..96ae1886cb8e0e1c01336a3b5e18afac6ddf6155 100644 (file)
--- a/init.c
+++ b/init.c
@@ -3955,15 +3955,6 @@ int mutt_init(int skip_sys_rc, struct ListHead *commands)
 
   CurrentMenu = MENU_MAIN;
 
-#ifndef LOCALES_HACK
-  /* Do we have a locale definition? */
-  if ((p = mutt_str_getenv("LC_ALL")) || (p = mutt_str_getenv("LANG")) ||
-      (p = mutt_str_getenv("LC_CTYPE")))
-  {
-    OptLocales = true;
-  }
-#endif
-
 #ifdef HAVE_GETSID
   /* Unset suspend by default if we're the session leader */
   if (getsid(0) == getpid())
diff --git a/main.c b/main.c
index 35af68b0151857eaa9ac44a66c7d4232434f7e60..90e8045134c8802d2e24a48105a58b49c5a656a1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -206,6 +206,32 @@ static int start_curses(void)
 #define MUTT_NEWS (1 << 5) /* -g and -G */
 #endif
 
+/**
+ * init_locale - Initialise the Locale/NLS settings
+ */
+void init_locale(void)
+{
+  setlocale(LC_ALL, "");
+
+#ifdef ENABLE_NLS
+  const char *domdir = mutt_str_getenv("TEXTDOMAINDIR");
+  if (domdir)
+    bindtextdomain(PACKAGE, domdir);
+  else
+    bindtextdomain(PACKAGE, MUTTLOCALEDIR);
+  textdomain(PACKAGE);
+#endif
+#ifndef LOCALES_HACK
+  const char *p = NULL;
+  /* Do we have a locale definition? */
+  if ((p = mutt_str_getenv("LC_ALL")) || (p = mutt_str_getenv("LANG")) ||
+      (p = mutt_str_getenv("LC_CTYPE")))
+  {
+    OptLocales = true;
+  }
+#endif
+}
+
 /**
  * get_user_info - Find the user's name, home and shell
  * @retval 0 Success
@@ -304,19 +330,7 @@ int main(int argc, char *argv[], char *envp[])
     goto main_exit; // TEST01: neomutt (as root, chgrp mail neomutt; chmod +s neomutt)
   }
 
-  setlocale(LC_ALL, "");
-
-#ifdef ENABLE_NLS
-  /* FIXME what about the LOCALES_HACK in mutt_init() [init.c] ? */
-  {
-    const char *domdir = mutt_str_getenv("TEXTDOMAINDIR");
-    if (domdir)
-      bindtextdomain(PACKAGE, domdir);
-    else
-      bindtextdomain(PACKAGE, MUTTLOCALEDIR);
-    textdomain(PACKAGE);
-  }
-#endif
+  init_locale();
 
   int out = 0;
   if (mutt_randbuf(&out, sizeof(out)) < 0)