From: Thomas Roessler Date: Tue, 16 May 2000 16:10:05 +0000 (+0000) Subject: Use nl_langinfo's return value as the default for $charset. X-Git-Tag: mutt-1-3-1-rel~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7639ef4c8ace8948ec5ce3baad9dbe9103f64c89;p=mutt Use nl_langinfo's return value as the default for $charset. --- 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 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 ], + [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 #include +#ifdef HAVE_LANGINFO_CODESET +#include +#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.