* fts.c: Include fts_.h first, to check interface.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 18 May 2005 19:47:06 +0000 (19:47 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 18 May 2005 19:47:06 +0000 (19:47 +0000)
Do not include intprops.h; no longer needed.
Include cycle-check.h and hash.h, since fts_.h no longer does.
Remove unnecessary casts of closedir to void.
(fts_build): Use a simpler method (not involving TYPE_SIGNED) to
decide whether to decrement nlinks.
* fts_.h: Do not include hash.h or cycle-check.h; no longer needed.
(FTS): Use struct hash_table * instead of Hash_table, so that
we no longer need to include hash.h here.
* fts.m4 (gl_FUNC_FTS): Don't require AC_HEADER_STDC, as we
don't use its results.
Don't check for fcntl.h, stddef.h, stdlib.h, string.h, unistd.h,
since we include them unconditionally.  Don't require
AM_STDBOOL_H, since stdbool is a prerequisite.
Don't require AC_C_CONST, AC_TYPE_SIZE_T or check for ptrdiff_t
since we assume C89 or better.
Don't require AC_FUNC_CLOSEDIR_VOID, AC_FUNC_LSTAT, or AC_FUNC_STAT,
as we don't use their results.
Don't check for fchdir, memmove, memset, strrchr, as we use
them unconditionally.

lib/fts.c
lib/fts_.h
m4/fts.m4

index 11ec512..07737a1 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -53,6 +53,8 @@
 static char sccsid[] = "@(#)fts.c      8.6 (Berkeley) 8/14/94";
 #endif /* LIBC_SCCS and not lint */
 
+#include "fts_.h"
+
 #if HAVE_SYS_PARAM_H || defined _LIBC
 # include <sys/param.h>
 #endif
@@ -64,9 +66,10 @@ static char sccsid[] = "@(#)fts.c    8.6 (Berkeley) 8/14/94";
 #include <fcntl.h>
 #include <errno.h>
 #include "dirfd.h"
-#include "fts_.h"
-#include "intprops.h"
+#include "cycle-check.h"
+#include "hash.h"
 #include "unistd-safer.h"
+#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -926,7 +929,7 @@ fts_build (register FTS *sp, int type)
                        cur->fts_flags |= FTS_DONTCHDIR;
                        descend = false;
                        cderrno = errno;
-                       (void)closedir(dirp);
+                       closedir(dirp);
                        dirp = NULL;
                } else
                        descend = true;
@@ -976,7 +979,7 @@ mem1:                               saved_errno = errno;
                                if (p)
                                        free(p);
                                fts_lfree(head);
-                               (void)closedir(dirp);
+                               closedir(dirp);
                                cur->fts_info = FTS_ERR;
                                SET(FTS_STOP);
                                __set_errno (saved_errno);
@@ -1001,7 +1004,7 @@ mem1:                             saved_errno = errno;
                         */
                        free(p);
                        fts_lfree(head);
-                       (void)closedir(dirp);
+                       closedir(dirp);
                        cur->fts_info = FTS_ERR;
                        SET(FTS_STOP);
                        __set_errno (ENAMETOOLONG);
@@ -1043,11 +1046,9 @@ mem1:                            saved_errno = errno;
                        p->fts_info = fts_stat(sp, p, false);
 
                        /* Decrement link count if applicable. */
-                       if (nlinks > 0
-                           && (TYPE_SIGNED (nlink_t) || nostat)
-                           && (p->fts_info == FTS_D ||
+                       if (nlinks > 0 && (p->fts_info == FTS_D ||
                            p->fts_info == FTS_DC || p->fts_info == FTS_DOT))
-                               --nlinks;
+                               nlinks -= nostat;
                }
 
                /* We walk in directory order so "ls -f" doesn't get upset. */
@@ -1061,7 +1062,7 @@ mem1:                             saved_errno = errno;
                ++nitems;
        }
        if (dirp)
-               (void)closedir(dirp);
+               closedir(dirp);
 
        /*
         * If realloc() changed the address of the path, adjust the
index b932cf7..5c5e1c2 100644 (file)
@@ -63,8 +63,7 @@
 
 # include <stddef.h>
 # include <sys/types.h>
-# include "hash.h"
-# include "cycle-check.h"
+# include <sys/stat.h>
 
 typedef struct {
        struct _ftsent *fts_cur;        /* current node */
@@ -116,7 +115,7 @@ typedef struct {
           and promptly even when the depth of a hierarchy is in the tens
           of thousands.  Lazy checking, as done by GNU rm via cycle-check.c,
           wouldn't be appropriate for du.  */
-       Hash_table *active_dir_ht;
+       struct hash_table *active_dir_ht;
        struct cycle_check_state *cycle_state;
 } FTS;
 
index e549305..f28f8be 100644 (file)
--- a/m4/fts.m4
+++ b/m4/fts.m4
@@ -6,7 +6,7 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_FUNC_FTS],
 [
-  AC_LIBSOURCES([fts.c, fts_.h, intprops.h])
+  AC_LIBSOURCES([fts.c, fts_.h])
 
   dnl Use this version of fts unconditionally, since the GNU libc and
   dnl NetBSD versions have bugs and/or unnecessary limitations.
@@ -16,21 +16,12 @@ AC_DEFUN([gl_FUNC_FTS],
 
   # Checks for header files.
   AC_REQUIRE([AC_HEADER_DIRENT])
-  AC_REQUIRE([AC_HEADER_STDC])
-  AC_CHECK_HEADERS_ONCE([fcntl.h inttypes.h stddef.h stdint.h])
-  AC_CHECK_HEADERS_ONCE([stdlib.h string.h sys/param.h unistd.h])
+  AC_CHECK_HEADERS_ONCE([inttypes.h stdint.h])
+  AC_CHECK_HEADERS_ONCE([sys/param.h])
 
   # Checks for typedefs, structures, and compiler characteristics.
-  AC_REQUIRE([AM_STDBOOL_H])
-  AC_REQUIRE([AC_C_CONST])
-  AC_REQUIRE([AC_TYPE_SIZE_T])
   AC_REQUIRE([gt_INTTYPES_PRI])
-  AC_CHECK_TYPES([ptrdiff_t])
 
   # Checks for library functions.
-  AC_REQUIRE([AC_FUNC_CLOSEDIR_VOID])
-  AC_REQUIRE([AC_FUNC_LSTAT])
   AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
-  AC_REQUIRE([AC_FUNC_STAT])
-  AC_CHECK_FUNCS_ONCE([fchdir memmove memset strrchr])
 ])