Fix a bug in yesterday's change.
authorJim Meyering <jim@meyering.net>
Sat, 14 Oct 2006 06:32:48 +0000 (06:32 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 14 Oct 2006 06:32:48 +0000 (06:32 +0000)
* lib/fts.c (fts_open): When using FTS_XDEV|FTS_NOSTAT,
p->fts_statp->st_dev would be used uninitialized.
Ensures that we always call fts_stat on the very first entry.
Miklos Szeredi reported that find -xdev stopped working.

ChangeLog
lib/fts.c

index f0201b3..561bfdb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-10-13  Jim Meyering  <jim@meyering.net>
+
+       Fix a bug in yesterday's change.
+       * lib/fts.c (fts_open): When using FTS_XDEV|FTS_NOSTAT,
+       p->fts_statp->st_dev would be used uninitialized.
+       Ensures that we always call fts_stat on the very first entry.
+       Miklos Szeredi reported that find -xdev stopped working.
+
 2006-10-12  Bruno Haible  <bruno@clisp.org>
 
        * gnulib-tool (func_get_automake_snippet): Append an automatically
index 05cd67c..fc6bbd3 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -396,7 +396,10 @@ fts_open (char * const *argv,
                p->fts_level = FTS_ROOTLEVEL;
                p->fts_parent = parent;
                p->fts_accpath = p->fts_name;
-               if (defer_stat) {
+               /* Even when defer_stat is true, be sure to stat the first
+                  command line argument, since fts_read (at least with
+                  FTS_XDEV) requires that.  */
+               if (defer_stat && root != NULL) {
                        p->fts_info = FTS_NSOK;
                        fts_set_stat_required(p, true);
                } else {