Commit 7639ef4c authored by Thomas Roessler's avatar Thomas Roessler

Use nl_langinfo's return value as the default for $charset.

parent 54de007b
......@@ -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
......@@ -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
......
......@@ -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]) ||
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment