diff --git a/ChangeLog b/ChangeLog index cbc39225660547b705be710428e395344d96d5f4..9164cb74d80f26449436a2d4a0e82fcd2ff46b0d 100644 --- 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 index f3d104b11ad424ca021a05a5bcf57f3e9a0667e3..9720485debcfc8d1c2410ed32cd2fd4c4c0aad76 100644 --- 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 index fe0dcbfdf5c533974c138ff81e3926469ac9cc04..6eeeadb7b746a8b48a2e718b409381365a81928b 100644 --- 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