Require jm_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK.
[gnulib.git] / m4 / stat.m4
1 #serial 4
2
3 dnl From Jim Meyering.
4 dnl Determine whether stat has the bug that it succeeds when given the
5 dnl zero-length file name argument.  The stat from SunOS4.1.4 and the Hurd
6 dnl (as of 1998-11-01) do this.
7 dnl
8 dnl If it does, then define HAVE_STAT_EMPTY_STRING_BUG and arrange to
9 dnl compile the wrapper function.
10 dnl
11
12 AC_DEFUN(jm_FUNC_STAT,
13 [
14  AC_REQUIRE([jm_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
15  AC_CACHE_CHECK([whether stat accepts an empty string],
16   jm_cv_func_stat_empty_string_bug,
17   [AC_TRY_RUN([
18 #   include <sys/types.h>
19 #   include <sys/stat.h>
20
21     int
22     main ()
23     {
24       struct stat sbuf;
25       exit (stat ("", &sbuf) ? 1 : 0);
26     }
27           ],
28          jm_cv_func_stat_empty_string_bug=yes,
29          jm_cv_func_stat_empty_string_bug=no,
30          dnl When crosscompiling, assume stat is broken.
31          jm_cv_func_stat_empty_string_bug=yes)
32   ])
33   if test $jm_cv_func_stat_empty_string_bug = yes; then
34     AC_SUBST(LIBOBJS)
35     LIBOBJS="$LIBOBJS stat.$ac_objext"
36     AC_DEFINE_UNQUOTED(HAVE_STAT_EMPTY_STRING_BUG, 1,
37 [Define if stat has the bug that it succeeds when given the zero-length
38    file name argument.  The stat from SunOS4.1.4 and the Hurd as of 1998-11-01)
39    do this. ])
40   fi
41 ])