Now that we have a wctype module we can simplify some of the other modules to just include <wctype.h> and depend on the wctype module. Here is a proposed patch.
2006-12-21 Paul Eggert <[EMAIL PROTECTED]> * lib/mbchar.h: Just include <wctype.h>; the wctype module handles its gotchas now. * lib/mbswidth.c: Likewise. * lib/wcwidth.h: Likewise. * m4/mbchar.m4 (gl_MBCHAR): Don't bother checking for wctype.h and iswcntrl; the wctype module does this stuff now. * m4/mbswidth.m4 (gl_MBSWIDTH): Likewise. * m4/wcwidth.m4 (gl_FUNC_WCWIDTH): Likewise. * modules/mbchar (Depends-on): Add wctype. * modules/mbswidth (Depends-on): Likewise. * modules/wcwidth (Depends-on): Likewise. Index: lib/mbchar.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/mbchar.h,v retrieving revision 1.9 diff -u -p -r1.9 mbchar.h --- lib/mbchar.h 31 Oct 2006 19:18:54 -0000 1.9 +++ lib/mbchar.h 22 Dec 2006 00:33:03 -0000 @@ -155,132 +155,7 @@ #include <stdio.h> #include <time.h> #include <wchar.h> - -/* BeOS 5 has the functions but no <wctype.h>. */ -#if HAVE_WCTYPE_H -# include <wctype.h> -#endif -/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions. - Assume all 12 functions are implemented the same way, or not at all. */ -#if !defined iswalnum && !HAVE_ISWCNTRL -static inline int -iswalnum (wint_t wc) -{ - return (wc >= 0 && wc < 128 - ? (wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z') - : 0); -} -# define iswalnum iswalnum -#endif -#if !defined iswalpha && !HAVE_ISWCNTRL -static inline int -iswalpha (wint_t wc) -{ - return (wc >= 0 && wc < 128 - ? (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z' - : 0); -} -# define iswalpha iswalpha -#endif -#if !defined iswblank && !HAVE_ISWCNTRL -static inline int -iswblank (wint_t wc) -{ - return (wc >= 0 && wc < 128 - ? wc == ' ' || wc == '\t' - : 0); -} -# define iswblank iswblank -#endif -#if !defined iswcntrl && !HAVE_ISWCNTRL -static inline int -iswcntrl (wint_t wc) -{ - return (wc >= 0 && wc < 128 - ? (wc & ~0x1f) == 0 || wc == 0x7f - : 0); -} -# define iswcntrl iswcntrl -#endif -#if !defined iswdigit && !HAVE_ISWCNTRL -static inline int -iswdigit (wint_t wc) -{ - return (wc >= '0' && wc <= '9'); -} -# define iswdigit iswdigit -#endif -#if !defined iswgraph && !HAVE_ISWCNTRL -static inline int -iswgraph (wint_t wc) -{ - return (wc >= 0 && wc < 128 - ? wc >= '!' && wc <= '~' - : 1); -} -# define iswgraph iswgraph -#endif -#if !defined iswlower && !HAVE_ISWCNTRL -static inline int -iswlower (wint_t wc) -{ - return (wc >= 0 && wc < 128 - ? wc >= 'a' && wc <= 'z' - : 0); -} -# define iswlower iswlower -#endif -#if !defined iswprint && !HAVE_ISWCNTRL -static inline int -iswprint (wint_t wc) -{ - return (wc >= 0 && wc < 128 - ? wc >= ' ' && wc <= '~' - : 1); -} -# define iswprint iswprint -#endif -#if !defined iswpunct && !HAVE_ISWCNTRL -static inline int -iswpunct (wint_t wc) -{ - return (wc >= 0 && wc < 128 - ? wc >= '!' && wc <= '~' - && !((wc >= '0' && wc <= '9') - || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')) - : 1); -} -# define iswpunct iswpunct -#endif -#if !defined iswspace && !HAVE_ISWCNTRL -static inline int -iswspace (wint_t wc) -{ - return (wc >= 0 && wc < 128 - ? wc == ' ' || wc == '\t' - || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r' - : 0); -} -# define iswspace iswspace -#endif -#if !defined iswupper && !HAVE_ISWCNTRL -static inline int -iswupper (wint_t wc) -{ - return (wc >= 0 && wc < 128 - ? wc >= 'A' && wc <= 'Z' - : 0); -} -# define iswupper iswupper -#endif -#if !defined iswxdigit && !HAVE_ISWCNTRL -static inline int -iswxdigit (wint_t wc) -{ - return (wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'); -} -# define iswxdigit iswxdigit -#endif +#include <wctype.h> #include "wcwidth.h" Index: lib/mbswidth.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/mbswidth.c,v retrieving revision 1.19 diff -u -p -r1.19 mbswidth.c --- lib/mbswidth.c 14 Sep 2006 14:18:36 -0000 1.19 +++ lib/mbswidth.c 22 Dec 2006 00:33:03 -0000 @@ -45,12 +45,7 @@ #include "wcwidth.h" /* Get iswcntrl(). */ -#if HAVE_WCTYPE_H -# include <wctype.h> -#endif -#if !defined iswcntrl && !HAVE_ISWCNTRL -# define iswcntrl(wc) (((wc) & ~0x1f) == 0 || (wc) == 0x7f) -#endif +#include <wctype.h> #ifndef mbsinit # if !HAVE_MBSINIT Index: lib/wcwidth.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/wcwidth.h,v retrieving revision 1.6 diff -u -p -r1.6 wcwidth.h --- lib/wcwidth.h 24 Oct 2006 20:19:49 -0000 1.6 +++ lib/wcwidth.h 22 Dec 2006 00:33:03 -0000 @@ -32,23 +32,7 @@ # endif /* Get iswprint. */ -# if HAVE_WCTYPE_H -# include <wctype.h> -# endif -# if !defined iswprint && !HAVE_ISWPRINT -static inline int -# if HAVE_WINT_T -iswprint (wint_t wc) -# else -iswprint (int wc) -# endif -{ - return (wc >= 0 && wc < 128 - ? wc >= ' ' && wc <= '~' - : 1); -} -# define iswprint iswprint -# endif +# include <wctype.h> # ifndef HAVE_DECL_WCWIDTH "this configure-time declaration test was not run" Index: m4/mbchar.m4 =================================================================== RCS file: /cvsroot/gnulib/gnulib/m4/mbchar.m4,v retrieving revision 1.4 diff -u -p -r1.4 mbchar.m4 --- m4/mbchar.m4 21 Aug 2006 18:28:02 -0000 1.4 +++ m4/mbchar.m4 22 Dec 2006 00:33:03 -0000 @@ -16,8 +16,5 @@ AC_DEFUN([gl_MBCHAR], dnl Compile mbchar.c only if HAVE_WCHAR_H. if test $ac_cv_header_wchar_h = yes; then AC_LIBOBJ([mbchar]) - dnl Prerequisites of mbchar.h and mbchar.c. - AC_CHECK_HEADERS_ONCE([wctype.h]) - AC_CHECK_FUNCS([iswcntrl]) fi ]) Index: m4/mbswidth.m4 =================================================================== RCS file: /cvsroot/gnulib/gnulib/m4/mbswidth.m4,v retrieving revision 1.16 diff -u -p -r1.16 mbswidth.m4 --- m4/mbswidth.m4 22 Sep 2006 20:10:26 -0000 1.16 +++ m4/mbswidth.m4 22 Dec 2006 00:33:03 -0000 @@ -9,9 +9,8 @@ dnl From Bruno Haible. AC_DEFUN([gl_MBSWIDTH], [ - AC_CHECK_HEADERS_ONCE([wchar.h wctype.h]) + AC_CHECK_HEADERS_ONCE([wchar.h]) AC_CHECK_FUNCS_ONCE([isascii mbsinit]) - AC_CHECK_FUNCS([iswcntrl]) gl_FUNC_MBRTOWC dnl UnixWare 7.1.1 <wchar.h> has a declaration of a function mbswidth() Index: m4/wcwidth.m4 =================================================================== RCS file: /cvsroot/gnulib/gnulib/m4/wcwidth.m4,v retrieving revision 1.6 diff -u -p -r1.6 wcwidth.m4 --- m4/wcwidth.m4 24 Oct 2006 20:19:49 -0000 1.6 +++ m4/wcwidth.m4 22 Dec 2006 00:33:03 -0000 @@ -13,8 +13,8 @@ AC_DEFUN([gl_FUNC_WCWIDTH], AC_REQUIRE([gt_TYPE_WCHAR_T]) AC_REQUIRE([gt_TYPE_WINT_T]) - AC_CHECK_HEADERS_ONCE([wchar.h wctype.h]) - AC_CHECK_FUNCS_ONCE([iswprint wcwidth]) + AC_CHECK_HEADERS_ONCE([wchar.h]) + AC_CHECK_FUNCS_ONCE([wcwidth]) AC_CHECK_DECLS([wcwidth], [], [], [ /* AIX 3.2.5 declares wcwidth in <string.h>. */ Index: modules/mbchar =================================================================== RCS file: /cvsroot/gnulib/gnulib/modules/mbchar,v retrieving revision 1.6 diff -u -p -r1.6 mbchar --- modules/mbchar 13 Oct 2006 12:40:23 -0000 1.6 +++ modules/mbchar 22 Dec 2006 00:33:03 -0000 @@ -8,6 +8,7 @@ m4/mbchar.m4 Depends-on: stdbool +wctype wcwidth configure.ac: @@ -25,4 +26,3 @@ LGPL Maintainer: Bruno Haible - Index: modules/mbswidth =================================================================== RCS file: /cvsroot/gnulib/gnulib/modules/mbswidth,v retrieving revision 1.5 diff -u -p -r1.5 mbswidth --- modules/mbswidth 28 Jun 2006 13:11:32 -0000 1.5 +++ modules/mbswidth 22 Dec 2006 00:33:03 -0000 @@ -9,6 +9,7 @@ m4/mbrtowc.m4 m4/mbswidth.m4 Depends-on: +wctype wcwidth configure.ac: @@ -25,4 +26,3 @@ GPL Maintainer: Bruno Haible - Index: modules/wcwidth =================================================================== RCS file: /cvsroot/gnulib/gnulib/modules/wcwidth,v retrieving revision 1.4 diff -u -p -r1.4 wcwidth --- modules/wcwidth 24 Oct 2006 20:19:49 -0000 1.4 +++ modules/wcwidth 22 Dec 2006 00:33:03 -0000 @@ -8,6 +8,7 @@ m4/wchar_t.m4 m4/wint_t.m4 Depends-on: +wctype configure.ac: gl_FUNC_WCWIDTH