]> granicus.if.org Git - mutt/commitdiff
Use nl_langinfo's return value as the default for $charset.
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 16 May 2000 16:10:05 +0000 (16:10 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 16 May 2000 16:10:05 +0000 (16:10 +0000)
acconfig.h
configure.in
init.c
init.h

index 8c93576d762e12cd633184d1c2e3185826019f59..23fe41952ae6cbe7d969b7483557b1102b8aca9d 100644 (file)
 /* Define if we are using the system's wchar_t functions. */
 #undef HAVE_WC_FUNCS
 
+/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+#undef HAVE_LANGINFO_CODESET
+
   
index 9d6afb364e9ea3f530476dcd45b8fbf742058ff5..c9eb4e7627d26f7fb8d5e23ed98ab35a8e73b3f9 100644 (file)
@@ -780,6 +780,15 @@ if test $wc_funcs = yes; then
        AC_DEFINE(HAVE_WC_FUNCS)
 fi
 
+AC_CACHE_CHECK([for nl_langinfo and CODESET], mutt_cv_langinfo_codeset,
+  [AC_TRY_LINK([#include <langinfo.h>],
+    [char* cs = nl_langinfo(CODESET);],
+    mutt_cv_langinfo_codeset=yes,
+    mutt_cv_langinfo_codeset=no)])
+if test $mutt_cv_langinfo_codeset = yes; then
+  AC_DEFINE(HAVE_LANGINFO_CODESET)
+fi
+
 AC_OUTPUT(Makefile intl/Makefile m4/Makefile dnl
        po/Makefile.in doc/Makefile contrib/Makefile dnl
        muttbug.sh dnl
diff --git a/init.c b/init.c
index 1b41413778a342b6a077d4cabbfb9b0bb8986265..0da5cae520c59b4e32d05b36eea66564fa554bc2 100644 (file)
--- a/init.c
+++ b/init.c
 #include <errno.h>
 #include <sys/wait.h>
 
+#ifdef HAVE_LANGINFO_CODESET
+#include <langinfo.h>
+#endif
+
 void toggle_quadoption (int opt)
 {
   int n = opt/4;
@@ -919,7 +923,8 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
         else if (DTYPE (MuttVars[idx].type) == DT_STR)
         {
          *((char **) MuttVars[idx].data) = safe_strdup (tmp->data);
-         mutt_set_charset (Charset);
+         if (mutt_strcmp (MuttVars[idx].option, "charset") == 0)
+           mutt_set_charset (Charset);
         }
         else
         {
@@ -1809,6 +1814,15 @@ void mutt_init (int skip_sys_rc, LIST *commands)
     FREE (&token.data);
   }
 
+#ifdef HAVE_LANGINFO_CODESET
+  Charset = safe_strdup (nl_langinfo (CODESET));
+#else
+  Charset = safe_strdup ("iso-8859-1");
+#endif
+
+  mutt_set_charset (Charset);
+  
+  
   /* Set standard defaults */
   for (i = 0; MuttVars[i].option; i++)
   {
@@ -1818,6 +1832,7 @@ void mutt_init (int skip_sys_rc, LIST *commands)
 
   CurrentMenu = MENU_MAIN;
 
+
 #ifndef LOCALES_HACK
   /* Do we have a locale definition? */
   if (((p = getenv ("LC_ALL")) != NULL && p[0]) ||
diff --git a/init.h b/init.h
index c7401be35970f6ccd0941fdd6c6970f667cade2b..9e50946884e37169c401f8e42115dd28cb56acbb 100644 (file)
--- a/init.h
+++ b/init.h
@@ -261,7 +261,7 @@ struct option_t MuttVars[] = {
   ** When this variable is set, mutt will include Delivered-To headers when
   ** bouncing messages.  Postfix users may wish to unset this variable.
   */
-  { "charset",         DT_STR,  R_NONE, UL &Charset, UL "iso-8859-1" },
+  { "charset",         DT_STR,  R_NONE, UL &Charset, UL 0 },
   /*
   ** .pp
   ** Character set your terminal uses to display and enter textual data.