changeset 6934:d68ff786c180

* lib/getloadavg.c: Use __VMS, not VMS. * lib/getopt.c: Likewise. * lib/getpagesize.h: Likewise. * lib/glob.c: Remove most VMS cruft; it hasn't been tested for a while and probably does not work. * lib/backupfile.c [HAVE_DIRENT_H && ! HAVE_NDIR_H]: Don't worry about this obsolete case any more. (HAVE_DIR): Remove. All uses removed; we now assume you can read directories. * lib/dirfd.h [HAVE_DIRENT_H && ! HAVE_NDIR_H]: Don't worry about this obsolete case any more. * lib/fts.c: Likewise. * lib/getcwd.c: Likewise. * lib/glob.h: Likewise. * lib/savedir.c: Likewise. * m4/backupfile.m4 (gl_BACKUPFILE): Check for dirent.h, instead of invoking obsolescent AC_HEADER_DIRENT macro. * m4/d-ino.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_INO): Likewise. * m4/d-type.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE): Likewise. * m4/dirfd.m4 (gl_FUNC_DIRFD): Likewise. * m4/fts.m4 (gl_FUNC_FTS_CORE): Likewise. * m4/getcwd.m4 (gl_PREREQ_GETCWD): Likewise. * m4/glob.m4 (gl_PREREQ_GLOB): Likewise. * m4/savedir.m4 (gl_SAVEDIR): Likewise. * m4/readdir.m4: Remove; no longer needed.
author Paul Eggert <eggert@cs.ucla.edu>
date Thu, 06 Jul 2006 23:29:27 +0000
parents 53581389f883
children c7a96bfc8c0e
files lib/ChangeLog lib/backupfile.c lib/dirfd.h lib/fts.c lib/getcwd.c lib/getloadavg.c lib/getopt.c lib/getpagesize.h lib/glob.c lib/savedir.c m4/ChangeLog m4/backupfile.m4 m4/d-ino.m4 m4/d-type.m4 m4/dirfd.m4 m4/fts.m4 m4/getcwd.m4 m4/glob.m4 m4/readdir.m4 m4/savedir.m4
diffstat 20 files changed, 97 insertions(+), 293 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,25 @@
+2006-07-06  Paul Eggert  <eggert@cs.ucla.edu>
+
+	* getloadavg.c: Use __VMS, not VMS.
+	* getopt.c: Likewise.
+	* getpagesize.h: Likewise.
+	* glob.c: Remove most VMS cruft; it hasn't been tested for a while and
+	probably does not work.
+
+2006-07-06  Derek R. Price  <derek@ximbiot.com>
+	and Paul Eggert  <eggert@cs.ucla.edu>
+
+	* backupfile.c [HAVE_DIRENT_H && ! HAVE_NDIR_H]:
+	Don't worry about this obsolete case any more.
+	(HAVE_DIR): Remove.  All uses removed; we now assume you can read
+	directories.
+	* dirfd.h [HAVE_DIRENT_H && ! HAVE_NDIR_H]: Don't
+	worry about this obsolete case any more.
+	* fts.c: Likewise.
+	* getcwd.c: Likewise.
+	* glob.h: Likewise.
+	* savedir.c: Likewise.
+
 2006-07-06  Paul Eggert  <eggert@cs.ucla.edu>
 
 	* .cppi-disable: Add wcwidth.
--- a/lib/backupfile.c
+++ b/lib/backupfile.c
@@ -47,21 +47,7 @@
 #else
 # define dirent direct
 # define NLENGTH(direct) ((size_t) (direct)->d_namlen)
-# if HAVE_SYS_NDIR_H
-#  include <sys/ndir.h>
-# endif
-# if HAVE_SYS_DIR_H
-#  include <sys/dir.h>
-# endif
-# if HAVE_NDIR_H
-#  include <ndir.h>
-# endif
-#endif
-
-#if HAVE_DIRENT_H || HAVE_NDIR_H || HAVE_SYS_DIR_H || HAVE_SYS_NDIR_H
-# define HAVE_DIR 1
-#else
-# define HAVE_DIR 0
+# include <ndir.h>
 #endif
 
 #if D_INO_IN_DIRENT
@@ -166,8 +152,6 @@
     }
 }
 
-#if HAVE_DIR
-
 /* Returned values for NUMBERED_BACKUP.  */
 
 enum numbered_backup_result
