bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_HEADER_DIRENT


From: Derek R. Price
Subject: Re: AC_HEADER_DIRENT
Date: Mon, 10 Jul 2006 22:25:22 -0400
User-agent: Thunderbird 1.5.0.4 (Windows/20060516)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Paul Eggert wrote:

> The simplest thing is to simply omit all references to <ndir.h>, which
> is what I'm inclined to do unless someone speaks up.

I'm fine with that.  It was what my first pass at this did, actually.

I'm not quite sure what will happen on a Windows system that can run
configure like DJGPP.  It may find <win32/dirent.h>, but I think it may
 need CVS's windows-NT/dirent.h and not find it to test it for
gl_CHECK_TYPE_STRUCT_DIRENT_D_INO and
gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE.  Of course, no one is actually
compiling CVS under DJGPP right now, that I know of, to test this and
they will be no *worse* off, since they wouldn't have found <ndir.h> either.

Patch attached.  It also consolidates the NAMELEN macros into the GNU
_D_EXACT_NAMLEN, as was already being done in lib/getcwd.c and which may
result in a performance improvement on some systems.

2006-07-10  Derek R. Price  <derek@ximbiot.com>

        * lib/backupfile.c, lib/dirfd.h, lib/fts.c, lib/glob.c,
        lib/glob_.h, m4/d-ino.m4, m4/d-type.m4, m4/dirfd.m4: Ignore the
        obsolescent !HAVE_DIRENT_H case.  Consolidate NAMLEN macros into
        the GNU _D_EXACT_NAMLEN.
        * lib/savedir.c:  Likewise.
        (savedirstream): Use _D_EXACT_NAMLEN in preference to strlen.

Cheers,

Derek
- --
Derek R. Price
CVS Solutions Architect
Get CVS support at Ximbiot <http://ximbiot.com>!
v: +1 248.835.1260
f: +1 248.835.1263
<mailto:derek@ximbiot.com>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEswwSLD1OTBfyMaQRAn7uAKDrfz6+XdpP2n+2xyI9xfrMExIIzACgq4RC
VYNlh0iJWDD6JryxKWWLRGE=
=uWaN
-----END PGP SIGNATURE-----
Index: lib/backupfile.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/backupfile.c,v
retrieving revision 1.50
diff -u -p -r1.50 backupfile.c
--- lib/backupfile.c    6 Jul 2006 23:29:27 -0000       1.50
+++ lib/backupfile.c    11 Jul 2006 02:13:15 -0000
@@ -41,15 +41,10 @@
 
 #include <unistd.h>
 
-#if HAVE_DIRENT_H
-# include <dirent.h>
-# define NLENGTH(direct) strlen ((direct)->d_name)
-#else
-# define dirent direct
-# define NLENGTH(direct) ((size_t) (direct)->d_namlen)
-# include <ndir.h>
+#include <dirent.h>
+#ifndef _D_EXACT_NAMLEN
+# define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name)
 #endif
-
 #if D_INO_IN_DIRENT
 # define REAL_DIR_ENTRY(dp) ((dp)->d_ino != 0)
 #else
