+2023-07-26 Bruno Haible <bruno@clisp.org>
+
+ wctype: Work around wctype bug on mingw.
+ * lib/wctype.in.h (rpl_wctype_t, wctype_t, GNULIB_defined_wctype_t):
+ Define if REPLACE_WCTYPE is 1.
+ (wctype): Consider REPLACE_WCTYPE.
+ (iswctype): Override also if REPLACE_WCTYPE is 1.
+ * lib/iswctype.c: If GNULIB_defined_wctype_t is defined, use the
+ function-pointer based implementation.
+ * m4/wctype_h.m4 (gl_WCTYPE_H_DEFAULTS): Initialize REPLACE_WCTYPE.
+ * m4/wctype.m4 (gl_FUNC_WCTYPE): Define through AC_DEFUN_ONCE. Test
+ whether wctype supports the "blank" character class. Set REPLACE_WCTYPE
+ if not.
+ * m4/iswctype.m4 (gl_FUNC_ISWCTYPE): Require gl_FUNC_WCTYPE.
+ * modules/wctype (Status, Notice): Remove.
+ (Depends-on): Add iswctype. Consider REPLACE_WCTYPE.
+ (configure.ac): Consider REPLACE_WCTYPE.
+ * modules/iswctype (Status, Notice): Remove.
+ (Files): Add m4/wctype.m4.
+ (configure.ac): Override also if REPLACE_WCTYPE is 1.
+ * modules/wctype-h (Makefile.am): Substitute REPLACE_WCTYPE.
+ * doc/posix-functions/wctype.texi: Mention the mingw bug.
+
2023-07-26 Bruno Haible <bruno@clisp.org>
wctype-h: Work around iswprint bug on mingw.
This function is declared in @code{<wchar.h>}, not in @code{<wctype.h>}, on
some platforms:
HP-UX 11.00.
+@item
+This function does not support the @code{"blank"} character class
+on some platforms:
+mingw.
@end itemize
Portability problems not fixed by Gnulib:
/* Specification. */
#include <wctype.h>
-#if GNULIB_defined_wint_t
+#if GNULIB_defined_wint_t && !GNULIB_defined_wctype_t
int
iswctype (wint_t wc, wctype_t desc)
typedef void * wctype_t;
# define GNULIB_defined_wctype_t 1
# endif
+#elif @REPLACE_WCTYPE@
+# if !GNULIB_defined_wctype_t
+typedef void *rpl_wctype_t;
+# undef wctype_t
+# define wctype_t rpl_wctype_t
+# define GNULIB_defined_wctype_t 1
+# endif
#endif
/* Get a descriptor for a wide character property. */
#if @GNULIB_WCTYPE@
-# if !@HAVE_WCTYPE_T@
+# if @REPLACE_WCTYPE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wctype
+# define wctype rpl_wctype
+# endif
+_GL_FUNCDECL_RPL (wctype, wctype_t, (const char *name)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (wctype, wctype_t, (const char *name));
+# else
+# if !@HAVE_WCTYPE_T@
_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name)
_GL_ARG_NONNULL ((1)));
-# endif
+# endif
_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name));
+# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (wctype);
# endif
The argument WC must be either a wchar_t value or WEOF.
The argument DESC must have been returned by the wctype() function. */
#if @GNULIB_ISWCTYPE@
-# if @GNULIBHEADERS_OVERRIDE_WINT_T@
+# if @GNULIBHEADERS_OVERRIDE_WINT_T@ || @REPLACE_WCTYPE@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef iswctype
# define iswctype rpl_iswctype
-# iswctype.m4 serial 2
+# iswctype.m4 serial 3
dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
[
AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
AC_REQUIRE([gl_WCTYPE_H])
+ dnl Determine REPLACE_WCTYPE.
+ AC_REQUIRE([gl_FUNC_WCTYPE])
])
-# wctype.m4 serial 2
+# wctype.m4 serial 3
dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
-AC_DEFUN([gl_FUNC_WCTYPE],
+AC_DEFUN_ONCE([gl_FUNC_WCTYPE],
[
AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
AC_REQUIRE([gl_WCTYPE_H])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
HAVE_WCTYPE=$HAVE_WCTYPE_T
+ if test $HAVE_WCTYPE = 1; then
+ AC_CACHE_CHECK([whether wctype supports the "blank" character class],
+ [gl_cv_func_wctype_works],
+ [AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+ #include <wchar.h>
+ #include <wctype.h>
+ int main () { return wctype ("blank") == (wctype_t)0; }
+ ]])],
+ [gl_cv_func_wctype_works=yes], [gl_cv_func_wctype_works=no],
+ [case "$host_os" in
+ # Guess no on mingw.
+ mingw*) AC_EGREP_CPP([Problem], [
+#ifdef __MINGW32__
+ Problem
+#endif
+ ],
+ [gl_cv_func_wctype_works="guessing no"],
+ [gl_cv_func_wctype_works="guessing yes"])
+ ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_wctype_works="guessing yes" ;;
+ esac
+ ])
+ ])
+ case "$gl_cv_func_wctype_works" in
+ *yes) ;;
+ *) REPLACE_WCTYPE=1 ;;
+ esac
+ fi
])
-# wctype_h.m4 serial 30
+# wctype_h.m4 serial 31
dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK])
REPLACE_ISWDIGIT=0; AC_SUBST([REPLACE_ISWDIGIT])
REPLACE_ISWXDIGIT=0; AC_SUBST([REPLACE_ISWXDIGIT])
+ REPLACE_WCTYPE=0; AC_SUBST([REPLACE_WCTYPE])
])
Description:
iswctype() function: test whether a wide character has a given property.
-Status:
-obsolete
-
-Notice:
-This module is obsolete.
-
Files:
lib/iswctype.c
lib/iswctype-impl.h
m4/iswctype.m4
+m4/wctype.m4
Depends-on:
wctype-h
configure.ac:
gl_FUNC_ISWCTYPE
gl_CONDITIONAL([GL_COND_OBJ_ISWCTYPE],
- [test $HAVE_WCTYPE_T = 0 || test $GNULIBHEADERS_OVERRIDE_WINT_T = 1])
+ [test $HAVE_WCTYPE_T = 0 || test $GNULIBHEADERS_OVERRIDE_WINT_T = 1 || test $REPLACE_WCTYPE = 1])
gl_WCTYPE_MODULE_INDICATOR([iswctype])
Makefile.am:
Description:
wctype() function: get descriptor for a wide character property.
-Status:
-obsolete
-
-Notice:
-This module is obsolete.
-
Files:
lib/wctype.c
lib/wctype-impl.h
Depends-on:
wctype-h
-iswblank [test $HAVE_WCTYPE = 0]
-iswdigit [test $HAVE_WCTYPE = 0]
-iswxdigit [test $HAVE_WCTYPE = 0]
+iswblank [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1]
+iswdigit [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1]
+iswxdigit [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1]
+# When we override wctype_t, we also need to override iswctype().
+iswctype [test $REPLACE_WCTYPE = 1]
configure.ac:
gl_FUNC_WCTYPE
-gl_CONDITIONAL([GL_COND_OBJ_WCTYPE], [test $HAVE_WCTYPE = 0])
+gl_CONDITIONAL([GL_COND_OBJ_WCTYPE], [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1])
gl_WCTYPE_MODULE_INDICATOR([wctype])
Makefile.am:
-e 's/@''REPLACE_ISWXDIGIT''@/$(REPLACE_ISWXDIGIT)/g' \
-e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
-e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \
+ -e 's/@''REPLACE_WCTYPE''@/$(REPLACE_WCTYPE)/g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \