commit 289d331fedc4119b1cb824e5055ec8090465ed38
parent a8f88632faa19b0f2d3cfa5d9e9bed88156d6dda
Author: inu <inu>
Date:   Wed, 23 May 2007 12:34:20 +0000
[w3m-dev 04240] nl_langinfo() requires setlocale()
Diffstat:
6 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,4 +1,10 @@
-2007-04-19  Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
+2007-05-23  Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
+
+	* [w3m-dev 04240] nl_langinfo() requires setlocale()
+	* fm.h, main.c, menu.c, rc.c: add "#ifdef"s.
+	* libwc/charset.c: add setlocale() for nl_langinfo().
+
+2007-05-23  Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
 
 	* [w3m-dev 03923] <pre> in <table>
 	* file.c, table.c: avoid extra blanks in pre in table.
diff --git a/fm.h b/fm.h
@@ -53,7 +53,7 @@ typedef int wc_ces;	/* XXX: not used */
 #define setlocale(category, locale)	/* empty */
 #endif
 
-#if ENABLE_NLS
+#ifdef ENABLE_NLS
 #include <libintl.h>
 #define _(String) gettext (String)
 #define N_(String) (String)
diff --git a/libwc/charset.c b/libwc/charset.c
@@ -376,7 +376,8 @@ wc_locale_to_ces(char *locale)
 #ifdef HAVE_LANGINFO_CODESET
     {
 	char *cs = nl_langinfo(CODESET);
-	return wc_charset_to_ces(cs);
+	if (cs && strcmp(cs, "US-ASCII"))
+	    return wc_charset_to_ces(cs);
     }
 #endif
     for (n = 0; *p && *p != '.' && n < 5; p++) {
diff --git a/main.c b/main.c
@@ -383,8 +383,10 @@ main(int argc, char **argv, char **envp)
 #endif
 #endif
     GC_init();
-#if ENABLE_NLS
+#if defined(ENABLE_NLS) || (defined(USE_M17N) && defined(HAVE_LANGINFO_CODESET))
     setlocale(LC_ALL, "");
+#endif
+#ifdef ENABLE_NLS
     bindtextdomain(PACKAGE, LOCALEDIR);
     textdomain(PACKAGE);
 #endif
diff --git a/menu.c b/menu.c
@@ -1711,7 +1711,7 @@ initMenu(void)
 #ifdef USE_M17N
     if (!MainMenuEncode) {
 	MenuItem *item;
-#if ENABLE_NLS
+#ifdef ENABLE_NLS
 	/* FIXME: charset that gettext(3) returns */
 	MainMenuCharset = SystemCharset;
 #endif
diff --git a/rc.c b/rc.c
@@ -790,9 +790,11 @@ show_params(FILE * fp)
     char *t = NULL;
     char *cmt;
 
-#if ENABLE_NLS
+#ifdef USE_M17N
+#ifdef ENABLE_NLS
     OptionCharset = SystemCharset;	/* FIXME */
 #endif
+#endif
 
     fputs("\nconfiguration parameters\n", fp);
     for (j = 0; sections[j].name != NULL; j++) {
@@ -1310,10 +1312,10 @@ load_option_panel(void)
     if (optionpanel_str == NULL)
 	optionpanel_str = Sprintf(optionpanel_src1, w3m_version,
 			      html_quote(localCookie()->ptr), _(CMT_HELPER));
-#if ENABLE_NLS
+#ifdef USE_M17N
+#ifdef ENABLE_NLS
     OptionCharset = SystemCharset;	/* FIXME */
 #endif
-#ifdef USE_M17N
     if (!OptionEncode) {
 	optionpanel_str =
 	    wc_Str_conv(optionpanel_str, OptionCharset, InnerCharset);