summaryrefslogtreecommitdiff
path: root/aclocal.m4
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-05-04 08:45:17 +0000
committerJim Meyering <jim@meyering.net>2003-05-04 08:45:17 +0000
commitf1ce5dbf0e453e753a1a42fdc28cbdc0d8d637a7 (patch)
treeab59fc00545431f26fa299b8274d9bcc27bbbd51 /aclocal.m4
parent28e9fb4f738bf6f35fbddbebfaeb5a83fa5a7e90 (diff)
downloadcoreutils-f1ce5dbf0e453e753a1a42fdc28cbdc0d8d637a7.tar.xz
.
Diffstat (limited to 'aclocal.m4')
-rw-r--r--aclocal.m4161
1 files changed, 148 insertions, 13 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index 89903244e..d4d5513d3 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -859,7 +859,7 @@ WARNING: You don't seem to have perl5.003 or newer installed, or you lack
] )
])
-#serial 61 -*- autoconf -*-
+#serial 62 -*- autoconf -*-
m4_undefine([AC_LANG_SOURCE(C)])
dnl The following is identical to the definition in c.m4
@@ -1052,6 +1052,7 @@ AC_DEFUN([jm_MACROS],
AC_FUNC_STRTOD
AC_REQUIRE([UTILS_SYS_OPEN_MAX])
AC_REQUIRE([GL_FUNC_GETCWD_PATH_MAX])
+ AC_REQUIRE([GL_FUNC_READDIR])
# See if linking `seq' requires -lm.
# It does on nearly every system. The single exception (so far) is
@@ -3697,7 +3698,7 @@ AC_DEFUN([UTILS_SYS_OPEN_MAX],
[the maximum number of simultaneously open files per process])
])
-#serial 2
+#serial 3
# Check whether getcwd has the bug that it succeeds for a working directory
# longer than PATH_MAX, yet returns a truncated directory name.
# If so, arrange to compile the wrapper function.
@@ -3743,23 +3744,21 @@ AC_DEFUN([GL_FUNC_GETCWD_PATH_MAX],
# define INT_MAX TYPE_MAXIMUM (int)
#endif
-#ifndef PATH_MAX
-/* There might be a better way to handle this case, but note:
- - the value shouldn't be anywhere near INT_MAX, and
- - the value shouldn't be so big that the local declaration, below,
- blows the stack. */
-# define PATH_MAX 40000
-#endif
-
/* The length of this name must be 8. */
#define DIR_NAME "confdir3"
int
main ()
{
- /* The '9' comes from strlen (DIR_NAME) + 1. */
-#if INT_MAX - 9 <= PATH_MAX
- /* FIXME: Assuming there's a system for which this is true -- Hurd?,
+#ifndef PATH_MAX
+ /* The Hurd doesn't define this, so getcwd can't exhibit the bug --
+ at least not on a local file system. And if we were to start worrying
+ about remote file systems, we'd have to enable the wrapper function
+ all of the time, just to be safe. That's not worth the cost. */
+ exit (0);
+#elif INT_MAX - 9 <= PATH_MAX
+ /* The '9', above, comes from strlen (DIR_NAME) + 1. */
+ /* FIXME: Assuming there's a system for which this is true,
this should be done in a compile test. */
exit (0);
#else
@@ -3834,6 +3833,142 @@ main ()
fi
])
+#serial 5
+
+dnl SunOS's readdir is broken in such a way that rm.c has to add extra code
+dnl to test whether a NULL return value really means there are no more files
+dnl in the directory.
+dnl
+dnl And the rm from coreutils-5.0 exposes a similar problem when there
+dnl are 338 or more files in a directory on a Darwin-6.5 system
+dnl
+dnl Detect the problem by creating a directory containing 500 files (254 not
+dnl counting . and .. is the minimum for SunOS, 338 for Darwin) and see
+dnl if a loop doing `readdir; unlink' removes all of them.
+dnl
+dnl Define HAVE_WORKING_READDIR if readdir does *not* have this problem.
+
+dnl Written by Jim Meyering.
+
+AC_DEFUN([GL_FUNC_READDIR],
+[dnl
+AC_REQUIRE([AC_HEADER_DIRENT])
+AC_CHECK_HEADERS(string.h)
+AC_CACHE_CHECK([for working readdir], gl_cv_func_working_readdir,
+ [dnl
+ # Arrange for deletion of the temporary directory this test creates, in
+ # case the test itself fails to delete everything -- as happens on Sunos.
+ ac_clean_files="$ac_clean_files conf-dir"
+
+ AC_TRY_RUN(
+[# include <stdio.h>
+# include <sys/types.h>
+# if HAVE_STRING_H
+# include <string.h>
+# endif
+
+# ifdef HAVE_DIRENT_H
+# include <dirent.h>
+# define NLENGTH(direct) (strlen((direct)->d_name))
+# else /* not HAVE_DIRENT_H */
+# define dirent direct
+# define NLENGTH(direct) ((direct)->d_namlen)
+# ifdef HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif /* HAVE_SYS_NDIR_H */
+# ifdef HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif /* HAVE_SYS_DIR_H */
+# ifdef HAVE_NDIR_H
+# include <ndir.h>
+# endif /* HAVE_NDIR_H */
+# endif /* HAVE_DIRENT_H */
+
+# define DOT_OR_DOTDOT(Basename) \
+ (Basename[0] == '.' && (Basename[1] == '\0' \
+ || (Basename[1] == '.' && Basename[2] == '\0')))
+
+/* Don't try to use replacement mkdir; it wouldn't resolve at link time. */
+# undef mkdir
+
+ static void
+ create_N_file_dir (const char *dir, size_t n_files)
+ {
+ unsigned int i;
+
+ if (mkdir (dir, 0700))
+ abort ();
+ if (chdir (dir))
+ abort ();
+
+ for (i = 0; i < n_files; i++)
+ {
+ char file_name[4];
+ FILE *out;
+
+ sprintf (file_name, "%03d", i);
+ out = fopen (file_name, "w");
+ if (!out)
+ abort ();
+ if (fclose (out) == EOF)
+ abort ();
+ }
+
+ if (chdir (".."))
+ abort ();
+ }
+
+ static void
+ remove_dir (const char *dir)
+ {
+ DIR *dirp;
+
+ if (chdir (dir))
+ abort ();
+
+ dirp = opendir (".");
+ if (dirp == NULL)
+ abort ();
+
+ while (1)
+ {
+ struct dirent *dp = readdir (dirp);
+ if (dp == NULL)
+ break;
+
+ if (DOT_OR_DOTDOT (dp->d_name))
+ continue;
+
+ if (unlink (dp->d_name))
+ abort ();
+ }
+ closedir (dirp);
+
+ if (chdir (".."))
+ abort ();
+
+ if (rmdir (dir))
+ exit (1);
+ }
+
+ int
+ main ()
+ {
+ const char *dir = "conf-dir";
+ create_N_file_dir (dir, 500);
+ remove_dir (dir);
+ exit (0);
+ }],
+ gl_cv_func_working_readdir=yes,
+ gl_cv_func_working_readdir=no,
+ gl_cv_func_working_readdir=no)])
+
+ if test $gl_cv_func_working_readdir = yes; then
+ AC_DEFINE(HAVE_WORKING_READDIR, 1,
+[Define if readdir is found to work properly in some unusual cases. ])
+ fi
+])
+
# codeset.m4 serial AM1 (gettext-0.10.40)
dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU