? build-aux/Makefile.am
? build-aux/Makefile.in
? build-aux/config.guess
? build-aux/config.sub
? build-aux/depcomp
? build-aux/install-sh
? build-aux/mdate-sh
? build-aux/missing
? build-aux/mkinstalldirs
? build-aux/texinfo.tex
Index: ChangeLog
===================================================================
RCS file: /sources/findutils/findutils/ChangeLog,v
retrieving revision 1.149
diff -u -p -r1.149 ChangeLog
--- ChangeLog	15 Apr 2007 19:17:48 -0000	1.149
+++ ChangeLog	16 Apr 2007 20:21:14 -0000
@@ -1,3 +1,11 @@
+2007-04-16    James Youngman  <jay@gnu.org>
+
+	* find/testsuite/find.posix/exec-many-return-failure.exp: The
+	command we run for this test case should return nonzero.
+
+	* find/testsuite/config/unix.exp: Correctly interpret the return
+	valid for expect-failure cases.
+
 2007-04-15  James Youngman  <jay@gnu.org>
 
  	* find/find.1: "-printf %b": blocks are 512 bytes.   Fixes
Index: find/find.c
===================================================================
RCS file: /sources/findutils/findutils/find/find.c,v
retrieving revision 1.112
diff -u -p -r1.112 find.c
--- find/find.c	15 Apr 2007 18:57:39 -0000	1.112
+++ find/find.c	16 Apr 2007 20:21:14 -0000
@@ -84,7 +84,7 @@ static void init_mounted_dev_list(int ma
 
 static void process_top_path PARAMS((char *pathname, mode_t mode));
 static int process_path PARAMS((char *pathname, char *name, boolean leaf, char *parent, mode_t type));
-static void process_dir PARAMS((char *pathname, char *name, int pathlen, struct stat *statp, char *parent));
+static void process_dir PARAMS((char *pathname, char *name, int pathlen, const struct stat *statp, char *parent));
 
 
 
@@ -1164,17 +1164,10 @@ process_path (char *pathname, char *name
   /* Now we really need to stat the directory, even if we know the
    * type, because we need information like struct stat.st_rdev.
    */
-  if (0 == stat_buf.st_mode)
-    {
-      /* This call was made conditional on Sat Apr 14 16:01:01 2007,
-       * and at that time the test suite passed without it.  Omitting
-       * this stat call saves a lot of system calls.
-       */
-      if (get_statinfo(pathname, name, &stat_buf) != 0)
-	return 0;
+  if (get_statinfo(pathname, name, &stat_buf) != 0)
+    return 0;
 
-      state.have_stat = true;
-    }
+  state.have_stat = true;
   mode = state.type = stat_buf.st_mode;	/* use full info now that we have it. */
   state.stop_at_current_level =
     options.maxdepth >= 0
@@ -1215,8 +1208,10 @@ process_path (char *pathname, char *name
 	    pathname, state.stop_at_current_level);
   
   if (state.stop_at_current_level == false)
-    /* Scan directory on disk. */
-    process_dir (pathname, name, strlen (pathname), &stat_buf, parent);
+    {
+      /* Scan directory on disk. */
+      process_dir (pathname, name, strlen (pathname), &stat_buf, parent);
+    }
 
   if (options.do_dir_first == false && state.curdepth >= options.mindepth)
     {
@@ -1253,15 +1248,21 @@ process_path (char *pathname, char *name
    starting directory.  */
 
 static void
-process_dir (char *pathname, char *name, int pathlen, struct stat *statp, char *parent)
+process_dir (char *pathname, char *name, int pathlen, const struct stat *statp, char *parent)
 {
   int subdirs_left;		/* Number of unexamined subdirs in PATHNAME. */
   boolean subdirs_unreliable;	/* if true, cannot use dir link count as subdir limif (if false, it may STILL be unreliable) */
   unsigned int idx;		/* Which entry are we on? */
   struct stat stat_buf;
-
+  size_t dircount = 0u;
   struct savedir_dirinfo *dirinfo;
-
+#if 0
+  printf("process_dir: pathname=%s name=%s statp->st_nlink=%d st_ino=%d\n",
+	 pathname,
+	 name,
+	 (int)statp->st_nlink,
+	 (int)statp->st_ino);
+#endif  
   if (statp->st_nlink < 2)
     {
       subdirs_unreliable = true;
@@ -1398,8 +1399,10 @@ process_dir (char *pathname, char *name,
 		   * doesn't really handle hard links with Unix semantics.
 		   * In the latter case, -noleaf should be used routinely.
 		   */
-		  error(0, 0, _("WARNING: Hard link count is wrong for %s: this may be a bug in your filesystem driver.  Automatically turning on find's -noleaf option.  Earlier results may have failed to include directories that should have been searched."),
-			pathname);
+		  error(0, 0, _("WARNING: Hard link count is wrong for %s (saw only st_nlink=%d but we already saw %d subdirectories): this may be a bug in your filesystem driver.  Automatically turning on find's -noleaf option.  Earlier results may have failed to include directories that should have been searched."),
+			pathname,
+			statp->st_nlink,
+			dircount);
 		  state.exit_status = 1; /* We know the result is wrong, now */
 		  options.no_leaf_check = true;	/* Don't make same
 						   mistake again */
@@ -1415,9 +1418,14 @@ process_dir (char *pathname, char *name,
 		 there are additional links, we know that the rest of
 		 the entries are non-directories -- in other words,
 		 leaf files. */
-	      subdirs_left -= process_path (cur_path, cur_name,
+	      {
+		int count;
+		count = process_path (cur_path, cur_name,
 					    subdirs_left == 0, pathname,
 					    mode);
+		subdirs_left -= count;
+		dircount += count;
+	      }
 	    }
 	  else
 	    {
Index: find/ftsfind.c
===================================================================
RCS file: /sources/findutils/findutils/find/ftsfind.c,v
retrieving revision 1.23
diff -u -p -r1.23 ftsfind.c
--- find/ftsfind.c	15 Apr 2007 18:57:40 -0000	1.23
+++ find/ftsfind.c	16 Apr 2007 20:21:14 -0000
@@ -428,7 +428,8 @@ consider_visiting(FTS *p, FTSENT *ent)
       error_severity(1);
       return;
     }
-  else if (ent->fts_info == FTS_SLNONE)
+  else if (ent->fts_info == FTS_SLNONE
+	   || ent->fts_info == FTS_NS)
     {
       /* fts_read() claims that ent->fts_accpath is a broken symbolic
        * link.  That would be fine, but if this is part of a symbolic
Index: find/testsuite/config/unix.exp
===================================================================
RCS file: /sources/findutils/findutils/find/testsuite/config/unix.exp,v
retrieving revision 1.20
diff -u -p -r1.20 unix.exp
--- find/testsuite/config/unix.exp	22 Jan 2007 10:56:47 -0000	1.20
+++ find/testsuite/config/unix.exp	16 Apr 2007 20:21:14 -0000
@@ -89,11 +89,10 @@ proc find_version {} {
     }
 }
 
-# Run find and leave the output in $comp_output.
+# Run find 
 # Called by individual test scripts.
 proc do_find_start { suffix findprogram flags passfail options infile output } {
     global verbose
-    global comp_output
 
     set scriptname [uplevel {info script}]
     set testbase [file rootname $scriptname]
@@ -139,26 +138,38 @@ proc do_find_start { suffix findprogram 
 	set infile /dev/null
     }
 
-    set cmd "$findprogram $flags $options < $infile | sort > find.out"
+    set cmd "$findprogram $flags $options < $infile > find.out.uns"
     send_log "$cmd\n"
     if $verbose>1 then {
 	send_user "Spawning \"$cmd\"\n"
     }
 
-    catch "exec $cmd" comp_output
-    if {$comp_output != ""} then {
-	send_log "$comp_output\n"
-	if $verbose>1 then {
-	    send_user "$comp_output\n"
+    if $fail_good then {
+	send_log "Hoping for this command to return nonzero\n"
+    } else {
+	send_log "Hoping for this command to return 0\n"
+    }
+    set failed [ catch "exec $cmd" result ] 
+    send_log "return value is $failed, result is '$result'\n"
+    if $failed {
+	# The command failed.
+	if $fail_good then {
+	    send_log "As expected, $cmd returned nonzero\n"
+	} else {
+	    fail "$testname, $result"
 	}
+    } else {
+	# The command returned 0.
 	if $fail_good then {
-	    pass "$testname"
+	    fail "$testname, $result"
 	} else {
-	    fail "$testname, $comp_output"
+	    send_log "As expected, $cmd returned 0\n"
 	}
-	return
     }
 
+    exec sort < find.out.uns > find.out
+    file delete find.out.uns
+
     if [file exists $outfile] then {
 	# We use the 'sort' above to sort the output of find to ensure
 	# that the directory entries appear in a predictable order.
@@ -192,7 +203,6 @@ proc find_start { passfail options {infi
     global OLDFIND
     global FTSFIND
     global FINDFLAGS
-    global comp_output
     global SKIP_OLD
     global SKIP_NEW
 
Index: find/testsuite/find.gnu/exec-many-rtn-failure.exp
===================================================================
RCS file: /sources/findutils/findutils/find/testsuite/find.gnu/exec-many-rtn-failure.exp,v
retrieving revision 1.1
diff -u -p -r1.1 exec-many-rtn-failure.exp
--- find/testsuite/find.gnu/exec-many-rtn-failure.exp	17 Jan 2005 21:08:39 -0000	1.1
+++ find/testsuite/find.gnu/exec-many-rtn-failure.exp	16 Apr 2007 20:21:14 -0000
@@ -1,4 +1,4 @@
 # POSIX: If the invoked command fails, -exec still returns true if it
 # was punctuated with +, because that always returns true.  However,
 # the program as a whole should return a NON-zero exit status.
-find_start f { /tmp -exec true \{\} + -printf "yep\n" -quit }
+find_start f { /tmp -exec false \{\} + -printf "yep\n" -quit }
Index: find/testsuite/find.posix/sv-bug-19605.exp
===================================================================
RCS file: find/testsuite/find.posix/sv-bug-19605.exp
diff -N find/testsuite/find.posix/sv-bug-19605.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ find/testsuite/find.posix/sv-bug-19605.exp	16 Apr 2007 20:21:14 -0000
@@ -0,0 +1,7 @@
+# tests for Savannah bug 19605 (Inability of ftsfind to detect sym;link loop)
+exec rm -rf  tmp
+exec mkdir tmp
+exec ln -s a tmp/b
+exec ln -s b tmp/a
+find_start f {-L tmp -false -print}
+#exec rm -rf tmp
