# HG changeset patch # User Jim Meyering # Date 1313565846 -7200 # Node ID ddc76c261e25dd317932403dc8e0543e82681694 # Parent 894e5e6ae541979580da8e29359045c725c560e2 maint: fts: move decl of `dp' down into while loop; split a long line * lib/fts.c (fts_build): No semantic change. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2011-08-19 Jim Meyering + 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. diff --git a/lib/fts.c b/lib/fts.c --- a/lib/fts.c +++ b/lib/fts.c @@ -1229,7 +1229,6 @@ 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 @@ /* 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;