@@ -282,7 +266,6 @@
   *buffer = buf;
   return result;
 }
-#endif /* HAVE_DIR */
 
 /* Return the name of the new backup file for the existing file FILE,
    allocated with malloc.  Report an error and fail if out of memory.
@@ -301,14 +284,13 @@
   size_t simple_backup_suffix_size = strlen (simple_backup_suffix) + 1;
   size_t backup_suffix_size_guess = simple_backup_suffix_size;
   enum { GUESS = sizeof ".~12345~" };
-  if (HAVE_DIR && backup_suffix_size_guess < GUESS)
+  if (backup_suffix_size_guess < GUESS)
     backup_suffix_size_guess = GUESS;
 
   ssize = filelen + backup_suffix_size_guess + 1;
   s = xmalloc (ssize);
   memcpy (s, file, filelen + 1);
 
-#if HAVE_DIR
   if (backup_type != simple_backups)
     switch (numbered_backup (&s, ssize, filelen))
       {
@@ -323,7 +305,6 @@
 	simple = (backup_type == numbered_existing_backups);
 	break;
       }
-#endif
 
   if (simple)
     memcpy (s + filelen, simple_backup_suffix, simple_backup_suffix_size);
--- a/lib/dirfd.h
+++ b/lib/dirfd.h
@@ -1,5 +1,5 @@
 /* Declare dirfd, if necessary.
-   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -21,18 +21,10 @@
 
 #if HAVE_DIRENT_H
 # include <dirent.h>
-#else /* not HAVE_DIRENT_H */
+#else
 # define dirent direct
-# if HAVE_SYS_NDIR_H
-#  include <sys/ndir.h>
-# endif /* HAVE_SYS_NDIR_H */
-# if HAVE_SYS_DIR_H
-#  include <sys/dir.h>
-# endif /* HAVE_SYS_DIR_H */
-# if HAVE_NDIR_H
-#  include <ndir.h>
-# endif /* HAVE_NDIR_H */
-#endif /* HAVE_DIRENT_H */
+# include <ndir.h>
+#endif
 
 #ifndef HAVE_DECL_DIRFD
 "this configure-time declaration test was not run"
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -75,26 +75,17 @@
 # include "lstat.h"
 #endif
 
-#if defined _LIBC
+#if HAVE_DIRENT_H || _LIBC
 # include <dirent.h>
-# define NAMLEN(dirent) _D_EXACT_NAMLEN (dirent)
-#else
-# if HAVE_DIRENT_H
-#  include <dirent.h>
-#  define NAMLEN(dirent) strlen ((dirent)->d_name)
+# ifdef _D_EXACT_NAMLEN
+#  define NAMLEN(dirent) _D_EXACT_NAMLEN (dirent)
 # else
-#  define dirent direct
-#  define NAMLEN(dirent) (dirent)->d_namlen
-#  if HAVE_SYS_NDIR_H
-#   include <sys/ndir.h>
-#  endif
-#  if HAVE_SYS_DIR_H
-#   include <sys/dir.h>
-#  endif
-#  if HAVE_NDIR_H
-#   include <ndir.h>
-#  endif
+#  define NAMLEN(dirent) strlen ((dirent)->d_name)
 # endif
+#else
+# define dirent direct
+# define NAMLEN(dirent) (dirent)->d_namlen
+# include <ndir.h>
 #endif
 
 #ifdef _LIBC
--- a/lib/getcwd.c
+++ b/lib/getcwd.c
@@ -38,23 +38,13 @@
 
 #if HAVE_DIRENT_H || _LIBC
 # include <dirent.h>
-# ifndef _D_EXACT_NAMLEN
-#  define _D_EXACT_NAMLEN(d) strlen ((d)->d_name)
-# endif
 #else
 # define dirent direct
-# if HAVE_SYS_NDIR_H
-#  include <sys/ndir.h>
-# endif
-# if HAVE_SYS_DIR_H
-#  include <sys/dir.h>
-# endif
-# if HAVE_NDIR_H
-#  include <ndir.h>
-# endif
+# define _D_EXACT_NAMLEN(d) (d)->d_namlen
+# include <ndir.h>
 #endif
 #ifndef _D_EXACT_NAMLEN
