maint: fts: move decl of `dp' down into while loop; split a long line
authorJim Meyering <meyering@redhat.com>
Wed, 17 Aug 2011 07:24:06 +0000 (09:24 +0200)
committerJim Meyering <meyering@redhat.com>
Fri, 19 Aug 2011 15:07:22 +0000 (17:07 +0200)
* lib/fts.c (fts_build): No semantic change.

ChangeLog
lib/fts.c

index c47ddc5..88108d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2011-08-19  Jim Meyering  <meyering@redhat.com>
 
+       maint: fts: move decl of `dp' down into while loop; split a long line
+       * lib/fts.c (fts_build): No semantic change.
+
        fts: add/use new struct member, fts_dirp
        We are about to use this to manage any directory with
        too many entries to read all of them into memory at once.
index 4d07d09..4d972c3 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -1229,7 +1229,6 @@ static FTSENT *
 internal_function
 fts_build (register FTS *sp, int type)
 {
-        register struct dirent *dp;
         register FTSENT *p, *head;
         register size_t nitems;
         FTSENT *tail;
@@ -1352,9 +1351,14 @@ fts_build (register FTS *sp, int type)
 
         /* Read the directory, attaching each entry to the `link' pointer. */
         doadjust = false;
-        for (head = tail = NULL, nitems = 0; cur->fts_dirp && (dp = readdir(cur->fts_dirp));) {
+        head = NULL;
+        tail = NULL;
+        nitems = 0;
+        while (cur->fts_dirp) {
                 bool is_dir;
-
+                struct dirent *dp = readdir(cur->fts_dirp);
+                if (dp == NULL)
+                        break;
                 if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
                         continue;