summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--acconfig.h3
-rw-r--r--configure.in9
-rw-r--r--init.c17
-rw-r--r--init.h2
4 files changed, 29 insertions, 2 deletions
diff --git a/acconfig.h b/acconfig.h
index 8c93576d..23fe4195 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -192,4 +192,7 @@
/* 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
+
diff --git a/configure.in b/configure.in
index 9d6afb36..c9eb4e76 100644
--- a/configure.in
+++ b/configure.in
@@ -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 1b414137..0da5cae5 100644
--- a/init.c
+++ b/init.c
@@ -51,6 +51,10 @@
#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 c7401be3..9e509468 100644
--- 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.