reflects addition of codeset.m4 from gettext-0.10.38, automatically
[findutils.git] / m4 / strerror_r.m4
blob410dfdfa2a65a6d3b7497303a4ac191cefe9262c
1 #serial 2
3 dnl From Jim Meyering.
4 dnl Determine whether the strerror_r implementation is one of
5 dnl the broken ones that returns `int' rather than `char*'.
6 dnl Actually, this tests only whether it returns a scalar
7 dnl or an array, but that should be enough.
8 dnl On at least DEC UNIX 4.0[A-D] and HP-UX B.10.20, strerror_r
9 dnl returns `int'.  This is used by lib/error.c.
11 AC_DEFUN(jm_FUNC_STRERROR_R,
13   # Check strerror_r
14   AC_CHECK_FUNCS([strerror_r])
15   if test $ac_cv_func_strerror_r = yes; then
16     AC_CHECK_HEADERS(string.h)
17     AC_CACHE_CHECK([for working strerror_r],
18                    jm_cv_func_working_strerror_r,
19      [
20       AC_TRY_COMPILE(
21        [
22 #       include <stdio.h>
23 #       if HAVE_STRING_H
24 #        include <string.h>
25 #       endif
26        ],
27        [
28          int buf; /* avoiding square brackets makes this easier */
29          char x = *strerror_r (0, buf, sizeof buf);
30        ],
31        jm_cv_func_working_strerror_r=yes,
32        jm_cv_func_working_strerror_r=no
33       )
34       if test $jm_cv_func_working_strerror_r = yes; then
35         AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1,
36           [Define to 1 if strerror_r returns a string.])
37       fi
38     ])
39   fi