* lib/fts.c (fts_build): No semantic change.
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.
internal_function
fts_build (register FTS *sp, int type)
{
- register struct dirent *dp;
register FTSENT *p, *head;
register size_t nitems;
FTSENT *tail;
/* 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;