* lib/wchar.in.h (wcstok): Override when REPLACE_WCSTOK is 1.
* m4/wcstok.m4 (gl_FUNC_WCSTOK): Check for signature of wcstok. Set
REPLACE_WCSTOK.
* m4/wchar_h.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_WCSTOK.
* modules/wchar (Makefile.am): Substitute REPLACE_WCSTOK.
* modules/wcstok (Depends-on, configure.ac): Consider REPLACE_WCSTOK.
* doc/posix-functions/wcstok.texi: Mention the problem.
+2019-11-24 Bruno Haible <bruno@clisp.org>
+
+ wcstok: Work around wrong signature on native Windows.
+ * lib/wchar.in.h (wcstok): Override when REPLACE_WCSTOK is 1.
+ * m4/wcstok.m4 (gl_FUNC_WCSTOK): Check for signature of wcstok. Set
+ REPLACE_WCSTOK.
+ * m4/wchar_h.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_WCSTOK.
+ * modules/wchar (Makefile.am): Substitute REPLACE_WCSTOK.
+ * modules/wcstok (Depends-on, configure.ac): Consider REPLACE_WCSTOK.
+ * doc/posix-functions/wcstok.texi: Mention the problem.
+
2019-11-22 Paul Eggert <eggert@cs.ucla.edu>
intprops: INT_MULTIPLY_WRAPV speedup for GCC 8.4+
@item
This function is missing on some platforms:
Cygwin 1.5.x.
+@item
+This function takes only two arguments on some platforms:
+mingw, MSVC 14.
@end itemize
Portability problems not fixed by Gnulib:
/* Divide WCS into tokens separated by characters in DELIM. */
#if @GNULIB_WCSTOK@
-# if !@HAVE_WCSTOK@
+# if @REPLACE_WCSTOK@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wcstok
+# define wcstok rpl_wcstok
+# endif
+_GL_FUNCDECL_RPL (wcstok, wchar_t *,
+ (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
+_GL_CXXALIAS_RPL (wcstok, wchar_t *,
+ (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
+# else
+# if !@HAVE_WCSTOK@
_GL_FUNCDECL_SYS (wcstok, wchar_t *,
(wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
-# endif
+# endif
_GL_CXXALIAS_SYS (wcstok, wchar_t *,
(wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
+# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (wcstok);
# endif
dnl Written by Eric Blake.
-# wchar_h.m4 serial 43
+# wchar_h.m4 serial 44
AC_DEFUN([gl_WCHAR_H],
[
REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH])
REPLACE_WCSFTIME=0; AC_SUBST([REPLACE_WCSFTIME])
+ REPLACE_WCSTOK=0; AC_SUBST([REPLACE_WCSTOK])
])
-# wcstok.m4 serial 2
+# wcstok.m4 serial 3
dnl Copyright (C) 2011-2019 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_WCHAR_H_DEFAULTS])
AC_CHECK_FUNCS_ONCE([wcstok])
- if test $ac_cv_func_wcstok = no; then
+ if test $ac_cv_func_wcstok = yes; then
+ dnl POSIX: wchar_t *wcstok (wchar_t *, const wchar_t *, wchar_t **);
+ dnl mingw, MSVC: wchar_t *wcstok (wchar_t *, const wchar_t *);
+ AC_CACHE_CHECK([for wcstok with POSIX signature],
+ [gl_cv_func_wcstok_posix_signature],
+ [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>
+wchar_t *wcstok (wchar_t *, const wchar_t *, wchar_t **);
+]],
+ [])],
+ [gl_cv_func_wcstok_posix_signature=yes],
+ [gl_cv_func_wcstok_posix_signature=no])
+ ])
+ if test $gl_cv_func_wcstok_posix_signature = no; then
+ REPLACE_WCSTOK=1
+ fi
+ else
HAVE_WCSTOK=0
fi
])
-e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
-e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \
-e 's|@''REPLACE_WCSFTIME''@|$(REPLACE_WCSFTIME)|g' \
+ -e 's|@''REPLACE_WCSTOK''@|$(REPLACE_WCSTOK)|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)'; \
Depends-on:
wchar
-wcsspn [test $HAVE_WCSTOK = 0]
-wcspbrk [test $HAVE_WCSTOK = 0]
+wcsspn [test $HAVE_WCSTOK = 0 || test $REPLACE_WCSTOK = 1]
+wcspbrk [test $HAVE_WCSTOK = 0 || test $REPLACE_WCSTOK = 1]
configure.ac:
gl_FUNC_WCSTOK
-if test $HAVE_WCSTOK = 0; then
+if test $HAVE_WCSTOK = 0 || test $REPLACE_WCSTOK = 1; then
AC_LIBOBJ([wcstok])
fi
gl_WCHAR_MODULE_INDICATOR([wcstok])