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
This commit is contained in:
David Lawrence Ramsey 2007-05-25 14:39:40 +00:00
parent bc65313104
commit a78b4354bb
3 changed files with 13 additions and 6 deletions

View File

@ -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

View File

@ -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([

View File

@ -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