-# define _D_EXACT_NAMLEN(d) ((d)->d_namlen)
+# define _D_EXACT_NAMLEN(d) strlen ((d)->d_name)
 #endif
 #ifndef _D_ALLOC_NAMLEN
 # define _D_ALLOC_NAMLEN(d) (_D_EXACT_NAMLEN (d) + 1)
--- a/lib/getloadavg.c
+++ b/lib/getloadavg.c
@@ -358,7 +358,7 @@
 
 # ifdef LOAD_AVE_TYPE
 
-#  ifndef VMS
+#  ifndef __VMS
 #   ifndef __linux__
 #    ifndef NLIST_STRUCT
 #     include <a.out.h>
@@ -385,7 +385,7 @@
 #    endif /* LDAV_SYMBOL */
 #   endif /* __linux__ */
 
-#  else /* VMS */
+#  else /* __VMS */
 
 #   ifndef eunice
 #    include <iodef.h>
@@ -393,7 +393,7 @@
 #   else /* eunice */
 #    include <vms/iodef.h>
 #   endif /* eunice */
-#  endif /* VMS */
+#  endif /* __VMS */
 
 #  ifndef LDAV_CVT
 #   define LDAV_CVT(n) ((double) (n))
@@ -473,9 +473,9 @@
 /* Offset in kmem to seek to read load average, or 0 means invalid.  */
 static long offset;
 
-#  if !defined (VMS) && !defined (sgi) && !defined (__linux__)
+#  if ! defined __VMS && ! defined sgi && ! defined __linux__
 static struct nlist nl[2];
-#  endif /* Not VMS or sgi */
+#  endif
 
 #  ifdef SUNOS_5
 static kvm_t *kd;
@@ -813,7 +813,7 @@
 	 : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
 # endif /* OSF_ALPHA */
 
-# if !defined (LDAV_DONE) && defined (VMS)
+# if ! defined LDAV_DONE && defined __VMS
   /* VMS specific code -- read from the Load Ave driver.  */
 
   LOAD_AVE_TYPE load_ave[3];
@@ -851,9 +851,9 @@
 
   if (!getloadavg_initialized)
     return -1;
-# endif /* VMS */
+# endif /* ! defined LDAV_DONE && defined __VMS */
 
-# if !defined (LDAV_DONE) && defined (LOAD_AVE_TYPE) && !defined (VMS)
+# if ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS
 
   /* UNIX-specific code -- read the average from /dev/kmem.  */
 
@@ -953,7 +953,7 @@
 
   if (offset == 0 || !getloadavg_initialized)
     return -1;
-# endif /* LOAD_AVE_TYPE and not VMS */
+# endif /* ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS */
 
 # if !defined (LDAV_DONE) && defined (LOAD_AVE_TYPE) /* Including VMS.  */
   if (nelem > 0)
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -31,7 +31,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#ifdef VMS
+#ifdef __VMS
 # include <unixlib.h>
 #endif
 
--- a/lib/getpagesize.h
+++ b/lib/getpagesize.h
@@ -21,12 +21,12 @@
 #include <unistd.h>
 
 #if !defined getpagesize && defined _SC_PAGESIZE
-# if !(defined VMS && __VMS_VER < 70000000)
+# if ! (defined __VMS && __VMS_VER < 70000000)
 #  define getpagesize() sysconf (_SC_PAGESIZE)
 # endif
 #endif
 
-#if !defined getpagesize && defined VMS
+#if !defined getpagesize && defined __VMS
 # ifdef __ALPHA
 #  define getpagesize() 8192
 # else
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -53,18 +53,7 @@
 #else
 # define dirent direct
 # define NAMLEN(dirent) (dirent)->d_namlen
-# ifdef HAVE_SYS_NDIR_H
-#  include <sys/ndir.h>
-# endif
-# ifdef HAVE_SYS_DIR_H
-#  include <sys/dir.h>
-# endif
-# ifdef HAVE_NDIR_H
-#  include <ndir.h>
-# endif
-# ifdef HAVE_VMSDIR_H
-#  include "vmsdir.h"
-# endif /* HAVE_VMSDIR_H */
+# include <ndir.h>
 #endif
 
 
@@ -511,7 +500,6 @@
 
   oldcount = pglob->gl_pathc + pglob->gl_offs;
 
-#ifndef VMS
   if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~')
     {
       if (dirname[1] == '\0' || dirname[1] == '/')
@@ -679,7 +667,6 @@
 	}
 # endif	/* Not Amiga && not WINDOWS32.  */
     }
