commit a78b4354bbcf68b6f4701af0096dbf89a90d7e28
parent bc6531310423bee8baf8e8a0a98a78f3062f0883
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Fri, 25 May 2007 14:39:40 +0000
replace the current hackish check for a UTF-8 locale with a proper call
to nl_langinfo()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4110 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,8 @@
+2007-05-25 David Lawrence Ramsey <pooka109@gmail.com>
+
+ * configure.ac, nano.c (main): Replace the current hackish check
+ for a UTF-8 locale with a proper call to nl_langinfo().
+
2007-05-22 David Lawrence Ramsey <pooka109@gmail.com>
* browser.c (do_browser), nano.c (do_mouse), prompt.c
diff --git a/configure.ac b/configure.ac
@@ -379,7 +379,7 @@ dnl Checks for functions.
AC_CHECK_FUNCS(getdelim getline isblank strcasecmp strcasestr strncasecmp strnlen vsnprintf)
if test x$enable_utf8 != xno; then
- AC_CHECK_FUNCS(iswalnum iswblank iswpunct iswspace mblen mbstowcs mbtowc wctomb wcwidth)
+ AC_CHECK_FUNCS(iswalnum iswblank iswpunct iswspace nl_langinfo mblen mbstowcs mbtowc wctomb wcwidth)
fi
if test x$ac_cv_func_vsnprintf = xno; then
@@ -453,12 +453,13 @@ if test x$enable_utf8 != xno && \
test x$ac_cv_func_iswalnum = xyes && \
test x$ac_cv_func_iswpunct = xyes && \
(test x$ac_cv_func_iswblank = xyes || test x$ac_cv_func_iswspace = xyes) && \
+ test x$ac_cv_func_nl_langinfo = xyes && \
test x$ac_cv_func_mblen = xyes && \
test x$ac_cv_func_mbstowcs = xyes && \
test x$ac_cv_func_mbtowc = xyes && \
test x$ac_cv_func_wctomb = xyes && \
test x$ac_cv_func_wcwidth = xyes; then
- AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support (a wide curses library, iswalnum(), iswpunct(), iswblank() or iswspace(), mblen(), mbstowcs(), mbtowc(), wctomb(), and wcwidth()).])
+ AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support (a wide curses library, iswalnum(), iswpunct(), iswblank() or iswspace(), nl_langinfo, mblen(), mbstowcs(), mbtowc(), wctomb(), and wcwidth()).])
else
if test x$enable_utf8 = xyes; then
AC_MSG_ERROR([
diff --git a/src/nano.c b/src/nano.c
@@ -32,6 +32,7 @@
#include <errno.h>
#include <ctype.h>
#include <locale.h>
+#include <langinfo.h>
#include <termios.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
@@ -1725,12 +1726,12 @@ int main(int argc, char **argv)
#ifdef ENABLE_UTF8
{
- /* If the locale set exists and includes the case-insensitive
- * string "UTF8" or "UTF-8", we should use UTF-8. */
+ /* If the locale set exists and uses UTF-8, we should use
+ * UTF-8. */
char *locale = setlocale(LC_ALL, "");
- if (locale != NULL && (strcasestr(locale, "UTF8") != NULL ||
- strcasestr(locale, "UTF-8") != NULL)) {
+ if (locale != NULL && (strcmp(nl_langinfo(CODESET),
+ "UTF-8") == 0)) {
#ifdef USE_SLANG
SLutf8_enable(1);
#endif