diff --git a/ChangeLog b/ChangeLog index 71ece1b2725919aaa583262391b26144fcd4f43b..2a3da4c126d048a33a54a4e0e06b915512da8187 100644 --- a/ChangeLog +++ b/ChangeLog @@ -250,7 +250,7 @@ CVS code - Weinehall) - Don't refer to the built-in file browser as crappy anymore. (DLR) - - Check for iswpunct(). (DLR) + - Check for iswpunct() and mbstowcs(). (DLR) - doc/faq.html: - Update the question about the FAQ to mention the current maintainer. (DLR) diff --git a/configure.ac b/configure.ac index ccbc9c36378d5cc911b7dc499c8a7daec91c72f1..2df63185c71003fb96b8e06cabeec221dc28ebb7 100644 --- a/configure.ac +++ b/configure.ac @@ -399,7 +399,7 @@ dnl Checks for functions. AC_CHECK_FUNCS(snprintf vsnprintf isblank strcasecmp strncasecmp strcasestr strnlen getline getdelim) if test x$enable_utf8 != xno; then - AC_CHECK_FUNCS(iswalnum iswblank iswpunct iswspace mblen mbtowc wctomb wcwidth) + AC_CHECK_FUNCS(iswalnum iswblank iswpunct iswspace mblen mbstowcs mbtowc wctomb wcwidth) fi if test x$ac_cv_func_snprintf = xno || test x$ac_cv_func_vsnprintf = xno; then @@ -475,10 +475,11 @@ if test x$enable_utf8 != xno && \ 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_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(NANO_WIDE, 1, [Define this if your system has sufficient wide character support (a wide curses library, iswalnum(), iswpunct(), iswblank() or iswspace(), mblen(), mbtowc(), wctomb(), and wcwidth()).]) + AC_DEFINE(NANO_WIDE, 1, [Define this if your system has sufficient wide character support (a wide curses library, iswalnum(), iswpunct(), iswblank() or iswspace(), mblen(), mbstowcs(), mbtowc(), wctomb(), and wcwidth()).]) else if test x$enable_utf8 = xyes; then AC_MSG_ERROR([ diff --git a/src/chars.c b/src/chars.c index bd2f0d577b8ffbae9f0009ef2ae6cbb4dbb5b7be..34712dc75140d1331a7eb9f9a7fd5ea2f66092ae 100644 --- a/src/chars.c +++ b/src/chars.c @@ -285,23 +285,13 @@ bool is_valid_mbstring(const char *str) { assert(str != NULL); + return #ifdef NANO_WIDE - if (!ISSET(NO_UTF8)) { - while (*str != '\0') { - int chr_mb_len; - bool bad_chr; - - chr_mb_len = parse_mbchar(str, NULL, &bad_chr, NULL); - - if (bad_chr) - return FALSE; - - str += chr_mb_len; - } - } + (!ISSET(NO_UTF8)) ? + (mbstowcs(NULL, str, (size_t)-1) != (size_t)-1) : #endif - return TRUE; + TRUE; } #endif /* ENABLE_NANORC */