From 0224757f8cde66d8224107dbb30a81c3d4a5f9e6 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 6 Feb 2011 23:18:30 +0100 Subject: [PATCH] wctype-h: Ensure wctype_t and wctrans_t are defined. * lib/wctype.in.h (wctype_t, wctrans_t): New type declarations. * m4/wctype_h.m4 (gl_WCTYPE_H): Determine HAVE_WCTYPE_T, HAVE_WCTRANS_T. (gl_WCTYPE_H_DEFAULTS): Initialize HAVE_WCTYPE_T, HAVE_WCTRANS_T. * modules/wctype-h (Makefile.am): Substitute HAVE_WCTYPE_T, HAVE_WCTRANS_T. * tests/test-wctype-h.c: Check that wctype_t and wctrans_t are defined. --- ChangeLog | 10 +++++++++ lib/wctype.in.h | 14 +++++++++++++ m4/wctype_h.m4 | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++- modules/wctype-h | 2 ++ tests/test-wctype-h.c | 6 ++++++ 5 files changed, 87 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d1ba7a646..fec236bd4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-02-06 Bruno Haible + + wctype-h: Ensure wctype_t and wctrans_t are defined. + * lib/wctype.in.h (wctype_t, wctrans_t): New type declarations. + * m4/wctype_h.m4 (gl_WCTYPE_H): Determine HAVE_WCTYPE_T, HAVE_WCTRANS_T. + (gl_WCTYPE_H_DEFAULTS): Initialize HAVE_WCTYPE_T, HAVE_WCTRANS_T. + * modules/wctype-h (Makefile.am): Substitute HAVE_WCTYPE_T, + HAVE_WCTRANS_T. + * tests/test-wctype-h.c: Check that wctype_t and wctrans_t are defined. + 2011-02-09 Paul Eggert flock: fix license typo diff --git a/lib/wctype.in.h b/lib/wctype.in.h index 00df21389..f72991aa4 100644 --- a/lib/wctype.in.h +++ b/lib/wctype.in.h @@ -377,6 +377,13 @@ _GL_CXXALIAS_SYS (iswblank, int, (wint_t wc)); _GL_CXXALIASWARN (iswblank); #endif +#if !@HAVE_WCTYPE_T@ +# if !GNULIB_defined_wctype_t +typedef void * wctype_t; +# define GNULIB_defined_wctype_t 1 +# endif +#endif + #if @REPLACE_ISWCNTRL@ || defined __MINGW32__ _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc)); _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc)); @@ -387,6 +394,13 @@ _GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc)); _GL_CXXALIASWARN (towlower); _GL_CXXALIASWARN (towupper); +#if !@HAVE_WCTRANS_T@ +# if !GNULIB_defined_wctrans_t +typedef void * wctrans_t; +# define GNULIB_defined_wctrans_t 1 +# endif +#endif + #endif /* _GL_WCTYPE_H */ #endif /* _GL_WCTYPE_H */ diff --git a/m4/wctype_h.m4 b/m4/wctype_h.m4 index c667fee9f..307d5e1be 100644 --- a/m4/wctype_h.m4 +++ b/m4/wctype_h.m4 @@ -1,4 +1,4 @@ -# wctype_h.m4 serial 13 +# wctype_h.m4 serial 14 dnl A placeholder for ISO C99 , for platforms that lack it. @@ -78,6 +78,58 @@ AC_DEFUN([gl_WCTYPE_H], dnl Redefine all of iswcntrl, ..., towupper in . : fi + + dnl We assume that the wctype() and iswctype() functions exist if and only + dnl if the type wctype_t is defined in or in if that + dnl exists. + dnl HP-UX 11.00 declares all these in and lacks . + AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[/* Tru64 with Desktop Toolkit C has a bug: must be + included before . + BSD/OS 4.0.1 has a bug: , and + must be included before . */ + #include + #include + #include + #include + #if HAVE_WCTYPE_H + # include + #endif + wctype_t a; + ]], + [[]])], + [gl_cv_type_wctype_t=yes], + [gl_cv_type_wctype_t=no]) + ]) + if test $gl_cv_type_wctype_t = no; then + HAVE_WCTYPE_T=0 + fi + + dnl We assume that the wctrans() and towctrans() functions exist if and only + dnl if the type wctrans_t is defined in . + AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[/* Tru64 with Desktop Toolkit C has a bug: must be + included before . + BSD/OS 4.0.1 has a bug: , and + must be included before . */ + #include + #include + #include + #include + #include + wctrans_t a; + ]], + [[]])], + [gl_cv_type_wctrans_t=yes], + [gl_cv_type_wctrans_t=no]) + ]) + if test $gl_cv_type_wctrans_t = no; then + HAVE_WCTRANS_T=0 + fi ]) AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR], @@ -94,5 +146,7 @@ AC_DEFUN([gl_WCTYPE_H_DEFAULTS], GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK]) + HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T]) + HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T]) REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK]) ]) diff --git a/modules/wctype-h b/modules/wctype-h index d1e36e3ef..d6499c7bb 100644 --- a/modules/wctype-h +++ b/modules/wctype-h @@ -30,6 +30,8 @@ wctype.h: wctype.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) -e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \ -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \ -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \ + -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \ + -e 's/@''HAVE_WCTRANS_T''@/$(HAVE_WCTRANS_T)/g' \ -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \ -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \ diff --git a/tests/test-wctype-h.c b/tests/test-wctype-h.c index 0fe4a7748..aed3b772f 100644 --- a/tests/test-wctype-h.c +++ b/tests/test-wctype-h.c @@ -27,6 +27,12 @@ wint_t a = 'x'; /* Check that WEOF is defined. */ wint_t e = WEOF; +/* Check that the type wctype_t is defined. */ +wctype_t p; + +/* Check that the type wctrans_t is defined. */ +wctrans_t q; + int main (void) { -- 2.11.0