@@ -211,7 +206,7 @@ numbered_backup (char **buffer, size_t b
       size_t versionlen;
       size_t new_buflen;
 
-      if (! REAL_DIR_ENTRY (dp) || NLENGTH (dp) < baselen + 4)
+      if (! REAL_DIR_ENTRY (dp) || _D_EXACT_NAMLEN (dp) < baselen + 4)
        continue;
 
       if (memcmp (buf + base_offset, dp->d_name, baselen + 2) != 0)
Index: lib/dirfd.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/dirfd.h,v
retrieving revision 1.7
diff -u -p -r1.7 dirfd.h
--- lib/dirfd.h 6 Jul 2006 23:29:27 -0000       1.7
+++ lib/dirfd.h 11 Jul 2006 02:13:15 -0000
@@ -19,12 +19,7 @@
 
 #include <sys/types.h>
 
-#if HAVE_DIRENT_H
-# include <dirent.h>
-#else
-# define dirent direct
-# include <ndir.h>
-#endif
+#include <dirent.h>
 
 #ifndef HAVE_DECL_DIRFD
 "this configure-time declaration test was not run"
Index: lib/fts.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/fts.c,v
retrieving revision 1.12
diff -u -p -r1.12 fts.c
--- lib/fts.c   6 Jul 2006 23:29:27 -0000       1.12
+++ lib/fts.c   11 Jul 2006 02:13:16 -0000
@@ -75,17 +75,9 @@ static char sccsid[] = "@(#)fts.c    8.6 (B
 # include "lstat.h"
 #endif
 
-#if HAVE_DIRENT_H || _LIBC
-# include <dirent.h>
-# ifdef _D_EXACT_NAMLEN
-#  define NAMLEN(dirent) _D_EXACT_NAMLEN (dirent)
-# else
-#  define NAMLEN(dirent) strlen ((dirent)->d_name)
-# endif
-#else
-# define dirent direct
-# define NAMLEN(dirent) (dirent)->d_namlen
-# include <ndir.h>
+#include <dirent.h>
+#ifndef _D_EXACT_NAMLEN
+# define _D_EXACT_NAMLEN(dirent) strlen ((dirent)->d_name)
 #endif
 
 #ifdef _LIBC
@@ -829,11 +821,13 @@ fts_build (register FTS *sp, int type)
                if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
                        continue;
 
-               if ((p = fts_alloc(sp, dp->d_name, NAMLEN (dp))) == NULL)
+               if ((p = fts_alloc (sp, dp->d_name,
+                                   _D_EXACT_NAMLEN (dp))) == NULL)
                        goto mem1;
-               if (NAMLEN (dp) >= maxlen) {/* include space for NUL */
+               if (_D_EXACT_NAMLEN (dp) >= maxlen) {
+                       /* include space for NUL */
                        oldaddr = sp->fts_path;
-                       if (! fts_palloc(sp, NAMLEN (dp) + len + 1)) {
+                       if (! fts_palloc(sp, _D_EXACT_NAMLEN (dp) + len + 1)) {
                                /*
                                 * No more memory.  Save
                                 * errno, free up the current structure and the
@@ -858,7 +852,7 @@ mem1:                               saved_errno = errno;
                        maxlen = sp->fts_pathlen - len;
                }
 
-               new_len = len + NAMLEN (dp);
+               new_len = len + _D_EXACT_NAMLEN (dp);
                if (new_len < len) {
                        /*
                         * In the unlikely even that we would end up
Index: lib/getcwd.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/getcwd.c,v
retrieving revision 1.13
diff -u -p -r1.13 getcwd.c
--- lib/getcwd.c        6 Jul 2006 23:29:27 -0000       1.13
+++ lib/getcwd.c        11 Jul 2006 02:13:16 -0000
@@ -36,13 +36,7 @@
 # define __set_errno(val) (errno = (val))
 #endif
 
-#if HAVE_DIRENT_H || _LIBC
-# include <dirent.h>
-#else
-# define dirent direct
-# define _D_EXACT_NAMLEN(d) (d)->d_namlen
-# include <ndir.h>
-#endif
+#include <dirent.h>
 #ifndef _D_EXACT_NAMLEN
 # define _D_EXACT_NAMLEN(d) strlen ((d)->d_name)
 #endif
Index: lib/glob.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/glob.c,v
retrieving revision 1.7
diff -u -p -r1.7 glob.c
--- lib/glob.c  6 Jul 2006 23:29:27 -0000       1.7
+++ lib/glob.c  11 Jul 2006 02:13:16 -0000
@@ -47,20 +47,12 @@
 # define __set_errno(val) errno = (val)
 #endif
 
-#if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__
-# include <dirent.h>
-# define NAMLEN(dirent) strlen((dirent)->d_name)
-#else
-# define dirent direct
-# define NAMLEN(dirent) (dirent)->d_namlen
-# include <ndir.h>
-#endif
+#include <dirent.h>
 
 
 /* In GNU systems, <dirent.h> defines this macro for us.  */
-#ifdef _D_NAMLEN
-# undef NAMLEN
-# define NAMLEN(d) _D_NAMLEN(d)
+#ifndef _D_EXACT_NAMLEN
+# define _D_EXACT_NAMLEN(dirent) strlen ((dirent)->d_name)
 #endif
 
 /* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available
@@ -86,13 +78,6 @@
 
 /* If the system has the `struct dirent64' type we use it internally.  */
 #if defined _LIBC && !defined COMPILE_GLOB64
-# if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__
-#  define CONVERT_D_NAMLEN(d64, d32)
-# else
-#  define CONVERT_D_NAMLEN(d64, d32) \
-  (d64)->d_namlen = (d32)->d_namlen;
-# endif
-
 # if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
 #  define CONVERT_D_INO(d64, d32)
 # else
@@ -109,7 +94,6 @@
 
 # define CONVERT_DIRENT_DIRENT64(d64, d32) \
   memcpy ((d64)->d_name, (d32)->d_name, NAMLEN (d32) + 1);                   \
-  CONVERT_D_NAMLEN (d64, d32)                                                \
   CONVERT_D_INO (d64, d32)                                                   \
   CONVERT_D_TYPE (d64, d32)
 #endif
Index: lib/glob_.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/glob_.h,v
retrieving revision 1.5
diff -u -p -r1.5 glob_.h
--- lib/glob_.h 10 Jan 2006 21:49:07 -0000      1.5
+++ lib/glob_.h 11 Jul 2006 02:13:16 -0000
@@ -46,10 +46,6 @@
 #endif
 
 
-#ifndef HAVE_DIRENT_H
-# define dirent direct
-#endif
-
 #define glob rpl_glob
 #define globfree rpl_globfree
 #define glob_pattern_p rpl_glob_pattern_p
Index: lib/savedir.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/savedir.c,v
retrieving revision 1.30
diff -u -p -r1.30 savedir.c
--- lib/savedir.c       6 Jul 2006 23:29:27 -0000       1.30
+++ lib/savedir.c       11 Jul 2006 02:13:16 -0000
@@ -29,11 +29,9 @@
 
 #include <errno.h>
 
-#if HAVE_DIRENT_H
-# include <dirent.h>
-#else
-# define dirent direct
-# include <ndir.h>
+#include <dirent.h>
+#ifndef _D_EXACT_NAMLEN
+# define _D_EXACT_NAMLEN(dp)   strlen ((dp)->d_name)
 #endif
 
 #include <stddef.h>
@@ -81,7 +79,7 @@ savedirstream (DIR *dirp)
       entry = dp->d_name;
       if (entry[entry[0] != '.' ? 0 : entry[1] != '.' ? 1 : 2] != '\0')
        {
-         size_t entry_size = strlen (entry) + 1;
+         size_t entry_size = _D_EXACT_NAMLEN (dp) + 1;
          if (used + entry_size < used)
            xalloc_die ();
          if (allocated <= used + entry_size)
Index: m4/d-ino.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/d-ino.m4,v
retrieving revision 1.9
diff -u -p -r1.9 d-ino.m4
--- m4/d-ino.m4 6 Jul 2006 23:29:27 -0000       1.9
+++ m4/d-ino.m4 11 Jul 2006 02:13:16 -0000
@@ -13,18 +13,12 @@ dnl
 # with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO],
-  [AC_CHECK_HEADERS_ONCE([dirent.h])dnl
-   AC_CACHE_CHECK([for d_ino member in directory struct],
+  [AC_CACHE_CHECK([for d_ino member in directory struct],
                  jm_cv_struct_dirent_d_ino,
      [AC_TRY_LINK(dnl
        [
 #include <sys/types.h>
-#ifdef HAVE_DIRENT_H
-# include <dirent.h>
-#else
-# define dirent direct
-# include <ndir.h>
-#endif
+#include <dirent.h>
        ],
        [struct dirent dp; dp.d_ino = 0;],
 
Index: m4/d-type.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/d-type.m4,v
retrieving revision 1.10
diff -u -p -r1.10 d-type.m4
--- m4/d-type.m4        6 Jul 2006 23:29:27 -0000       1.10
+++ m4/d-type.m4        11 Jul 2006 02:13:16 -0000
@@ -13,18 +13,12 @@ dnl
 # with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE],
-  [AC_CHECK_HEADERS_ONCE([dirent.h])dnl
-   AC_CACHE_CHECK([for d_type member in directory struct],
+  [AC_CACHE_CHECK([for d_type member in directory struct],
                  jm_cv_struct_dirent_d_type,
      [AC_TRY_LINK(dnl
        [
 #include <sys/types.h>
-#ifdef HAVE_DIRENT_H
-# include <dirent.h>
-#else
-# define dirent direct
-# include <ndir.h>
-#endif
+#include <dirent.h>
        ],
        [struct dirent dp; dp.d_type = 0;],
 
Index: m4/dirfd.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/dirfd.m4,v
retrieving revision 1.20
diff -u -p -r1.20 dirfd.m4
--- m4/dirfd.m4 6 Jul 2006 23:29:27 -0000       1.20
+++ m4/dirfd.m4 11 Jul 2006 02:13:16 -0000
@@ -17,22 +17,12 @@ AC_DEFUN([gl_FUNC_DIRFD],
   dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
   AC_REQUIRE([AC_PROG_CPP])
   AC_REQUIRE([AC_PROG_EGREP])
-  AC_CHECK_HEADERS_ONCE([dirent.h])dnl
-
-  dirfd_headers='
-#if HAVE_DIRENT_H
-# include <dirent.h>
-#else
-# define dirent direct
-# include <ndir.h>
-#endif
-'
   AC_CHECK_FUNCS(dirfd)
-  AC_CHECK_DECLS([dirfd], , , $dirfd_headers)
+  AC_CHECK_DECLS([dirfd], , , [#include <dirent.h>])
 
   AC_CACHE_CHECK([whether dirfd is a macro],
     gl_cv_func_dirfd_macro,
-    [AC_EGREP_CPP([dirent_header_defines_dirfd], [$dirfd_headers
+    [AC_EGREP_CPP([dirent_header_defines_dirfd], [#include <dirent.h>
 #ifdef dirfd
  dirent_header_defines_dirfd
 #endif],
@@ -53,7 +43,7 @@ AC_DEFUN([gl_FUNC_DIRFD],
 
          CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
          AC_TRY_COMPILE(
-           [$dirfd_headers
+           [#include <dirent.h>
            ],
            [DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;],
            dir_fd_found=yes

reply via email to

[Prev in Thread] Current Thread [Next in Thread]