Hello Mark,
appended is a patch inluding configure checks for Debian bug report "less: does not properly detect UTF-8 locales",
URL http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=226023
Maybe you could include this in the next release of less.
Thanks! Thomas
--- Begin Message ---Hello Thomas,appended you find a new version of my patch. On Debian systems it is functionally identical to my previously sent patch, but the new version includes addional checks in the configure script to make it safe on non-Debian systems. Usage: 1) apply the appended patch 2) install the autoconf package and rerun autoheader and autoconf in the less source directory once (autoconf is NOT needed as a build-dependency) 3) rebuild the package I hope this helps, Jochen -- http://seehuhn.de/diff -ur less-382.orig/charset.c less-382/charset.c --- less-382.orig/charset.c 2004-02-04 04:52:26.000000000 +0000 +++ less-382/charset.c 2005-01-08 22:29:17.000000000 +0000 @@ -19,6 +19,9 @@ #include <locale.h> #include <ctype.h> #endif +#if HAVE_LANGINFO_H +#include <langinfo.h> +#endif public int utf_mode = 0; @@ -219,6 +222,28 @@ /* * Initialize charset data structures. */ + +#if HAVE_NL_LANGINFO + static int +utf8_encoding_used() +/* taken from the GNU libc manual */ +{ + char *old_locale, *saved_locale; + int res; + + old_locale = setlocale (LC_CTYPE, NULL); /* save old locale */ + saved_locale = strdup (old_locale); + setlocale (LC_CTYPE, ""); /* set locale from environment */ + + res = (strcmp (nl_langinfo (CODESET), "UTF-8") == 0); + + setlocale (LC_CTYPE, saved_locale); /* restore old locale */ + free (saved_locale); + + return res; +} +#endif + public void init_charset() { @@ -243,6 +268,16 @@ return; } +#if HAVE_NL_LANGINFO + /* + * Check whether UTF-8 is used. + */ + if (utf8_encoding_used ()) { + if (icharset("utf-8")) + return; + } +#endif + #if HAVE_STRSTR /* * Check whether LC_ALL, LC_CTYPE or LANG look like UTF-8 is used. diff -ur less-382.orig/configure.ac less-382/configure.ac --- less-382.orig/configure.ac 2004-02-04 04:52:26.000000000 +0000 +++ less-382/configure.ac 2005-01-08 21:59:40.000000000 +0000 @@ -140,7 +140,7 @@ # Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS([ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h sys/ptem.h]) +AC_CHECK_HEADERS([ctype.h errno.h fcntl.h langinfo.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h sys/ptem.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STAT @@ -211,7 +211,7 @@ # Checks for library functions. AC_TYPE_SIGNAL -AC_CHECK_FUNCS([fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr strstr system]) +AC_CHECK_FUNCS([fsync memcpy nl_langinfo popen _setjmp sigprocmask sigsetmask stat strchr strstr system]) # Some systems have termios.h but not the corresponding functions. AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
signature.asc
Description: Digital signature
--- End Message ---