[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
wctype-h: ensure wctype_t and wctrans_t types
From: |
Bruno Haible |
Subject: |
wctype-h: ensure wctype_t and wctrans_t types |
Date: |
Sun, 6 Feb 2011 23:19:17 +0100 |
User-agent: |
KMail/1.9.9 |
On some platforms, the functions wctype and iswctype and the type wctype_t
are missing. Likewise for the functions wctrans and towctrans and the type
wctrans_t. Let's detect it and define the types:
2011-02-06 Bruno Haible <address@hidden>
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.
--- lib/wctype.in.h.orig Sun Feb 6 23:12:21 2011
+++ lib/wctype.in.h Sun Feb 6 23:08:28 2011
@@ -372,6 +372,10 @@
_GL_CXXALIASWARN (iswblank);
#endif
+#if address@hidden@
+typedef void * wctype_t;
+#endif
+
#if @REPLACE_ISWCNTRL@ || defined __MINGW32__
_GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
_GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
@@ -382,6 +386,10 @@
_GL_CXXALIASWARN (towlower);
_GL_CXXALIASWARN (towupper);
+#if address@hidden@
+typedef void * wctrans_t;
+#endif
+
#endif /* _GL_WCTYPE_H */
#endif /* _GL_WCTYPE_H */
--- m4/wctype_h.m4.orig Sun Feb 6 23:12:21 2011
+++ m4/wctype_h.m4 Sun Feb 6 23:07:24 2011
@@ -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,54 @@
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 <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>
+ #include <wctype.h>
+ 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 +142,7 @@
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])
])
--- modules/wctype-h.orig Sun Feb 6 23:12:22 2011
+++ modules/wctype-h Sun Feb 6 23:11:51 2011
@@ -30,6 +30,8 @@
-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' \
--- tests/test-wctype-h.c.orig Sun Feb 6 23:12:22 2011
+++ tests/test-wctype-h.c Sun Feb 6 23:09:30 2011
@@ -27,6 +27,12 @@
/* 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)
{
--
In memoriam Chris Gueffroy <http://en.wikipedia.org/wiki/Chris_Gueffroy>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- wctype-h: ensure wctype_t and wctrans_t types,
Bruno Haible <=