-#endif	/* Not VMS.  */
 
   /* Now test whether we looked for "~" or "~NAME".  In this case we
      can give the answer now.  */
@@ -1132,7 +1119,7 @@
 	    {
 	      int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0)
 			       | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)
-#if defined _AMIGA || defined VMS
+#if defined _AMIGA || defined __VMS
 			       | FNM_CASEFOLD
 #endif
 			       );
--- a/lib/savedir.c
+++ b/lib/savedir.c
@@ -33,15 +33,7 @@
 # include <dirent.h>
 #else
 # define dirent direct
-# if HAVE_SYS_NDIR_H
-#  include <sys/ndir.h>
-# endif
-# if HAVE_SYS_DIR_H
-#  include <sys/dir.h>
-# endif
-# if HAVE_NDIR_H
-#  include <ndir.h>
-# endif
+# include <ndir.h>
 #endif
 
 #include <stddef.h>
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,17 @@
+2006-07-06  Derek R. Price  <derek@ximbiot.com>
+	and Paul Eggert  <eggert@cs.ucla.edu>
+
+	* backupfile.m4 (gl_BACKUPFILE): Check for dirent.h, instead
+	of invoking obsolescent AC_HEADER_DIRENT macro.
+	* d-ino.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_INO): Likewise.
+	* d-type.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE): Likewise.
+	* dirfd.m4 (gl_FUNC_DIRFD): Likewise.
+	* fts.m4 (gl_FUNC_FTS_CORE): Likewise.
+	* getcwd.m4 (gl_PREREQ_GETCWD): Likewise.
+	* glob.m4 (gl_PREREQ_GLOB): Likewise.
+	* savedir.m4 (gl_SAVEDIR): Likewise.
+	* readdir.m4: Remove; no longer needed.
+
 2006-07-06  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
 	* _inttypes_h.m4 (gl_INTTYPES_H): Use AC_CHECK_DECLS_ONCE
--- a/m4/backupfile.m4
+++ b/m4/backupfile.m4
@@ -1,5 +1,5 @@
-# backupfile.m4 serial 9
-dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# backupfile.m4 serial 10
+dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -10,7 +10,7 @@
   AC_LIBOBJ([backupfile])
 
   dnl Prerequisites of lib/backupfile.c.
-  AC_REQUIRE([AC_HEADER_DIRENT])
+  AC_CHECK_HEADERS_ONCE([dirent.h])
   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO])
   AC_REQUIRE([gl_AC_DOS])
   AC_REQUIRE([AC_SYS_LONG_FILE_NAMES])
--- a/m4/d-ino.m4
+++ b/m4/d-ino.m4
@@ -1,11 +1,11 @@
-#serial 7
+#serial 8
 
 dnl From Jim Meyering.
 dnl
 dnl Check whether struct dirent has a member named d_ino.
 dnl
 
-# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004 Free Software
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2006 Free Software
 # Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
@@ -13,7 +13,7 @@
 # with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO],
