wctype-h: Ensure wctype_t and wctrans_t are defined.
authorBruno Haible <bruno@clisp.org>
Sun, 6 Feb 2011 22:18:30 +0000 (23:18 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 9 Feb 2011 19:54:31 +0000 (20:54 +0100)
* 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
lib/wctype.in.h
m4/wctype_h.m4
modules/wctype-h
tests/test-wctype-h.c

index d1ba7a6..fec236b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+       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  <eggert@cs.ucla.edu>
 
        flock: fix license typo
index 00df213..f72991a 100644 (file)
@@ -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 */
index c667fee..307d5e1 100644 (file)
@@ -1,4 +1,4 @@
-# wctype_h.m4 serial 13
+# wctype_h.m4 serial 14
 
 dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
 
@@ -78,6 +78,58 @@ AC_DEFUN([gl_WCTYPE_H],
     dnl Redefine all of iswcntrl, ..., towupper in <wctype.h>.
     :
   fi
+
+  dnl We assume that the wctype() and iswctype() functions exist if and only
+  dnl if the type wctype_t is defined in <wchar.h> or in <wctype.h> if that
+  dnl exists.
+  dnl HP-UX 11.00 declares all these in <wchar.h> and lacks <wctype.h>.
+  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: <stdio.h> must be
+               included before <wchar.h>.
+               BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
+               must be included before <wchar.h>.  */
+            #include <stddef.h>
+            #include <stdio.h>
+            #include <time.h>
+            #include <wchar.h>
+            #if HAVE_WCTYPE_H
+            # include <wctype.h>
+            #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 <wctype.h>.
+  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: <stdio.h> must be
+               included before <wchar.h>.
+               BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
+               must be included before <wchar.h>.  */
+            #include <stddef.h>
+            #include <stdio.h>
+            #include <time.h>
+            #include <wchar.h>
+            #include <wctype.h>
+            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])
 ])
index d1e36e3..d6499c7 100644 (file)
@@ -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' \
index 0fe4a77..aed3b77 100644 (file)
@@ -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)
 {