mirror of git://git.sv.gnu.org/nano.git
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
This commit is contained in:
parent
30d0a81656
commit
b300af3f63
|
@ -250,7 +250,7 @@ CVS code -
|
||||||
Weinehall)
|
Weinehall)
|
||||||
- Don't refer to the built-in file browser as crappy anymore.
|
- Don't refer to the built-in file browser as crappy anymore.
|
||||||
(DLR)
|
(DLR)
|
||||||
- Check for iswpunct(). (DLR)
|
- Check for iswpunct() and mbstowcs(). (DLR)
|
||||||
- doc/faq.html:
|
- doc/faq.html:
|
||||||
- Update the question about the FAQ to mention the current
|
- Update the question about the FAQ to mention the current
|
||||||
maintainer. (DLR)
|
maintainer. (DLR)
|
||||||
|
|
|
@ -399,7 +399,7 @@ dnl Checks for functions.
|
||||||
AC_CHECK_FUNCS(snprintf vsnprintf isblank strcasecmp strncasecmp strcasestr strnlen getline getdelim)
|
AC_CHECK_FUNCS(snprintf vsnprintf isblank strcasecmp strncasecmp strcasestr strnlen getline getdelim)
|
||||||
|
|
||||||
if test x$enable_utf8 != xno; then
|
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
|
fi
|
||||||
|
|
||||||
if test x$ac_cv_func_snprintf = xno || test x$ac_cv_func_vsnprintf = xno; then
|
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_iswpunct = xyes && \
|
||||||
(test x$ac_cv_func_iswblank = xyes || test x$ac_cv_func_iswspace = 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_mblen = xyes && \
|
||||||
|
test x$ac_cv_func_mbstowcs = xyes && \
|
||||||
test x$ac_cv_func_mbtowc = xyes && \
|
test x$ac_cv_func_mbtowc = xyes && \
|
||||||
test x$ac_cv_func_wctomb = xyes && \
|
test x$ac_cv_func_wctomb = xyes && \
|
||||||
test x$ac_cv_func_wcwidth = xyes; then
|
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
|
else
|
||||||
if test x$enable_utf8 = xyes; then
|
if test x$enable_utf8 = xyes; then
|
||||||
AC_MSG_ERROR([
|
AC_MSG_ERROR([
|
||||||
|
|
18
src/chars.c
18
src/chars.c
|
@ -285,23 +285,13 @@ bool is_valid_mbstring(const char *str)
|
||||||
{
|
{
|
||||||
assert(str != NULL);
|
assert(str != NULL);
|
||||||
|
|
||||||
|
return
|
||||||
#ifdef NANO_WIDE
|
#ifdef NANO_WIDE
|
||||||
if (!ISSET(NO_UTF8)) {
|
(!ISSET(NO_UTF8)) ?
|
||||||
while (*str != '\0') {
|
(mbstowcs(NULL, str, (size_t)-1) != (size_t)-1) :
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
TRUE;
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_NANORC */
|
#endif /* ENABLE_NANORC */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue