Remove support for broken <wchar.h> in BSD/OS and OSF/1.
[gnulib.git] / m4 / wcstok.m4
blob4f73292ff1fe0a7c62e9abb340b0d976cd5c2baf
1 # wcstok.m4 serial 6
2 dnl Copyright (C) 2011-2020 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_WCSTOK],
9   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
10   AC_REQUIRE([AC_CANONICAL_HOST])
11   AC_CHECK_FUNCS_ONCE([wcstok])
12   if test $ac_cv_func_wcstok = yes; then
13     dnl On HP-UX 11.31, it depends on the compiler and linker whether wcstok()
14     dnl uses hidden state, ignoring the third argument, and thus exhibits a
15     dnl bug when two or more wcstok() iteration loops are being performed in
16     dnl the same thread.
17     case "$host_os" in
18       hpux*)
19         REPLACE_WCSTOK=1
20         ;;
21       *)
22         dnl POSIX:        wchar_t *wcstok (wchar_t *, const wchar_t *, wchar_t **);
23         dnl mingw, MSVC:  wchar_t *wcstok (wchar_t *, const wchar_t *);
24         AC_CACHE_CHECK([for wcstok with POSIX signature],
25           [gl_cv_func_wcstok_posix_signature],
26           [AC_COMPILE_IFELSE(
27              [AC_LANG_PROGRAM(
28                 [[#include <wchar.h>
29                   wchar_t *wcstok (wchar_t *, const wchar_t *, wchar_t **);
30                 ]],
31                 [[]])],
32              [gl_cv_func_wcstok_posix_signature=yes],
33              [gl_cv_func_wcstok_posix_signature=no])
34           ])
35         if test $gl_cv_func_wcstok_posix_signature = no; then
36           REPLACE_WCSTOK=1
37         fi
38         ;;
39     esac
40   else
41     HAVE_WCSTOK=0
42   fi