-  [AC_REQUIRE([AC_HEADER_DIRENT])dnl
+  [AC_CHECK_HEADERS_ONCE([dirent.h])dnl
    AC_CACHE_CHECK([for d_ino member in directory struct],
 		  jm_cv_struct_dirent_d_ino,
      [AC_TRY_LINK(dnl
@@ -21,18 +21,10 @@
 #include <sys/types.h>
 #ifdef HAVE_DIRENT_H
 # include <dirent.h>
-#else /* not HAVE_DIRENT_H */
+#else
 # define dirent direct
-# 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 */
+# include <ndir.h>
+#endif
        ],
        [struct dirent dp; dp.d_ino = 0;],
 
--- a/m4/d-type.m4
+++ b/m4/d-type.m4
@@ -1,11 +1,11 @@
-#serial 8
+#serial 9
 
 dnl From Jim Meyering.
 dnl
 dnl Check whether struct dirent has a member named d_type.
 dnl
 
-# Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
+# Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software
 # Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
@@ -13,7 +13,7 @@
 # with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE],
-  [AC_REQUIRE([AC_HEADER_DIRENT])dnl
+  [AC_CHECK_HEADERS_ONCE([dirent.h])dnl
    AC_CACHE_CHECK([for d_type member in directory struct],
 		  jm_cv_struct_dirent_d_type,
      [AC_TRY_LINK(dnl
@@ -21,18 +21,10 @@
 #include <sys/types.h>
 #ifdef HAVE_DIRENT_H
 # include <dirent.h>
-#else /* not HAVE_DIRENT_H */
+#else
 # define dirent direct
-# 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 */
+# include <ndir.h>
+#endif
        ],
        [struct dirent dp; dp.d_type = 0;],
 
--- a/m4/dirfd.m4
+++ b/m4/dirfd.m4
@@ -1,4 +1,4 @@
-#serial 11   -*- Autoconf -*-
+#serial 12   -*- Autoconf -*-
 
 dnl Find out how to get the file descriptor associated with an open DIR*.
 
@@ -17,23 +17,15 @@
   dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
   AC_REQUIRE([AC_PROG_CPP])
   AC_REQUIRE([AC_PROG_EGREP])
-  AC_REQUIRE([AC_HEADER_DIRENT])
+  AC_CHECK_HEADERS_ONCE([dirent.h])dnl
 
   dirfd_headers='
 #if HAVE_DIRENT_H
 # include <dirent.h>
-#else /* not HAVE_DIRENT_H */
+#else
 # define dirent direct
-# if HAVE_SYS_NDIR_H
-#  include <sys/ndir.h>
-# endif /* HAVE_SYS_NDIR_H */
-# if HAVE_SYS_DIR_H
-#  include <sys/dir.h>
-# endif /* HAVE_SYS_DIR_H */
-# if HAVE_NDIR_H
-#  include <ndir.h>
-# endif /* HAVE_NDIR_H */
-#endif /* HAVE_DIRENT_H */
+# include <ndir.h>
+#endif
 '
   AC_CHECK_FUNCS(dirfd)
   AC_CHECK_DECLS([dirfd], , , $dirfd_headers)
--- a/m4/fts.m4
+++ b/m4/fts.m4
@@ -1,5 +1,5 @@
-#serial 6
-dnl Copyright (C) 2005 Free Software Foundation, Inc.
+#serial 7
+dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -29,6 +29,5 @@
   dnl Prerequisites of lib/fts.c.
 
   # Checks for header files.
-  AC_REQUIRE([AC_HEADER_DIRENT])
-  AC_CHECK_HEADERS_ONCE([sys/param.h])
+  AC_CHECK_HEADERS_ONCE([dirent.h sys/param.h])dnl
 ])
--- a/m4/getcwd.m4
+++ b/m4/getcwd.m4
@@ -61,7 +61,7 @@
 AC_DEFUN([gl_PREREQ_GETCWD],
 [
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  AC_REQUIRE([AC_HEADER_DIRENT])
+  AC_CHECK_HEADERS_ONCE([dirent.h])dnl
   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO])
   :
 ])
--- a/m4/glob.m4
+++ b/m4/glob.m4
@@ -1,5 +1,5 @@
-# glob.m4 serial 3
-dnl Copyright (C) 2005 Free Software Foundation, Inc.
+# glob.m4 serial 4
+dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -74,7 +74,7 @@
 AC_DEFUN([gl_PREREQ_GLOB],
 [ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])dnl
   AC_REQUIRE([AC_GNU_SOURCE])dnl
-  AC_REQUIRE([AC_HEADER_DIRENT])dnl
+  AC_CHECK_HEADERS_ONCE([dirent.h])dnl
   AC_CHECK_HEADERS_ONCE([sys/cdefs.h unistd.h])dnl
   AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r])dnl
   :])
deleted file mode 100644
--- a/m4/readdir.m4
+++ /dev/null
@@ -1,140 +0,0 @@
-#serial 9
-
-# Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2006 Free Software
-# Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-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_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 <stdlib.h>
-#   include <sys/types.h>
-#   include <string.h>
-
-#   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
-])
--- a/m4/savedir.m4
+++ b/m4/savedir.m4
@@ -1,4 +1,4 @@
-# savedir.m4 serial 5
+# savedir.m4 serial 7
 dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,5 +10,5 @@
   AC_LIBOBJ([savedir])
 
   dnl Prerequisites of lib/savedir.c.
-  AC_REQUIRE([AC_HEADER_DIRENT])
+  AC_CHECK_HEADERS_ONCE([dirent.h])dnl
 ])