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