commit b300af3f6356d80b30e225e581e58eabc37190e6
parent 30d0a816560100c46aabe78fbed959c94f2e11f7
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Mon, 13 Jun 2005 15:56:29 +0000
simplify is_valid_mbstring() by making it use mbstowcs()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2651 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
3 files changed, 8 insertions(+), 17 deletions(-)
diff --git 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
@@ -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
@@ -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 */