commit c41e16da608dfdf77eea904832f96005b585172f
parent 8be2da2f6edf19d900ed68034c000d877e941327
Author: ukai <ukai>
Date: Wed, 13 Oct 2004 16:52:49 +0000
Bug#276246: w3m's locale parsing should at least see '@euro' modifier
* config.h (HAVE_LANGINFO_CODESET): added
* configure.in (AM_LANGINFO_CODESET): added
* libwc/charset.c: #include <langinfo.h>
(wc_charset_to_ces): use nl_langinfo(CODESET)
From: Fumitoshi UKAI <ukai@debian.or.jp>
Diffstat:
5 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,11 @@
+2004-10-14 Fumitoshi UKAI <ukai@debian.or.jp>
+
+ * Bug#276246: w3m's locale parsing should at least see '@euro' modifier
+ * config.h (HAVE_LANGINFO_CODESET): added
+ * configure.in (AM_LANGINFO_CODESET): added
+ * libwc/charset.c: #include <langinfo.h>
+ (wc_charset_to_ces): use nl_langinfo(CODESET)
+
2004-09-30 Hiroyuki Ito <ZXB01226@nifty.com>
* [w3m-dev 04108] PIPE_BUF
diff --git a/config.h.in b/config.h.in
@@ -142,6 +142,7 @@ typedef long clen_t;
#undef HAVE_CHDIR
#undef HAVE_SETPGRP
#undef HAVE_SETLOCALE
+#undef HAVE_LANGINFO_CODESET
#undef SETPGRP_VOID
#ifdef SETPGRP_VOID
diff --git a/configure b/configure
@@ -10007,6 +10007,69 @@ _ACEOF
fi
+ echo "$as_me:$LINENO: checking for nl_langinfo and CODESET" >&5
+echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6
+if test "${am_cv_langinfo_codeset+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <langinfo.h>
+int
+main ()
+{
+char* cs = nl_langinfo(CODESET);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ am_cv_langinfo_codeset=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+am_cv_langinfo_codeset=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:$LINENO: result: $am_cv_langinfo_codeset" >&5
+echo "${ECHO_T}$am_cv_langinfo_codeset" >&6
+ if test $am_cv_langinfo_codeset = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LANGINFO_CODESET 1
+_ACEOF
+
+ fi
+
+
echo "$as_me:$LINENO: checking for sys_errlist" >&5
echo $ECHO_N "checking for sys_errlist... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
diff --git a/configure.in b/configure.in
@@ -148,6 +148,7 @@ AC_CHECK_FUNCS(strcasecmp strcasestr strchr memcpy strerror bcopy setpgrp chdir
AC_FUNC_STRFTIME
AC_FUNC_WAIT3
AC_FUNC_SETPGRP
+AM_LANGINFO_CODESET
AC_W3M_SYS_ERRLIST
AC_W3M_SIGSETJMP
AC_W3M_SIGNAL
diff --git a/libwc/charset.c b/libwc/charset.c
@@ -6,6 +6,10 @@
#include "wc.h"
+#ifdef HAVE_LANGINFO_CODESET
+#include <langinfo.h>
+#endif
+
wc_locale WcLocale = 0;
static struct {
@@ -369,6 +373,12 @@ wc_locale_to_ces(char *locale)
if (*p == 'C' && *(p+1) == '\0')
return WC_CES_US_ASCII;
+#ifdef HAVE_LANGINFO_CODESET
+ {
+ char *cs = nl_langinfo(CODESET);
+ return wc_charset_to_ces(cs);
+ }
+#endif
for (n = 0; *p && *p != '.' && n < 5; p++) {
if ((unsigned char)*p > 0x20)
buf[n++] = tolower(*p);