PERFORCE change 11204 for review

[email protected] (Chris Nandor) Sat, 7 Jul 2001 21:01:14 -0400
Newsgroups perl.perl5.changes.mac
Message-ID <p05100317b76d614d028a@[10.0.1.177]>
Change 11204 by pudge@pudge-mobile on 2001/07/07 23:53:37

	Sync up the File::Find changes from the rewrite by
	Thomas Wegner, et al.

Affected files ...

... //depot/maint-5.6/macperl/lib/File/Find.pm#3 edit
... //depot/maint-5.6/macperl/t/lib/filefind-taint.t#1 add
... //depot/maint-5.6/macperl/t/lib/filefind.t#3 edit

Differences ...

==== //depot/maint-5.6/macperl/lib/File/Find.pm#3 (text) ====
Index: perl/lib/File/Find.pm
--- perl/lib/File/Find.pm.~1~	Sat Jul  7 18:00:05 2001
+++ perl/lib/File/Find.pm	Sat Jul  7 18:00:05 2001
@@ -1,6 +1,8 @@
 package File::Find;
+use strict;
 use warnings;
 use 5.6.0;
+our $VERSION = '1.01';
 require Exporter;
 require Cwd;
 
@@ -45,19 +47,24 @@
 
 =item C<preprocess>
 
-The value should be a code reference.  This code reference is used to
-preprocess a directory; it is called after readdir() but before the loop that
-calls the wanted() function.  It is called with a list of strings and is
-expected to return a list of strings.  The code can be used to sort the
-strings alphabetically, numerically, or to filter out directory entries based
-on their name alone.
+The value should be a code reference. This code reference is used to 
+preprocess the current directory. The name of currently processed 
+directory is in $File::Find::dir. Your preprocessing function is 
+called after readdir() but before the loop that calls the wanted() 
+function. It is called with a list of strings (actually file/directory 
+names) and is expected to return a list of strings. The code can be 
+used to sort the file/directory names alphabetically, numerically, 
+or to filter out directory entries based on their name alone. When 
+I<follow> or I<follow_fast> are in effect, C<preprocess> is a no-op.
 
 =item C<postprocess>
 
-The value should be a code reference.  It is invoked just before leaving the
-current directory.  It is called in void context with no arguments.  The name
-of the current directory is in $File::Find::dir.  This hook is handy for
-summarizing a directory, such as calculating its disk usage.
+The value should be a code reference. It is invoked just before leaving 
+the currently processed directory. It is called in void context with no 
+arguments. The name of the current directory is in $File::Find::dir. This 
+hook is handy for summarizing a directory, such as calculating its disk 
+usage. When I<follow> or I<follow_fast> are in effect, C<postprocess> is a 
+no-op.
 
 =item C<follow>
 
@@ -101,7 +108,14 @@
 C<follow_skip==2> causes File::Find to ignore any duplicate files and
 directories but to proceed normally otherwise.
 
+=item C<dangling_symlinks>
 
+If true and a code reference, will be called with the symbolic link
+name and the directory it lives in as arguments.  Otherwise, if true
+and warnings are on, warning "symbolic_link_name is a dangling
+symbolic link\n" will be issued.  If false, the dangling symbolic link
+will be silently ignored.
+
 =item C<no_chdir>
 
 Does not C<chdir()> to each directory as it recurses. The wanted()
@@ -112,9 +126,10 @@
 
 If find is used in taint-mode (-T command line switch or if EUID != UID
 or if EGID != GID) then internally directory names have to be untainted
-before they can be cd'ed to. Therefore they are checked against a regular
-expression I<untaint_pattern>.  Note that all names passed to the
-user's I<wanted()> function are still tainted. 
+before they can be chdir'ed to. Therefore they are checked against a regular
+expression I<untaint_pattern>.  Note that all names passed to the user's 
+I<wanted()> function are still tainted. If this option is used while 
+not in taint-mode, C<untaint> is a no-op.
 
 =item C<untaint_pattern>
 
@@ -124,8 +139,8 @@
 
 =item C<untaint_skip>
 
-If set, directories (subtrees) which fail the I<untaint_pattern>
-are skipped. The default is to 'die' in such a case.
+If set, a directory which fails the I<untaint_pattern> is skipped, 
+including all its sub-directories. The default is to 'die' in such a case.
 
 =back
 
@@ -134,7 +149,7 @@
 current filename within that directory.  C<$File::Find::name> contains
 the complete pathname to the file. You are chdir()'d to
 C<$File::Find::dir> when the function is called, unless C<no_chdir>
-was specified.  When <follow> or <follow_fast> are in effect, there is
+was specified.  When C<follow> or C<follow_fast> are in effect, there is
 also a C<$File::Find::fullname>.  The function may set
 C<$File::Find::prune> to prune the tree unless C<bydepth> was
 specified.  Unless C<follow> or C<follow_fast> is specified, for
@@ -215,7 +230,7 @@
 =item *   
 
 The default C<untaint_pattern> (see above) on Mac OS is set to  
-C<qr|^(.+)$|s>. Note that the parentheses are vital.
+C<qr|^(.+)$|>. Note that the parentheses are vital.
 
 =item *   
 
@@ -228,7 +243,7 @@
 
  use Mac::Files;
 
- # invisible():  returns 1 if file/directory is invisible,  
+ # invisible() --  returns 1 if file/directory is invisible,  
  # 0 if it's visible or undef if an error occured
 
  sub invisible($) { 
@@ -245,7 +260,7 @@
  }
 
 Generally, invisible files are system files, unless an odd application 
-decides to use invisible files for it's own purposes. To distinguish 
+decides to use invisible files for its own purposes. To distinguish 
 such files from system files, you have to look at the B<type> and B<creator> 
 file attributes. The MacPerl built-in functions C<GetFileInfo(FILE)> and 
 C<SetFileInfo(CREATOR, TYPE, FILES)> offer access to these attributes 
@@ -260,10 +275,16 @@
 
 =back
 
+=head1 HISTORY
+
+File::Find used to produce incorrect results if called recursively.
+During the development of perl 5.8 this bug was fixed.
+The first fixed version of File::Find was 1.01.
+
 =cut
 
-@ISA = qw(Exporter);
-@EXPORT = qw(find finddepth);
+our @ISA = qw(Exporter);
+our @EXPORT = qw(find finddepth);
 
 
 use strict;
@@ -273,10 +294,13 @@
 require File::Basename;
 require File::Spec;
 
-my %SLnkSeen;
-my ($wanted_callback, $avoid_nlink, $bydepth, $no_chdir, $follow,
+# Should ideally be my() not our() but local() currently
+# refuses to operate on lexicals
+
+our %SLnkSeen;
+our ($wanted_callback, $avoid_nlink, $bydepth, $no_chdir, $follow,
     $follow_skip, $full_check, $untaint, $untaint_skip, $untaint_pat,
-    $pre_process, $post_process);
+    $pre_process, $post_process, $dangling_symlinks);
 
 sub contract_name {
     my ($cdir,$fn) = @_;
@@ -290,7 +314,7 @@
     my $abs_name= $cdir . $fn;
 
     if (substr($fn,0,3) eq '../') {
-	do 1 while ($abs_name=~ s|/(?>[^/]+)/\.\./|/|);
+       1 while $abs_name =~ s!/[^/]*/\.\./!/!;
     }
 
     return $abs_name;
@@ -330,7 +354,7 @@
 	# symlink, without a leading ':'
 	if ( (-e $fn) || (-l $fn) ) {
 	    if ($fn =~ /^[^:]+:/) { # a volume name like DataHD:*
-		return $fn; # $fn is already an absolut path
+		return $fn; # $fn is already an absolute path
 	    }
 	    else {
 		$abs_name = $cdir . $fn;
@@ -425,35 +449,51 @@
 sub _find_dir_symlnk($$$);
 sub _find_dir($$$);
 
+# check whether or not a scalar variable is tainted
+# (code straight from the Camel, 3rd ed., page 561)
+sub is_tainted_pp {
+    my $arg = shift;
+    my $nada = substr($arg, 0, 0); # zero-length
+    local $@;
+    eval { eval "# $nada" };
+    return length($@) != 0;
+} 
+
 sub _find_opt {
     my $wanted = shift;
     die "invalid top directory" unless defined $_[0];
 
-    my $cwd           = $wanted->{bydepth} ? Cwd::fastcwd() : Cwd::cwd();
-    my $cwd_untainted = $cwd;
-    $wanted_callback  = $wanted->{wanted};
-    $bydepth          = $wanted->{bydepth};
-    $pre_process      = $wanted->{preprocess};
-    $post_process     = $wanted->{postprocess};
-    $no_chdir         = $wanted->{no_chdir};
-    $full_check       = $wanted->{follow};
-    $follow           = $full_check || $wanted->{follow_fast};
-    $follow_skip      = $wanted->{follow_skip};
-    $untaint          = $wanted->{untaint};
-    $untaint_pat      = $wanted->{untaint_pattern};
-    $untaint_skip     = $wanted->{untaint_skip};
+    # This function must local()ize everything because callbacks may
+    # call find() or finddepth()
+
+    local %SLnkSeen;
+    local ($wanted_callback, $avoid_nlink, $bydepth, $no_chdir, $follow,
+	$follow_skip, $full_check, $untaint, $untaint_skip, $untaint_pat,
+	$pre_process, $post_process, $dangling_symlinks);
+    local($dir, $name, $fullname, $prune);
+
+    my $cwd            = $wanted->{bydepth} ? Cwd::fastcwd() : Cwd::cwd();
+    my $cwd_untainted  = $cwd;
+    my $check_t_cwd    = 1;
+    $wanted_callback   = $wanted->{wanted};
+    $bydepth           = $wanted->{bydepth};
+    $pre_process       = $wanted->{preprocess};
+    $post_process      = $wanted->{postprocess};
+    $no_chdir          = $wanted->{no_chdir};
+    $full_check        = $wanted->{follow};
+    $follow            = $full_check || $wanted->{follow_fast};
+    $follow_skip       = $wanted->{follow_skip};
+    $untaint           = $wanted->{untaint};
+    $untaint_pat       = $wanted->{untaint_pattern};
+    $untaint_skip      = $wanted->{untaint_skip};
+    $dangling_symlinks = $wanted->{dangling_symlinks};
 
     # for compatability reasons (find.pl, find2perl)
-    our ($topdir, $topdev, $topino, $topmode, $topnlink);
+    local our ($topdir, $topdev, $topino, $topmode, $topnlink);
 
     # a symbolic link to a directory doesn't increase the link count
     $avoid_nlink      = $follow || $File::Find::dont_use_nlink;
     
-    if ( $untaint ) {
-	$cwd_untainted= $1 if $cwd_untainted =~ m|$untaint_pat|;
-	die "insecure cwd in find(depth)"  unless defined($cwd_untainted);
-    }
-    
     my ($abs_dir, $Is_Dir);
 
     Proc_Top_Item:
@@ -461,13 +501,13 @@
 	my $top_item = $TOP;
 
 	if ($Is_MacOS) {
-	    ($topdev,$topino,$topmode,$topnlink) = stat $top_item;
+	    ($topdev,$topino,$topmode,$topnlink) = $follow ? stat $top_item : lstat $top_item;
 	    $top_item = ":$top_item"
-		if ( (-d _) && ($top_item =~ /^[^:]+\z/) );
+		if ( (-d _) && ( $top_item !~ /:/ ) );
 	}
 	else {
 	    $top_item =~ s|/\z|| unless $top_item eq '/';
-	    ($topdev,$topino,$topmode,$topnlink) = stat $top_item;
+	    ($topdev,$topino,$topmode,$topnlink) = $follow ? stat $top_item : lstat $top_item;
 	}
 
 	$Is_Dir= 0;
@@ -483,7 +523,7 @@
 		else {
 		    $abs_dir = contract_name_Mac($cwd, $top_item);
 		    unless (defined $abs_dir) {
-			warn "Can't determine absolute path for $top_item (No such file or directory)\n";
+			warn "Can't determine absolute path for $top_item (No such file or directory)\n" if $^W;
 			next Proc_Top_Item;
 		    }
 		}
@@ -502,7 +542,13 @@
 	    }
 	    $abs_dir= Follow_SymLink($abs_dir);
 	    unless (defined $abs_dir) {
-		warn "$top_item is a dangling symbolic link\n";
+		if ($dangling_symlinks) {
+		    if (ref $dangling_symlinks eq 'CODE') {
+			$dangling_symlinks->($top_item, $cwd);
+		    } else {
+			warn "$top_item is a dangling symbolic link\n" if $^W;
+		    }
+		}
 		next Proc_Top_Item;
 	    }
 
@@ -514,7 +560,7 @@
 	else { # no follow
 	    $topdir = $top_item;
 	    unless (defined $topnlink) {
-		warn "Can't stat $top_item: $!\n";
+		warn "Can't stat $top_item: $!\n" if $^W;
 		next Proc_Top_Item;
 	    }
 	    if (-d _) {
@@ -538,12 +584,11 @@
 	    }
 
 	    $abs_dir = $dir;
-	    if ($untaint) {
-		my $abs_dir_save = $abs_dir;
-		$abs_dir = $1 if $abs_dir =~ m|$untaint_pat|;
+	    if (( $untaint ) && (is_tainted($dir) )) {
+		( $abs_dir ) = $dir =~ m|$untaint_pat|;
 		unless (defined $abs_dir) {
 		    if ($untaint_skip == 0) {
-			die "directory $abs_dir_save is still tainted";
+			die "directory $dir is still tainted";
 		    }
 		    else {
 			next Proc_Top_Item;
@@ -551,8 +596,8 @@
 		}
 	    }
 
-	    unless ($no_chdir or chdir $abs_dir) {
-		warn "Couldn't chdir $abs_dir: $!\n";
+	    unless ($no_chdir || chdir $abs_dir) {
+		warn "Couldn't chdir $abs_dir: $!\n" if $^W;
 		next Proc_Top_Item;
 	    }
 
@@ -562,7 +607,18 @@
 
 	}
 
-	$no_chdir or chdir $cwd_untainted;
+	unless ( $no_chdir ) {
+	    if ( ($check_t_cwd) && (($untaint) && (is_tainted($cwd) )) ) {
+		( $cwd_untainted ) = $cwd =~ m|$untaint_pat|;
+		unless (defined $cwd_untainted) {
+		    die "insecure cwd in find(depth)";
+		}
+		$check_t_cwd = 0;
+	    }
+	    unless (chdir $cwd_untainted) {
+		die "Can't cd to $cwd: $!\n";
+	    }
+	}
     }
 }
 
@@ -583,6 +639,7 @@
     my $dir_name= $p_dir;
     my $dir_pref;
     my $dir_rel;
+    my $tainted = 0;
 
     if ($Is_MacOS) {
 	$dir_pref= ($p_dir =~ /:$/) ? $p_dir : "$p_dir:"; # preface
@@ -595,10 +652,10 @@
 
     local ($dir, $name, $prune, *DIR);
 
-    unless ( $no_chdir || ($p_dir eq $File::Find::current_dir) ) {
+    unless ( $no_chdir || ($p_dir eq $File::Find::current_dir)) {
 	my $udir = $p_dir;
-	if ($untaint) {
-	    $udir = $1 if $p_dir =~ m|$untaint_pat|;
+	if (( $untaint ) && (is_tainted($p_dir) )) {
+	    ( $udir ) = $p_dir =~ m|$untaint_pat|;
 	    unless (defined $udir) {
 		if ($untaint_skip == 0) {
 		    die "directory $p_dir is still tainted";
@@ -609,7 +666,7 @@
 	    }
 	}
 	unless (chdir $udir) {
-	    warn "Can't cd to $udir: $!\n";
+	    warn "Can't cd to $udir: $!\n" if $^W;
 	    return;
 	}
     }
@@ -618,7 +675,7 @@
     push @Stack,[$CdLvl,$p_dir,$dir_rel,-1]  if  $bydepth;
 
     if ($Is_MacOS) {
-	$p_dir = $dir_pref;
+	$p_dir = $dir_pref;  # ensure trailing ':'
     }
 
     while (defined $SE) {
@@ -633,10 +690,10 @@
 	}
 
 	# change to that directory
-	unless ($no_chdir or $dir_rel eq $File::Find::current_dir) {
+	unless ($no_chdir || ($dir_rel eq $File::Find::current_dir)) {
 	    my $udir= $dir_rel;
-	    if ($untaint) {
-		$udir = $1 if $dir_rel =~ m|$untaint_pat|;
+	    if ( ($untaint) && (($tainted) || ($tainted = is_tainted($dir_rel) )) ) {
+		( $udir ) = $dir_rel =~ m|$untaint_pat|;
 		unless (defined $udir) {
 		    if ($untaint_skip == 0) {
 			if ($Is_MacOS) {
@@ -645,15 +702,17 @@
 			else {
 			    die "directory (" . ($p_dir ne '/' ? $p_dir : '') . "/) $dir_rel is still tainted";
 			}
+		    } else { # $untaint_skip == 1
+			next; 
 		    }
 		}
 	    }
 	    unless (chdir $udir) {
 		if ($Is_MacOS) {
-		    warn "Can't cd to ($p_dir) $udir: $!\n";
+		    warn "Can't cd to ($p_dir) $udir: $!\n" if $^W;
 		}
 		else {
-		    warn "Can't cd to (" . ($p_dir ne '/' ? $p_dir : '') . "/) $udir: $!\n";
+		    warn "Can't cd to (" . ($p_dir ne '/' ? $p_dir : '') . "/) $udir: $!\n" if $^W;
 		}
 		next;
 	    }
@@ -668,7 +727,7 @@
 
 	# Get the list of files in the current directory.
 	unless (opendir DIR, ($no_chdir ? $dir_name : $File::Find::current_dir)) {
-	    warn "Can't opendir($dir_name): $!\n";
+	    warn "Can't opendir($dir_name): $!\n" if $^W;
 	    next;
 	}
 	@filenames = readdir DIR;
@@ -711,8 +770,8 @@
 		    }
 		}
 		else {
-		    $name = $dir_pref . $FN;
-		    $_= ($no_chdir ? $name : $FN);
+		    $name = $dir_pref . $FN; # $File::Find::name
+		    $_= ($no_chdir ? $name : $FN); # $_
 		    { &$wanted_callback }; # protect against wild "next"
 		}
 	    }
@@ -736,7 +795,7 @@
 
 	    if ($Is_MacOS) {
 		# $pdir always has a trailing ':', except for the starting dir,
-		# where $dir_rel == ':'
+		# where $dir_rel eq ':'
 		$dir_name = "$p_dir$dir_rel";
 		$dir_pref = "$dir_name:";
 	    }
@@ -794,17 +853,19 @@
 #  chdir (if not no_chdir) to dir
 
 sub _find_dir_symlnk($$$) {
-    my ($wanted, $dir_loc, $p_dir) = @_; # $dir_loc is absdir, without trailing ':' on Mac OS
+    my ($wanted, $dir_loc, $p_dir) = @_; # $dir_loc is the absolute directory
     my @Stack;
     my @filenames;
     my $new_loc;
-    my $pdir_loc = $dir_loc;
+    my $updir_loc = $dir_loc; # untainted parent directory
     my $SE = [];
     my $dir_name = $p_dir;
     my $dir_pref;
     my $loc_pref;
     my $dir_rel;
     my $byd_flag; # flag for pending stack entry if $bydepth
+    my $tainted = 0;
+    my $ok = 1;
 
     if ($Is_MacOS) {
 	$dir_pref = ($p_dir =~ /:$/) ? "$p_dir" : "$p_dir:";
@@ -818,11 +879,14 @@
 
     local ($dir, $name, $fullname, $prune, *DIR);
 
-    unless ($no_chdir or $p_dir eq $File::Find::current_dir) {
-	my $udir = $dir_loc;
-	if ($untaint) {
-	    $udir = $1 if $dir_loc =~ m|$untaint_pat|;
-	    unless (defined $udir) {
+    unless ($no_chdir) {
+	# untaint the topdir
+	if (( $untaint ) && (is_tainted($dir_loc) )) {
+	    ( $updir_loc ) = $dir_loc =~ m|$untaint_pat|; # parent dir, now untainted
+	     # once untainted, $updir_loc is pushed on the stack (as parent directory);
+	    # hence, we don't need to untaint the parent directory every time we chdir 
+	    # to it later 
+	    unless (defined $updir_loc) {
 		if ($untaint_skip == 0) {
 		    die "directory $dir_loc is still tainted";
 		}
@@ -831,36 +895,33 @@
 		}
 	    }
 	}
-	unless (chdir $udir) {
-	    warn "Can't cd to $udir: $!\n";
+	$ok = chdir($updir_loc) unless ($p_dir eq $File::Find::current_dir);
+	unless ($ok) {
+	    warn "Can't cd to $updir_loc: $!\n" if $^W;
 	    return;
 	}
     }
 
-    push @Stack,[$dir_loc,$pdir_loc,$p_dir,$dir_rel,-1]  if  $bydepth;
+    push @Stack,[$dir_loc,$updir_loc,$p_dir,$dir_rel,-1]  if  $bydepth;
 
     if ($Is_MacOS) {
-	$p_dir = $dir_pref;
+	$p_dir = $dir_pref; # ensure trailing ':'
     }
 
     while (defined $SE) {
 
 	unless ($bydepth) {
-	    # change to parent directory
+	    # change (back) to parent directory (always untainted)
 	    unless ($no_chdir) {
-		my $udir = $pdir_loc;
-		if ($untaint) {
-		    $udir = $1 if $pdir_loc =~ m|$untaint_pat|;
-		}
-		unless (chdir $udir) {
-		    warn "Can't cd to $udir: $!\n";
+		unless (chdir $updir_loc) {
+		    warn "Can't cd to $updir_loc: $!\n" if $^W;
 		    next;
 		}
 	    }
-	    $dir= $p_dir; # File::Find::dir
-	    $name= $dir_name; # File::Find::name
+	    $dir= $p_dir; # $File::Find::dir
+	    $name= $dir_name; # $File::Find::name
 	    $_= ($no_chdir ? $dir_name : $dir_rel ); # $_
-	    $fullname= $dir_loc; # File::Find::fullname
+	    $fullname= $dir_loc; # $File::Find::fullname
 	    # prune may happen here
 	    $prune= 0;
 	    lstat($_); # make sure  file tests with '_' work
@@ -869,11 +930,12 @@
 	}
 
 	# change to that directory
-	unless ($no_chdir or $dir_rel eq $File::Find::current_dir) {
-	    my $udir = $dir_loc;
-	    if ($untaint) {
-		$udir = $1 if $dir_loc =~ m|$untaint_pat|;
-		unless (defined $udir ) {
+	unless ($no_chdir || ($dir_rel eq $File::Find::current_dir)) {
+	    $updir_loc = $dir_loc;
+	    if ( ($untaint) && (($tainted) || ($tainted = is_tainted($dir_loc) )) ) {
+		# untaint $dir_loc, what will be pushed on the stack as (untainted) parent dir 
+		( $updir_loc ) = $dir_loc =~ m|$untaint_pat|;
+		unless (defined $updir_loc) {
 		    if ($untaint_skip == 0) {
 			die "directory $dir_loc is still tainted";
 		    }
@@ -882,8 +944,8 @@
 		    }
 		}
 	    }
-	    unless (chdir $udir) {
-		warn "Can't cd to $udir: $!\n";
+	    unless (chdir $updir_loc) {
+		warn "Can't cd to $updir_loc: $!\n" if $^W;
 		next;
 	    }
 	}
@@ -896,7 +958,7 @@
 
 	# Get the list of files in the current directory.
 	unless (opendir DIR, ($no_chdir ? $dir_loc : $File::Find::current_dir)) {
-	    warn "Can't opendir($dir_loc): $!\n";
+	    warn "Can't opendir($dir_loc): $!\n" if $^W;
 	    next;
 	}
 	@filenames = readdir DIR;
@@ -912,7 +974,7 @@
 	    next unless defined $new_loc;
 
 	    if (-d _) {
-		push @Stack,[$new_loc,$dir_loc,$dir_name,$FN,1];
+		push @Stack,[$new_loc,$updir_loc,$dir_name,$FN,1];
 	    }
 	    else {
 		$fullname = $new_loc; # $File::Find::fullname 
@@ -925,10 +987,10 @@
     }
     continue {
 	while (defined($SE = pop @Stack)) {
-	    ($dir_loc, $pdir_loc, $p_dir, $dir_rel, $byd_flag) = @$SE;
+	    ($dir_loc, $updir_loc, $p_dir, $dir_rel, $byd_flag) = @$SE;
 	    if ($Is_MacOS) {
 		# $p_dir always has a trailing ':', except for the starting dir,
-		# where $dir_rel == ':'
+		# where $dir_rel eq ':'
 		$dir_name = "$p_dir$dir_rel";
 		$dir_pref = "$dir_name:";
 		$loc_pref = ($dir_loc =~ /:$/) ? $dir_loc : "$dir_loc:";
@@ -939,13 +1001,9 @@
 		$loc_pref = "$dir_loc/";
 	    }
 	    if ( $byd_flag < 0 ) {  # must be finddepth, report dirname now
-		unless ($no_chdir or $dir_rel eq $File::Find::current_dir) {
-		    my $udir = $pdir_loc;
-		    if ($untaint) {
-			$udir = $1 if $dir_loc =~ m|$untaint_pat|;
-		    }
-		    unless (chdir $udir) {
-			warn "Can't cd to $udir: $!\n";
+		unless ($no_chdir || ($dir_rel eq $File::Find::current_dir)) {
+		    unless (chdir $updir_loc) { # $updir_loc (parent dir) is always untainted 
+			warn "Can't cd to $updir_loc: $!\n" if $^W;
 			next;
 		    }
 		}
@@ -961,7 +1019,7 @@
 		}
 		else {
 		    if ( substr($name,-2) eq '/.' ) {
-			$name =~ s|/\.$||;
+			$name =~ s|/\.$||; # $File::Find::name
 		    }
 		    $dir = $p_dir; # $File::Find::dir
 		    $_ = ($no_chdir ? $dir_name : $dir_rel); # $_
@@ -974,7 +1032,7 @@
 		{ &$wanted_callback }; # protect against wild "next"
 	    }
 	    else {
-		push @Stack,[$dir_loc, $pdir_loc, $p_dir, $dir_rel,-1]  if  $bydepth;
+		push @Stack,[$dir_loc, $updir_loc, $p_dir, $dir_rel,-1]  if  $bydepth;
 		last;
 	    }
 	}
@@ -1002,17 +1060,13 @@
 
 sub find {
     my $wanted = shift;
-    %SLnkSeen= (); # clear hash first
     _find_opt(wrap_wanted($wanted), @_);
-    %SLnkSeen= ();  # free memory
 }
 
 sub finddepth {
     my $wanted = wrap_wanted(shift);
-    %SLnkSeen= (); # clear hash first
     $wanted->{bydepth} = 1;
     _find_opt($wanted, @_);
-    %SLnkSeen= ();  # free memory
 }
 
 # default
@@ -1037,7 +1091,7 @@
 
 $File::Find::dont_use_nlink = 1
     if $^O eq 'os2' || $^O eq 'dos' || $^O eq 'amigaos' || $^O eq 'MSWin32' ||
-       $^O eq 'cygwin' || $^O eq 'epoc';
+       $^O eq 'cygwin' || $^O eq 'epoc' || $^O eq 'NetWare';
 
 # Set dont_use_nlink in your hint file if your system's stat doesn't
 # report the number of links in a directory as an indication
@@ -1048,4 +1102,13 @@
     $File::Find::dont_use_nlink = 1 if ($Config::Config{'dont_use_nlink'});
 }
 
+# We need a function that checks if a scalar is tainted. Either use the 
+# Scalar::Util module's tainted() function or our (slower) pure Perl 
+# fallback is_tainted_pp()
+{
+    local $@;
+    eval { require Scalar::Util };
+    *is_tainted = $@ ? \&is_tainted_pp : \&Scalar::Util::tainted;
+}
+
 1;

==== //depot/maint-5.6/macperl/t/lib/filefind.t#3 (xtext) ====
Index: perl/t/lib/filefind.t
--- perl/t/lib/filefind.t.~1~	Sat Jul  7 18:00:05 2001
+++ perl/t/lib/filefind.t	Sat Jul  7 18:00:05 2001
@@ -1,462 +1,742 @@
-####!./perl
+#!./perl
 
 
-my %Expect;
+my %Expect_File = (); # what we expect for $_ 
+my %Expect_Name = (); # what we expect for $File::Find::name/fullname
+my %Expect_Dir  = (); # what we expect for $File::Find::dir
 my $symlink_exists = eval { symlink("",""); 1 };
 my $warn_msg;
 
+
 BEGIN {
     chdir 't' if -d 't';
-    @INC = '../lib';
+    unshift @INC => '../lib';
 
     $SIG{'__WARN__'} = sub { $warn_msg = $_[0]; warn "# $_[0]"; }
 }
 
-if ( $symlink_exists ) { print "1..167\n"; }
-else                   { print "1..61\n"; }
+if ( $symlink_exists ) { print "1..188\n"; }
+else                   { print "1..78\n";  }
 
 use File::Find;
+use File::Spec;
+if ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'VMS')
+ {
+  # This is a hack - at present File::Find does not produce native names on 
+  # Win32 or VMS, so force File::Spec to use Unix names.
+  require File::Spec::Unix;
+  @File::Spec::ISA = 'File::Spec::Unix';
+ }
+
+cleanup();
+
+find({wanted => sub { print "ok 1\n" if $_ eq 'commonsense.t'; } },
+   File::Spec->curdir);
 
-if ($^O eq 'MacOS') {
-    find(sub { print "ok 1\n" if $_ eq 'filefind.t'; }, ':');
-    finddepth(sub { print "ok 2\n" if $_ eq 'filefind.t'; }, ':');
-} else {
-    find(sub { print "ok 1\n" if $_ eq 'filefind.t'; }, '.');
-    finddepth(sub { print "ok 2\n" if $_ eq 'filefind.t'; }, '.');
-}
+finddepth({wanted => sub { print "ok 2\n" if $_ eq 'commonsense.t'; } },
+	File::Spec->curdir);
 
 my $case = 2;
 my $FastFileTests_OK = 0;
 
+sub cleanup {
+    if (-d dir_path('for_find')) {
+        chdir(dir_path('for_find'));
+    }
+    if (-d dir_path('fa')) {
+        unlink file_path('fa', 'fa_ord'),
+               file_path('fa', 'fsl'),
+               file_path('fa', 'faa', 'faa_ord'),
+               file_path('fa', 'fab', 'fab_ord'),
+               file_path('fa', 'fab', 'faba', 'faba_ord'),
+               file_path('fb', 'fb_ord'),
+               file_path('fb', 'fba', 'fba_ord');
+        rmdir dir_path('fa', 'faa');
+        rmdir dir_path('fa', 'fab', 'faba');
+        rmdir dir_path('fa', 'fab');
+        rmdir dir_path('fa');
+        rmdir dir_path('fb', 'fba');
+        rmdir dir_path('fb');
+        chdir File::Spec->updir;
+        rmdir dir_path('for_find');
+    }
+}
+
 END {
-    if ($^O eq 'MacOS') {
-      unlink ':fa:fa_ord',':fa:fsl',':fa:faa:faa_ord',
-         ':fa:fab:fab_ord',':fa:fab:faba:faba_ord',':fb:fb_ord',':fb:fba:fba_ord';
-      rmdir ':fa:faa';
-      rmdir ':fa:fab:faba';
-      rmdir ':fa:fab';
-      rmdir ':fa';
-      rmdir ':fb:fba';
-      rmdir ':fb';
-      chdir '::';
-      rmdir ':for_find';
-
-    } else {
-      unlink 'fa/fa_ord','fa/fsl','fa/faa/faa_ord',
-         'fa/fab/fab_ord','fa/fab/faba/faba_ord','fb/fb_ord','fb/fba/fba_ord';
-      rmdir 'fa/faa';
-      rmdir 'fa/fab/faba';
-      rmdir 'fa/fab';
-      rmdir 'fa';
-      rmdir 'fb/fba';
-      rmdir 'fb';
-      chdir '..';
-      rmdir 'for_find';
-    }
+    cleanup();
 }
 
 sub Check($) {
-  $case++;
-  if ($_[0]) { print "ok $case\n"; }
-  else       { print "not ok $case\n"; }
+    $case++;
+    if ($_[0]) { print "ok $case\n"; }
+    else       { print "not ok $case\n"; }
 }
 
 sub CheckDie($) {
-  $case++;
-  if ($_[0]) { print "ok $case\n"; }
-  else { print "not ok $case\n $!\n"; exit 0; }
+    $case++;
+    if ($_[0]) { print "ok $case\n"; }
+    else { print "not ok $case\n $!\n"; exit 0; }
 }
 
 sub touch {
-  CheckDie( open(my $T,'>',$_[0]) );
+    CheckDie( open(my $T,'>',$_[0]) );
 }
 
 sub MkDir($$) {
-  CheckDie( mkdir($_[0],$_[1]) );
+    CheckDie( mkdir($_[0],$_[1]) );
 }
 
-sub wanted {
-  print "# '$_' => 1\n";
-  s#\.$## if ($^O eq 'VMS' && $_ ne '.');
-  Check( $Expect{$_} );
-  if ( $FastFileTests_OK ) {
-    delete $Expect{$_} 
-      unless ( $Expect_Dir{$_} && ! -d _ );
-  } else {
-    delete $Expect{$_} 
-      unless ( $Expect_Dir{$_} && ! -d $_ );
-  }
-  $File::Find::prune=1 if  $_ eq 'faba';
+sub wanted_File_Dir {
+    print "# \$File::Find::dir => '$File::Find::dir'\n";
+    print "# \$_ => '$_'\n";
+    s#\.$## if ($^O eq 'VMS' && $_ ne '.');
+    Check( $Expect_File{$_} );
+    if ( $FastFileTests_OK ) {
+        delete $Expect_File{ $_} 
+          unless ( $Expect_Dir{$_} && ! -d _ );
+    } else {
+        delete $Expect_File{$_} 
+          unless ( $Expect_Dir{$_} && ! -d $_ );
+    }
+}
 
+sub wanted_File_Dir_prune {
+    &wanted_File_Dir;
+    $File::Find::prune=1 if  $_ eq 'faba';
 }
 
-sub dn_wanted {
-  my $n = $File::Find::name;
-  $n =~ s#\.$## if ($^O eq 'VMS' && $n ne '.');
-  print "# '$n' => 1\n";
-  my $i = rindex($n,'/');
-  my $OK = exists($Expect{$n});
-  unless ($^O eq 'MacOS') {
-    if ( $OK ) {
-  	  $OK= exists($Expect{substr($n,0,$i)})  if $i >= 0;    
+sub wanted_Name {
+    my $n = $File::Find::name;
+    $n =~ s#\.$## if ($^O eq 'VMS' && $n ne '.');
+    print "# \$File::Find::name => '$n'\n";
+    my $i = rindex($n,'/');
+    my $OK = exists($Expect_Name{$n});
+    unless ($^O eq 'MacOS') {
+        if ( $OK ) {
+            $OK= exists($Expect_Name{substr($n,0,$i)})  if $i >= 0;    
+        }
     }
-  }
-  Check($OK);
-  delete $Expect{$n};
+    Check($OK);
+    delete $Expect_Name{$n};
 }
 
-sub d_wanted {
-  print "# '$_' => 1\n";
-  s#\.$## if ($^O eq 'VMS' && $_ ne '.');
-  my $i = rindex($_,'/');
-  my $OK = exists($Expect{$_});
-  unless ($^O eq 'MacOS') {
-    if ( $OK ) {
-        $OK= exists($Expect{substr($_,0,$i)})  if $i >= 0;
+sub wanted_File {
+    print "# \$_ => '$_'\n";
+    s#\.$## if ($^O eq 'VMS' && $_ ne '.');
+    my $i = rindex($_,'/');
+    my $OK = exists($Expect_File{ $_});
+    unless ($^O eq 'MacOS') {
+        if ( $OK ) {
+            $OK= exists($Expect_File{ substr($_,0,$i)})  if $i >= 0;
+        }
     }
-  }
-  Check($OK);
-  delete $Expect{$_};
+    Check($OK);
+    delete $Expect_File{ $_};
 }
 
 sub simple_wanted {
-  print "# \$File::Find::dir => '$File::Find::dir'\n";
-  print "# \$_ => '$_'\n";
+    print "# \$File::Find::dir => '$File::Find::dir'\n";
+    print "# \$_ => '$_'\n";
+}
+
+sub noop_wanted {}
+
+sub my_preprocess {
+    @files = @_;
+    print "# --preprocess--\n";
+    print "#   \$File::Find::dir => '$File::Find::dir' \n";
+    foreach $file (@files) {
+        $file =~ s/\.(dir)?$// if $^O eq 'VMS';
+        print "#   $file \n";
+        delete $Expect_Dir{ $File::Find::dir }->{$file};
+    }
+    print "# --end preprocess--\n";
+    Check(scalar(keys %{$Expect_Dir{ $File::Find::dir }}) == 0);
+    if (scalar(keys %{$Expect_Dir{ $File::Find::dir }}) == 0) {
+        delete $Expect_Dir{ $File::Find::dir }
+    }
+    return @files;
+}
+
+sub my_postprocess {
+    print "# postprocess: \$File::Find::dir => '$File::Find::dir' \n";
+    delete $Expect_Dir{ $File::Find::dir};
+}
+
+
+# Use dir_path() to specify a directory path that's expected for
+# $File::Find::dir (%Expect_Dir). Also use it in file operations like
+# chdir, rmdir etc.
+#
+# dir_path() concatenates directory names to form a _relative_
+# directory path, independent from the platform it's run on, although
+# there are limitations.  Don't try to create an absolute path,
+# because that may fail on operating systems that have the concept of
+# volume names (e.g. Mac OS). Be careful when you want to create an
+# updir path like ../fa (Unix) or ::fa: (Mac OS). Plain directory
+# names will work best. As a special case, you can pass it a "." as
+# first argument, to create a directory path like "./fa/dir" on
+# operating systems other than Mac OS (actually, Mac OS will ignore
+# the ".", if it's the first argument). If there's no second argument,
+# this function will return the empty string on Mac OS and the string
+# "./" otherwise.
+
+sub dir_path {
+    my $first_item = shift @_;
+
+    if ($first_item eq '.') {
+        if ($^O eq 'MacOS') {
+            return '' unless @_;
+            # ignore first argument; return a relative path
+            # with leading ":" and with trailing ":"
+            return File::Spec->catdir("", @_); 
+        } else { # other OS
+            return './' unless @_;
+            my $path = File::Spec->catdir(@_);
+            # add leading "./"
+            $path = "./$path";
+            return $path;
+        }
+
+    } else { # $first_item ne '.'
+        return $first_item unless @_; # return plain filename
+        if ($^O eq 'MacOS') {
+            # relative path with leading ":" and with trailing ":"
+            return File::Spec->catdir("", $first_item, @_);
+        } else { # other OS
+            return File::Spec->catdir($first_item, @_);
+        }
+    }
+}
+
+
+# Use topdir() to specify a directory path that you want to pass to
+#find/finddepth Basically, topdir() does the same as dir_path() (see
+#above), except that there's no trailing ":" on Mac OS.
+
+sub topdir {
+    my $path = dir_path(@_);
+    $path =~ s/:$// if ($^O eq 'MacOS');
+    return $path;
+}
+
+
+# Use file_path() to specify a file path that's expected for $_
+# (%Expect_File).  Also suitable for file operations like unlink etc.
+#
+# file_path() concatenates directory names (if any) and a filename to
+# form a _relative_ file path (the last argument is assumed to be a
+# file). It's independent from the platform it's run on, although
+# there are limitations (see the warnings for dir_path() above). As a
+# special case, you can pass it a "." as first argument, to create a
+# file path like "./fa/file" on operating systems other than Mac OS
+# (actually, Mac OS will ignore the ".", if it's the first
+# argument). If there's no second argument, this function will return
+# the empty string on Mac OS and the string "./" otherwise.
+
+sub file_path {
+    my $first_item = shift @_;
+
+    if ($first_item eq '.') {
+        if ($^O eq 'MacOS') {
+            return '' unless @_;
+            # ignore first argument; return a relative path  
+            # with leading ":", but without trailing ":"
+            return File::Spec->catfile("", @_); 
+        } else { # other OS
+            return './' unless @_;
+            my $path = File::Spec->catfile(@_);
+            # add leading "./" 
+            $path = "./$path"; 
+            return $path;
+        }
+
+    } else { # $first_item ne '.'
+        return $first_item unless @_; # return plain filename
+        if ($^O eq 'MacOS') {
+            # relative path with leading ":", but without trailing ":"
+            return File::Spec->catfile("", $first_item, @_);
+        } else { # other OS
+            return File::Spec->catfile($first_item, @_);
+        }
+    }
+}
+
+
+# Use file_path_name() to specify a file path that's expected for
+# $File::Find::Name (%Expect_Name). Note: When the no_chdir => 1
+# option is in effect, $_ is the same as $File::Find::Name. In that
+# case, also use this function to specify a file path that's expected
+# for $_.
+#
+# Basically, file_path_name() does the same as file_path() (see
+# above), except that there's always a leading ":" on Mac OS, even for
+# plain file/directory names.
+
+sub file_path_name {
+    my $path = file_path(@_);
+    $path = ":$path" if (($^O eq 'MacOS') && ($path !~ /:/));
+    return $path;
 }
 
 
+
+MkDir( dir_path('for_find'), 0770 );
+CheckDie(chdir( dir_path('for_find')));
+MkDir( dir_path('fa'), 0770 );
+MkDir( dir_path('fb'), 0770  );
+touch( file_path('fb', 'fb_ord') );
+MkDir( dir_path('fb', 'fba'), 0770  );
+touch( file_path('fb', 'fba', 'fba_ord') );
 if ($^O eq 'MacOS') {
+      CheckDie( symlink(':fb',':fa:fsl') ) if $symlink_exists;
+} else {
+      CheckDie( symlink('../fb','fa/fsl') ) if $symlink_exists;
+}
+touch( file_path('fa', 'fa_ord') );
+
+MkDir( dir_path('fa', 'faa'), 0770  );
+touch( file_path('fa', 'faa', 'faa_ord') );
+MkDir( dir_path('fa', 'fab'), 0770  );
+touch( file_path('fa', 'fab', 'fab_ord') );
+MkDir( dir_path('fa', 'fab', 'faba'), 0770  );
+touch( file_path('fa', 'fab', 'faba', 'faba_ord') );
+
+
+%Expect_File = (File::Spec->curdir => 1, file_path('fsl') => 1,
+                file_path('fa_ord') => 1, file_path('fab') => 1,
+                file_path('fab_ord') => 1, file_path('faba') => 1,
+                file_path('faa') => 1, file_path('faa_ord') => 1);
+
+delete $Expect_File{ file_path('fsl') } unless $symlink_exists;
+%Expect_Name = ();
+
+%Expect_Dir = ( dir_path('fa') => 1, dir_path('faa') => 1,
+                dir_path('fab') => 1, dir_path('faba') => 1,
+                dir_path('fb') => 1, dir_path('fba') => 1);
+
+delete @Expect_Dir{ dir_path('fb'), dir_path('fba') } unless $symlink_exists;
+File::Find::find( {wanted => \&wanted_File_Dir_prune}, topdir('fa') ); 
+Check( scalar(keys %Expect_File) == 0 );
+
+
+print "# check re-entrancy\n";
+
+%Expect_File = (File::Spec->curdir => 1, file_path('fsl') => 1,
+                file_path('fa_ord') => 1, file_path('fab') => 1,
+                file_path('fab_ord') => 1, file_path('faba') => 1,
+                file_path('faa') => 1, file_path('faa_ord') => 1);
+
+delete $Expect_File{ file_path('fsl') } unless $symlink_exists;
+%Expect_Name = ();
+
+%Expect_Dir = ( dir_path('fa') => 1, dir_path('faa') => 1,
+                dir_path('fab') => 1, dir_path('faba') => 1,
+                dir_path('fb') => 1, dir_path('fba') => 1);
+
+delete @Expect_Dir{ dir_path('fb'), dir_path('fba') } unless $symlink_exists;
+
+File::Find::find( {wanted => sub { wanted_File_Dir_prune();
+                                    File::Find::find( {wanted => sub
+                                    {} }, File::Spec->curdir ); } },
+                                    topdir('fa') );
+
+Check( scalar(keys %Expect_File) == 0 ); 
+
+
+# no_chdir is in effect, hence we use file_path_name to specify the expected paths for %Expect_File
+
+%Expect_File = (file_path_name('fa') => 1,
+		file_path_name('fa', 'fsl') => 1,
+                file_path_name('fa', 'fa_ord') => 1,
+                file_path_name('fa', 'fab') => 1,
+		file_path_name('fa', 'fab', 'fab_ord') => 1,
+		file_path_name('fa', 'fab', 'faba') => 1,
+		file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
+		file_path_name('fa', 'faa') => 1,
+                file_path_name('fa', 'faa', 'faa_ord') => 1,);
+
+delete $Expect_File{ file_path_name('fa', 'fsl') } unless $symlink_exists;
+%Expect_Name = ();
+
+%Expect_Dir = (dir_path('fa') => 1,
+	       dir_path('fa', 'faa') => 1,
+               dir_path('fa', 'fab') => 1,
+	       dir_path('fa', 'fab', 'faba') => 1,
+	       dir_path('fb') => 1,
+	       dir_path('fb', 'fba') => 1);
+
+delete @Expect_Dir{ dir_path('fb'), dir_path('fb', 'fba') }
+    unless $symlink_exists;
+
+File::Find::find( {wanted => \&wanted_File_Dir, no_chdir => 1},
+		  topdir('fa') ); Check( scalar(keys %Expect_File) == 0 );
+
+
+%Expect_File = ();
+
+%Expect_Name = (File::Spec->curdir => 1,
+		file_path_name('.', 'fa') => 1,
+                file_path_name('.', 'fa', 'fsl') => 1,
+                file_path_name('.', 'fa', 'fa_ord') => 1,
+                file_path_name('.', 'fa', 'fab') => 1,
+                file_path_name('.', 'fa', 'fab', 'fab_ord') => 1,
+                file_path_name('.', 'fa', 'fab', 'faba') => 1,
+                file_path_name('.', 'fa', 'fab', 'faba', 'faba_ord') => 1,
+                file_path_name('.', 'fa', 'faa') => 1,
+                file_path_name('.', 'fa', 'faa', 'faa_ord') => 1,
+                file_path_name('.', 'fb') => 1,
+		file_path_name('.', 'fb', 'fba') => 1,
+		file_path_name('.', 'fb', 'fba', 'fba_ord') => 1,
+		file_path_name('.', 'fb', 'fb_ord') => 1);
+
+delete $Expect_Name{ file_path('.', 'fa', 'fsl') } unless $symlink_exists;
+%Expect_Dir = (); 
+File::Find::finddepth( {wanted => \&wanted_Name}, File::Spec->curdir );
+Check( scalar(keys %Expect_Name) == 0 );
+
+
+# no_chdir is in effect, hence we use file_path_name to specify the
+# expected paths for %Expect_File
+
+%Expect_File = (File::Spec->curdir => 1,
+		file_path_name('.', 'fa') => 1,
+                file_path_name('.', 'fa', 'fsl') => 1,
+                file_path_name('.', 'fa', 'fa_ord') => 1,
+                file_path_name('.', 'fa', 'fab') => 1,
+                file_path_name('.', 'fa', 'fab', 'fab_ord') => 1,
+                file_path_name('.', 'fa', 'fab', 'faba') => 1,
+                file_path_name('.', 'fa', 'fab', 'faba', 'faba_ord') => 1,
+                file_path_name('.', 'fa', 'faa') => 1,
+                file_path_name('.', 'fa', 'faa', 'faa_ord') => 1,
+                file_path_name('.', 'fb') => 1,
+		file_path_name('.', 'fb', 'fba') => 1,
+		file_path_name('.', 'fb', 'fba', 'fba_ord') => 1,
+		file_path_name('.', 'fb', 'fb_ord') => 1);
+
+delete $Expect_File{ file_path_name('.', 'fa', 'fsl') } unless $symlink_exists;
+%Expect_Name = ();
+%Expect_Dir = (); 
+
+File::Find::finddepth( {wanted => \&wanted_File, no_chdir => 1},
+		     File::Spec->curdir );
+
+Check( scalar(keys %Expect_File) == 0 );
+
+
+print "# check preprocess\n";
+%Expect_File = ();
+%Expect_Name = ();
+%Expect_Dir = (
+          File::Spec->curdir                 => {fa => 1, fb => 1}, 
+          dir_path('.', 'fa')                => {faa => 1, fab => 1, fa_ord => 1},
+          dir_path('.', 'fa', 'faa')         => {faa_ord => 1},
+          dir_path('.', 'fa', 'fab')         => {faba => 1, fab_ord => 1},
+          dir_path('.', 'fa', 'fab', 'faba') => {faba_ord => 1},
+          dir_path('.', 'fb')                => {fba => 1, fb_ord => 1},
+          dir_path('.', 'fb', 'fba')         => {fba_ord => 1}
+          );
+
+File::Find::find( {wanted => \&noop_wanted,
+		   preprocess => \&my_preprocess}, File::Spec->curdir );
+
+Check( scalar(keys %Expect_Dir) == 0 );
+
+
+print "# check postprocess\n";
+%Expect_File = ();
+%Expect_Name = ();
+%Expect_Dir = (
+          File::Spec->curdir                 => 1,
+          dir_path('.', 'fa')                => 1,
+          dir_path('.', 'fa', 'faa')         => 1,
+          dir_path('.', 'fa', 'fab')         => 1,
+          dir_path('.', 'fa', 'fab', 'faba') => 1,
+          dir_path('.', 'fb')                => 1,
+          dir_path('.', 'fb', 'fba')         => 1
+          );
+
+File::Find::find( {wanted => \&noop_wanted,
+		   postprocess => \&my_postprocess}, File::Spec->curdir );
+
+Check( scalar(keys %Expect_Dir) == 0 );
+
+
+if ( $symlink_exists ) {
+    print "# --- symbolic link tests --- \n";
+    $FastFileTests_OK= 1;
+
+
+    # Verify that File::Find::find will call wanted even if the topdir of
+    # is a symlink to a directory, and it shouldn't follow the link
+    # unless follow is set, which it isn't in this case
+    %Expect_File = ( file_path('fsl') => 1 );
+    %Expect_Name = ();
+    %Expect_Dir = ();
+    File::Find::find( {wanted => \&wanted_File_Dir}, topdir('fa', 'fsl') );
+    Check( scalar(keys %Expect_File) == 0 );
+
+ 
+    %Expect_File = (File::Spec->curdir => 1, file_path('fa_ord') => 1,
+                    file_path('fsl') => 1, file_path('fb_ord') => 1,
+                    file_path('fba') => 1, file_path('fba_ord') => 1,
+                    file_path('fab') => 1, file_path('fab_ord') => 1,
+                    file_path('faba') => 1, file_path('faa') => 1,
+                    file_path('faa_ord') => 1);
+
+    %Expect_Name = ();
+
+    %Expect_Dir = (File::Spec->curdir => 1, dir_path('fa') => 1,
+                   dir_path('faa') => 1, dir_path('fab') => 1,
+                   dir_path('faba') => 1, dir_path('fb') => 1,
+                   dir_path('fba') => 1);
+
+    File::Find::find( {wanted => \&wanted_File_Dir_prune,
+		       follow_fast => 1}, topdir('fa') );
+
+    Check( scalar(keys %Expect_File) == 0 );  
+
+
+    # no_chdir is in effect, hence we use file_path_name to specify
+    # the expected paths for %Expect_File
+
+    %Expect_File = (file_path_name('fa') => 1,
+		    file_path_name('fa', 'fa_ord') => 1,
+		    file_path_name('fa', 'fsl') => 1,
+                    file_path_name('fa', 'fsl', 'fb_ord') => 1,
+                    file_path_name('fa', 'fsl', 'fba') => 1,
+                    file_path_name('fa', 'fsl', 'fba', 'fba_ord') => 1,
+                    file_path_name('fa', 'fab') => 1,
+                    file_path_name('fa', 'fab', 'fab_ord') => 1,
+                    file_path_name('fa', 'fab', 'faba') => 1,
+                    file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
+                    file_path_name('fa', 'faa') => 1,
+                    file_path_name('fa', 'faa', 'faa_ord') => 1);
 
-    MkDir( 'for_find',0770 );
-    CheckDie(chdir(for_find));
-    MkDir( 'fa',0770 );
-    MkDir( 'fb',0770  );
-    touch(':fb:fb_ord');
-    MkDir( ':fb:fba',0770  );
-    touch(':fb:fba:fba_ord');
-    CheckDie( symlink(':fb',':fa:fsl') ) if $symlink_exists;
-    touch(':fa:fa_ord');
+    %Expect_Name = ();
+
+    %Expect_Dir = (dir_path('fa') => 1,
+		   dir_path('fa', 'faa') => 1,
+                   dir_path('fa', 'fab') => 1,
+		   dir_path('fa', 'fab', 'faba') => 1,
+		   dir_path('fb') => 1,
+		   dir_path('fb', 'fba') => 1);
+
+    File::Find::find( {wanted => \&wanted_File_Dir, follow_fast => 1,
+		       no_chdir => 1}, topdir('fa') );
+
+    Check( scalar(keys %Expect_File) == 0 );
+
+    %Expect_File = ();
+
+    %Expect_Name = (file_path_name('fa') => 1,
+		    file_path_name('fa', 'fa_ord') => 1,
+		    file_path_name('fa', 'fsl') => 1,
+                    file_path_name('fa', 'fsl', 'fb_ord') => 1,
+                    file_path_name('fa', 'fsl', 'fba') => 1,
+                    file_path_name('fa', 'fsl', 'fba', 'fba_ord') => 1,
+                    file_path_name('fa', 'fab') => 1,
+                    file_path_name('fa', 'fab', 'fab_ord') => 1,
+                    file_path_name('fa', 'fab', 'faba') => 1,
+                    file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
+                    file_path_name('fa', 'faa') => 1,
+                    file_path_name('fa', 'faa', 'faa_ord') => 1);
+
+    %Expect_Dir = ();
 
-    MkDir( ':fa:faa',0770  );
-    touch(':fa:faa:faa_ord');
-    MkDir( ':fa:fab',0770  );
-    touch(':fa:fab:fab_ord');
-    MkDir( ':fa:fab:faba',0770  );
-    touch(':fa:fab:faba:faba_ord');
+    File::Find::finddepth( {wanted => \&wanted_Name,
+			    follow_fast => 1}, topdir('fa') );
 
-    %Expect = (':' => 1, 'fsl' => 1, 'fa_ord' => 1, 'fab' => 1, 'fab_ord' => 1,
-           'faba' => 1, 'faa' => 1, 'faa_ord' => 1);
-    delete $Expect{'fsl'} unless $symlink_exists;
-    %Expect_Dir = (':' => 1, 'fa' => 1, 'faa' => 1, 'fab' => 1, 'faba' => 1, 
-                   'fb' => 1, 'fba' => 1);
-    delete @Expect_Dir{'fb','fba'} unless $symlink_exists;
-    File::Find::find( {wanted => \&wanted, },':fa' );
-    Check( scalar(keys %Expect) == 0 );
+    Check( scalar(keys %Expect_Name) == 0 );
 
-    %Expect=(':fa' => 1, ':fa:fsl' => 1, ':fa:fa_ord' => 1, ':fa:fab' => 1,
-         ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1,
-         ':fa:fab:faba:faba_ord' => 1, ':fa:faa' => 1, ':fa:faa:faa_ord' => 1);
-    delete $Expect{':fa:fsl'} unless $symlink_exists;
-    %Expect_Dir = (':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, 
-                   ':fb' => 1, ':fb:fba' => 1);
-    delete @Expect_Dir{':fb',':fb:fba'} unless $symlink_exists;
-    File::Find::find( {wanted => \&wanted, no_chdir => 1},':fa' );
-    Check( scalar(keys %Expect) == 0 );
+    # no_chdir is in effect, hence we use file_path_name to specify
+    # the expected paths for %Expect_File
 
-    %Expect=(':' => 1, ':fa' => 1, ':fa:fsl' => 1, ':fa:fa_ord' => 1, ':fa:fab' => 1,
-             ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1,
-             ':fa:fab:faba:faba_ord' => 1, ':fa:faa' => 1, ':fa:faa:faa_ord' => 1,
-             ':fb' => 1, ':fb:fba' => 1, ':fb:fba:fba_ord' => 1, ':fb:fb_ord' => 1);
-    delete $Expect{':fa:fsl'} unless $symlink_exists;
-    %Expect_Dir = (':' => 1, ':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, 
-                   ':fb' => 1, ':fb:fba' => 1);
-    delete @Expect_Dir{':fb',':fb:fba'} unless $symlink_exists;
-    File::Find::finddepth( {wanted => \&dn_wanted },':' );
-    Check( scalar(keys %Expect) == 0 );
+    %Expect_File = (file_path_name('fa') => 1,
+		    file_path_name('fa', 'fa_ord') => 1,
+		    file_path_name('fa', 'fsl') => 1,
+                    file_path_name('fa', 'fsl', 'fb_ord') => 1,
+                    file_path_name('fa', 'fsl', 'fba') => 1,
+                    file_path_name('fa', 'fsl', 'fba', 'fba_ord') => 1,
+                    file_path_name('fa', 'fab') => 1,
+                    file_path_name('fa', 'fab', 'fab_ord') => 1,
+                    file_path_name('fa', 'fab', 'faba') => 1,
+                    file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
+                    file_path_name('fa', 'faa') => 1,
+                    file_path_name('fa', 'faa', 'faa_ord') => 1);
 
-    %Expect=(':' => 1, ':fa' => 1, ':fa:fsl' => 1, ':fa:fa_ord' => 1, ':fa:fab' => 1,
-             ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1,
-             ':fa:fab:faba:faba_ord' => 1, ':fa:faa' => 1, ':fa:faa:faa_ord' => 1,
-             ':fb' => 1, ':fb:fba' => 1, ':fb:fba:fba_ord' => 1, ':fb:fb_ord' => 1);
-    delete $Expect{':fa:fsl'} unless $symlink_exists;
-    %Expect_Dir = (':' => 1, ':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, 
-                   ':fb' => 1, ':fb:fba' => 1);
-    delete @Expect_Dir{':fb',':fb:fba'} unless $symlink_exists;
-    File::Find::finddepth( {wanted => \&d_wanted, no_chdir => 1 },':' );
-    Check( scalar(keys %Expect) == 0 );
+    %Expect_Name = ();
+    %Expect_Dir = ();
 
-    if ( $symlink_exists ) {
-      $FastFileTests_OK= 1;
-      %Expect=(':' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1,
-               'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faa' => 1,
-               'faa_ord' => 1);
-      %Expect_Dir = (':' => 1, 'fa' => 1, 'faa' => 1, 'fab' => 1, 'faba' => 1, 
-                     'fb' => 1, 'fba' => 1);	   
-      File::Find::find( {wanted => \&wanted, follow_fast => 1},':fa' );
-      Check( scalar(keys %Expect) == 0 );	  
+    File::Find::finddepth( {wanted => \&wanted_File, follow_fast => 1,
+			    no_chdir => 1}, topdir('fa') );
 
-      %Expect=(':fa' => 1, ':fa:fa_ord' => 1, ':fa:fsl' => 1, ':fa:fsl:fb_ord' => 1,
-               ':fa:fsl:fba' => 1, ':fa:fsl:fba:fba_ord' => 1, ':fa:fab' => 1,
-               ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1, ':fa:fab:faba:faba_ord' => 1,
-               ':fa:faa' => 1, ':fa:faa:faa_ord' => 1);
-      %Expect_Dir = (':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, 
-                     ':fb' => 1, ':fb:fba' => 1); 
-      File::Find::find( {wanted => \&wanted, follow_fast => 1, no_chdir => 1},':fa' );
-      Check( scalar(keys %Expect) == 0 );
+    Check( scalar(keys %Expect_File) == 0 );     
 
-      %Expect=(':fa' => 1, ':fa:fa_ord' => 1, ':fa:fsl' => 1, ':fa:fsl:fb_ord' => 1,
-               ':fa:fsl:fba' => 1, ':fa:fsl:fba:fba_ord' => 1, ':fa:fab' => 1,
-               ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1, ':fa:fab:faba:faba_ord' => 1,
-               ':fa:faa' => 1, ':fa:faa:faa_ord' => 1);
-        %Expect_Dir = (':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, 
-                       ':fb' => 1, ':fb:fba' => 1);
-      File::Find::finddepth( {wanted => \&dn_wanted, follow_fast => 1},':fa' );
-      Check( scalar(keys %Expect) == 0 );
+ 
+    print "# check dangling symbolic links\n";
+    MkDir( dir_path('dangling_dir'), 0770 );
+    CheckDie( symlink( dir_path('dangling_dir'),
+		       file_path('dangling_dir_sl') ) );
+    rmdir dir_path('dangling_dir');
+    touch(file_path('dangling_file'));  
+    if ($^O eq 'MacOS') {
+        CheckDie( symlink('dangling_file', ':fa:dangling_file_sl') );
+    } else {
+        CheckDie( symlink('../dangling_file','fa/dangling_file_sl') );
+    }      
+    unlink file_path('dangling_file');
 
-      %Expect=(':fa' => 1, ':fa:fa_ord' => 1, ':fa:fsl' => 1, ':fa:fsl:fb_ord' => 1,
-               ':fa:fsl:fba' => 1, ':fa:fsl:fba:fba_ord' => 1, ':fa:fab' => 1,
-               ':fa:fab:fab_ord' => 1, ':fa:fab:faba' => 1, ':fa:fab:faba:faba_ord' => 1,
-               ':fa:faa' => 1, ':fa:faa:faa_ord' => 1);
-      %Expect_Dir = (':fa' => 1, ':fa:faa' => 1, ':fa:fab' => 1, ':fa:fab:faba' => 1, 
-                     ':fb' => 1, ':fb:fba' => 1);
-      File::Find::finddepth( {wanted => \&d_wanted, follow_fast => 1, no_chdir => 1},':fa' );
-      Check( scalar(keys %Expect) == 0 );
+    { 
+        # these tests should also emit a warning
+	use warnings;
 
-      # tests below added by Thomas Wegner, 25-04-2001
+        %Expect_File = (File::Spec->curdir => 1,
+			file_path('fa_ord') => 1,
+                        file_path('fsl') => 1,
+                        file_path('fb_ord') => 1,
+			file_path('fba') => 1,
+                        file_path('fba_ord') => 1,
+			file_path('fab') => 1,
+                        file_path('fab_ord') => 1,
+                        file_path('faba') => 1,
+			file_path('faba_ord') => 1,
+                        file_path('faa') => 1,
+                        file_path('faa_ord') => 1);
 
-      print "# check dangling symbolic links\n";
-      MkDir( 'dangling_dir',0770 );
-      CheckDie( symlink('dangling_dir','dangling_dir_sl') );
-      rmdir 'dangling_dir';
-      touch('dangling_file');
-      CheckDie( symlink('dangling_file',':fa:dangling_file_sl') );
-      unlink 'dangling_file';
+        %Expect_Name = ();
+        %Expect_Dir = ();
+        undef $warn_msg;
 
-      %Expect=(':' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1,
-               'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faba_ord' => 1,
-               'faa' => 1, 'faa_ord' => 1);
-      %Expect_Dir = (':' => 1, 'fa' => 1, 'faa' => 1, 'fab' => 1, 'faba' => 1, 
-                     'fb' => 1, 'fba' => 1);	  
-      File::Find::find( {wanted => \&d_wanted, follow => 1}, 'dangling_dir_sl', ':fa' );
-      Check( $warn_msg =~ m|dangling_dir_sl is a dangling symbolic link| );	  
-      unlink ':fa:dangling_file_sl', 'dangling_dir_sl';
+        File::Find::find( {wanted => \&wanted_File, follow => 1,
+			   dangling_symlinks =>
+			       sub { $warn_msg = "$_[0] is a dangling symbolic link" }
+                           },
+                           topdir('dangling_dir_sl'), topdir('fa') );
 
-      print "# check recursion\n";
-      CheckDie( symlink(':fa:faa',':fa:faa:faa_sl') );
-      undef $@;
-      eval {File::Find::find( {wanted => \&simple_wanted, follow => 1},':fa' ); };
-      print "# Died: $@";
-      Check( $@ =~ m|:for_find:fa:faa:faa_sl is a recursive symbolic link| );	  
-      unlink 'faa_sl'; 
-      chdir ':::'; # chdir '../..';
+        Check( scalar(keys %Expect_File) == 0 );
+        Check( $warn_msg =~ m|dangling_dir_sl is a dangling symbolic link| );  
+        unlink file_path('fa', 'dangling_file_sl'),
+                         file_path('dangling_dir_sl');
 
-      print "# check follow_skip (file)\n";
-      CheckDie( symlink(':fa:fa_ord',':fa:fa_ord_sl') ); # symlink to a file
-      undef $@;
-      eval {File::Find::finddepth( {wanted => \&simple_wanted, follow => 1, follow_skip => 0},':fa' );};
-      print "# Died: $@";
-      Check( $@ =~ m|:for_find:fa:fa_ord encountered a second time| );
-      chdir '::'; # chdir '..';
+    }
 
-      %Expect=(':' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1,
-               'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faba_ord' => 1,
-               'faa' => 1, 'faa_ord' => 1);
-      %Expect_Dir = (':' => 1, 'fa' => 1, 'faa' => 1, 'fab' => 1, 'faba' => 1, 
-                     'fb' => 1, 'fba' => 1);	   
-      File::Find::finddepth( {wanted => \&d_wanted, follow => 1, follow_skip => 1},':fa' );
-      Check( scalar(keys %Expect) == 0 );
-      unlink ':fa:fa_ord_sl';
 
-      print "# check follow_skip (directory)\n";
-      CheckDie( symlink(':fa:faa',':fa:faa_sl') ); # symlink to a directory
-      undef $@;
-      eval {File::Find::find( {wanted => \&simple_wanted, follow => 1, follow_skip => 0},':fa' );};
-      print "# Died: $@";
-      Check( $@ =~ m|:for_find:fa:faa: encountered a second time| );
-      chdir '::'; # chdir '..';
+    print "# check recursion\n";
+    if ($^O eq 'MacOS') {
+        CheckDie( symlink(':fa:faa',':fa:faa:faa_sl') );
+    } else {
+        CheckDie( symlink('../faa','fa/faa/faa_sl') );
+    }
+    undef $@;
+    eval {File::Find::find( {wanted => \&simple_wanted, follow => 1,
+                             no_chdir => 1}, topdir('fa') ); };
+    Check( $@ =~ m|for_find[:/]fa[:/]faa[:/]faa_sl is a recursive symbolic link| );  
+    unlink file_path('fa', 'faa', 'faa_sl'); 
 
-      undef $@;
-      eval {File::Find::find( {wanted => \&simple_wanted, follow => 1, follow_skip => 1},':fa' );};
-      print "# Died: $@";
-      Check( $@ =~ m|:for_find:fa:faa: encountered a second time| );
-      chdir '::'; # chdir '..';	  
 
-      %Expect=(':' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1,
-               'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faba_ord' => 1,
-               'faa' => 1, 'faa_ord' => 1);
-      %Expect_Dir = (':' => 1, 'fa' => 1, 'faa' => 1, 'fab' => 1, 'faba' => 1, 
-                     'fb' => 1, 'fba' => 1);	   
-      File::Find::find( {wanted => \&d_wanted, follow => 1, follow_skip => 2},':fa' );
-      Check( scalar(keys %Expect) == 0 );
-      unlink ':fa:faa_sl';	  
+    print "# check follow_skip (file)\n";
+    if ($^O eq 'MacOS') {
+        CheckDie( symlink(':fa:fa_ord',':fa:fa_ord_sl') ); # symlink to a file
+    } else {
+        CheckDie( symlink('./fa_ord','fa/fa_ord_sl') ); # symlink to a file
     }
+    undef $@;
 
-} else {
+    eval {File::Find::finddepth( {wanted => \&simple_wanted,
+                                  follow => 1,
+                                  follow_skip => 0, no_chdir => 1},
+                                  topdir('fa') );};
+
+    Check( $@ =~ m|for_find[:/]fa[:/]fa_ord encountered a second time| );
+
+
+    # no_chdir is in effect, hence we use file_path_name to specify
+    # the expected paths for %Expect_File
+
+    %Expect_File = (file_path_name('fa') => 1,
+		    file_path_name('fa', 'fa_ord') => 1,
+		    file_path_name('fa', 'fsl') => 1,
+                    file_path_name('fa', 'fsl', 'fb_ord') => 1,
+                    file_path_name('fa', 'fsl', 'fba') => 1,
+                    file_path_name('fa', 'fsl', 'fba', 'fba_ord') => 1,
+                    file_path_name('fa', 'fab') => 1,
+                    file_path_name('fa', 'fab', 'fab_ord') => 1,
+                    file_path_name('fa', 'fab', 'faba') => 1,
+                    file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
+                    file_path_name('fa', 'faa') => 1,
+                    file_path_name('fa', 'faa', 'faa_ord') => 1);
 
-    MkDir( 'for_find',0770 );
-    CheckDie(chdir(for_find));
-    MkDir( 'fa',0770 );
-    MkDir( 'fb',0770  );
-    touch('fb/fb_ord');
-    MkDir( 'fb/fba',0770  );
-    touch('fb/fba/fba_ord');
-    CheckDie( symlink('../fb','fa/fsl') ) if $symlink_exists;
-    touch('fa/fa_ord');
+    %Expect_Name = ();
 
-    MkDir( 'fa/faa',0770  );
-    touch('fa/faa/faa_ord');
-    MkDir( 'fa/fab',0770  );
-    touch('fa/fab/fab_ord');
-    MkDir( 'fa/fab/faba',0770  );
-    touch('fa/fab/faba/faba_ord');
+    %Expect_Dir = (dir_path('fa') => 1,
+		   dir_path('fa', 'faa') => 1,
+                   dir_path('fa', 'fab') => 1,
+		   dir_path('fa', 'fab', 'faba') => 1,
+		   dir_path('fb') => 1,
+		   dir_path('fb','fba') => 1);
 
-    %Expect = ('.' => 1, 'fsl' => 1, 'fa_ord' => 1, 'fab' => 1, 'fab_ord' => 1,
-           'faba' => 1, 'faa' => 1, 'faa_ord' => 1);
-    delete $Expect{'fsl'} unless $symlink_exists;
-    %Expect_Dir = ('fa' => 1, 'faa' => 1, 'fab' => 1, 'faba' => 1, 
-                   'fb' => 1, 'fba' => 1);
-    delete @Expect_Dir{'fb','fba'} unless $symlink_exists;
-    File::Find::find( {wanted => \&wanted, },'fa' );
-    Check( scalar(keys %Expect) == 0 );
+    File::Find::finddepth( {wanted => \&wanted_File_Dir, follow => 1,
+                           follow_skip => 1, no_chdir => 1},
+                           topdir('fa') );
 
-    %Expect=('fa' => 1, 'fa/fsl' => 1, 'fa/fa_ord' => 1, 'fa/fab' => 1,
-         'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1,
-         'fa/fab/faba/faba_ord' => 1, 'fa/faa' => 1, 'fa/faa/faa_ord' => 1);
-    delete $Expect{'fa/fsl'} unless $symlink_exists;
-    %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, 
-                   'fb' => 1, 'fb/fba' => 1);
-    delete @Expect_Dir{'fb','fb/fba'} unless $symlink_exists;
-    File::Find::find( {wanted => \&wanted, no_chdir => 1},'fa' );
-    Check( scalar(keys %Expect) == 0 );
+    Check( scalar(keys %Expect_File) == 0 );
+    unlink file_path('fa', 'fa_ord_sl');
 
-    %Expect=('.' => 1, './fa' => 1, './fa/fsl' => 1, './fa/fa_ord' => 1, './fa/fab' => 1,
-             './fa/fab/fab_ord' => 1, './fa/fab/faba' => 1,
-             './fa/fab/faba/faba_ord' => 1, './fa/faa' => 1, './fa/faa/faa_ord' => 1,
-             './fb' => 1, './fb/fba' => 1, './fb/fba/fba_ord' => 1, './fb/fb_ord' => 1);
-    delete $Expect{'./fa/fsl'} unless $symlink_exists;
-    %Expect_Dir = ('./fa' => 1, './fa/faa' => 1, '/fa/fab' => 1, './fa/fab/faba' => 1, 
-                   './fb' => 1, './fb/fba' => 1);
-    delete @Expect_Dir{'./fb','./fb/fba'} unless $symlink_exists;
-    File::Find::finddepth( {wanted => \&dn_wanted },'.' );
-    Check( scalar(keys %Expect) == 0 );
 
-    %Expect=('.' => 1, './fa' => 1, './fa/fsl' => 1, './fa/fa_ord' => 1, './fa/fab' => 1,
-             './fa/fab/fab_ord' => 1, './fa/fab/faba' => 1,
-             './fa/fab/faba/faba_ord' => 1, './fa/faa' => 1, './fa/faa/faa_ord' => 1,
-             './fb' => 1, './fb/fba' => 1, './fb/fba/fba_ord' => 1, './fb/fb_ord' => 1);
-    delete $Expect{'./fa/fsl'} unless $symlink_exists;
-    %Expect_Dir = ('./fa' => 1, './fa/faa' => 1, '/fa/fab' => 1, './fa/fab/faba' => 1, 
-                   './fb' => 1, './fb/fba' => 1);
-    delete @Expect_Dir{'./fb','./fb/fba'} unless $symlink_exists;
-    File::Find::finddepth( {wanted => \&d_wanted, no_chdir => 1 },'.' );
-    Check( scalar(keys %Expect) == 0 );
+    print "# check follow_skip (directory)\n";
+    if ($^O eq 'MacOS') {
+        CheckDie( symlink(':fa:faa',':fa:faa_sl') ); # symlink to a directory
+    } else {
+        CheckDie( symlink('./faa','fa/faa_sl') ); # symlink to a directory
+    }
+    undef $@;
 
-    if ( $symlink_exists ) {
-      $FastFileTests_OK= 1;
-      %Expect=('.' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1,
-               'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faa' => 1,
-               'faa_ord' => 1);
-      %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, 
-                     'fb' => 1, 'fb/fba' => 1);
-      File::Find::find( {wanted => \&wanted, follow_fast => 1},'fa' );
-      Check( scalar(keys %Expect) == 0 );
+    eval {File::Find::find( {wanted => \&simple_wanted, follow => 1,
+                            follow_skip => 0, no_chdir => 1},
+                            topdir('fa') );};
 
-      %Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1,
-               'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1,
-               'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1,
-               'fa/faa' => 1, 'fa/faa/faa_ord' => 1);
-      %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, 
-                     'fb' => 1, 'fb/fba' => 1);
-      File::Find::find( {wanted => \&wanted, follow_fast => 1, no_chdir => 1},'fa' );
-      Check( scalar(keys %Expect) == 0 );
+    Check( $@ =~ m|for_find[:/]fa[:/]faa[:/]? encountered a second time| );
 
-      %Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1,
-               'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1,
-               'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1,
-               'fa/faa' => 1, 'fa/faa/faa_ord' => 1);
-      %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, 
-                     'fb' => 1, 'fb/fba' => 1);					 
-      File::Find::finddepth( {wanted => \&dn_wanted, follow_fast => 1},'fa' );
-      Check( scalar(keys %Expect) == 0 );
+  
+    undef $@;
 
-      %Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1,
-               'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1,
-               'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1,
-               'fa/faa' => 1, 'fa/faa/faa_ord' => 1);
-      %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, '/fa/fab' => 1, 'fa/fab/faba' => 1, 
-                     'fb' => 1, 'fb/fba' => 1);
-      File::Find::finddepth( {wanted => \&d_wanted, follow_fast => 1, no_chdir => 1},'fa' );
-      Check( scalar(keys %Expect) == 0 );
+    eval {File::Find::find( {wanted => \&simple_wanted, follow => 1,
+                            follow_skip => 1, no_chdir => 1},
+                            topdir('fa') );};
 
-      # tests below added by Thomas Wegner, 25-04-2001
+    Check( $@ =~ m|for_find[:/]fa[:/]faa[:/]? encountered a second time| );  
 
-      print "# check dangling symbolic links\n";
-      MkDir( 'dangling_dir',0770 );
-      CheckDie( symlink('dangling_dir','dangling_dir_sl') );
-      rmdir 'dangling_dir';
-      touch('dangling_file');
-      CheckDie( symlink('dangling_file','fa/dangling_file_sl') );
-      unlink 'dangling_file';
+    # no_chdir is in effect, hence we use file_path_name to specify
+    # the expected paths for %Expect_File
 
-      %Expect=('.' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1,
-               'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faba_ord' => 1,
-               'faa' => 1, 'faa_ord' => 1);
-      %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, 'fa/fab' => 1, 'fa/fab/faba' => 1, 
-                     'fb' => 1, 'fb/fba' => 1);
-      File::Find::find( {wanted => \&d_wanted, follow => 1}, 'dangling_dir_sl', 'fa' );
-      Check( $warn_msg =~ m|dangling_dir_sl is a dangling symbolic link| );	  
-      unlink 'fa/dangling_file_sl', 'dangling_dir_sl';
+    %Expect_File = (file_path_name('fa') => 1,
+		    file_path_name('fa', 'fa_ord') => 1,
+		    file_path_name('fa', 'fsl') => 1,
+                    file_path_name('fa', 'fsl', 'fb_ord') => 1,
+                    file_path_name('fa', 'fsl', 'fba') => 1,
+                    file_path_name('fa', 'fsl', 'fba', 'fba_ord') => 1,
+                    file_path_name('fa', 'fab') => 1,
+                    file_path_name('fa', 'fab', 'fab_ord') => 1,
+                    file_path_name('fa', 'fab', 'faba') => 1,
+                    file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
+                    file_path_name('fa', 'faa') => 1,
+                    file_path_name('fa', 'faa', 'faa_ord') => 1);
 
-      print "# check recursion\n";
-      CheckDie( symlink('fa/faa','fa/faa/faa_sl') );
-      undef $@;
-      eval {File::Find::find( {wanted => \&simple_wanted, follow => 1},'fa' ); };
-      print "# Died: $@";
-      Check( $@ =~ m|for_find/fa/faa/faa_sl is a recursive symbolic link| );	  
-      unlink 'faa_sl'; 
-      chdir '../..';
-      
-      print "# check follow_skip (file)\n";
-      CheckDie( symlink('fa/fa_ord','fa/fa_ord_sl') ); # symlink to a file
-      undef $@;
-      eval {File::Find::finddepth( {wanted => \&simple_wanted, follow => 1, follow_skip => 0},'fa' );};
-      print "# Died: $@";
-      Check( $@ =~ m|for_find/fa/fa_ord encountered a second time| );
-      chdir '..';
-      
-      %Expect=('.' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1,
-               'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faba_ord' => 1,
-               'faa' => 1, 'faa_ord' => 1);
-      %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, 'fa/fab' => 1, 'fa/fab/faba' => 1, 
-                     'fb' => 1, 'fb/fba' => 1);	   
-      File::Find::finddepth( {wanted => \&d_wanted, follow => 1, follow_skip => 1},'fa' );
-      Check( scalar(keys %Expect) == 0 );
-      unlink 'fa/fa_ord_sl';
+    %Expect_Name = ();
 
-      print "# check follow_skip (directory)\n";
-      CheckDie( symlink('fa/faa','fa/faa_sl') ); # symlink to a directory
-      undef $@;
-      eval {File::Find::find( {wanted => \&simple_wanted, follow => 1, follow_skip => 0},'fa' );};
-      print "# Died: $@";
-      Check( $@ =~ m|for_find/fa/faa encountered a second time| );
-      chdir '..';
+    %Expect_Dir = (dir_path('fa') => 1,
+		   dir_path('fa', 'faa') => 1,
+                   dir_path('fa', 'fab') => 1,
+		   dir_path('fa', 'fab', 'faba') => 1,
+		   dir_path('fb') => 1,
+		   dir_path('fb', 'fba') => 1);
 
-      undef $@;
-      eval {File::Find::find( {wanted => \&simple_wanted, follow => 1, follow_skip => 1},'fa' );};
-      print "# Died: $@";
-      Check( $@ =~ m|for_find/fa/faa encountered a second time| );
-      chdir '..';
+    File::Find::find( {wanted => \&wanted_File_Dir, follow => 1,
+		       follow_skip => 2, no_chdir => 1}, topdir('fa') );
 
-      %Expect=('.' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1,
-               'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faba_ord' => 1,
-               'faa' => 1, 'faa_ord' => 1);
-      %Expect_Dir = ('fa' => 1, 'fa/faa' => 1, 'fa/fab' => 1, 'fa/fab/faba' => 1, 
-                     'fb' => 1, 'fb/fba' => 1);		   
-      File::Find::find( {wanted => \&d_wanted, follow => 1, follow_skip => 2},'fa' );
-      Check( scalar(keys %Expect) == 0 );
-      unlink 'fa/faa_sl';
+    Check( scalar(keys %Expect_File) == 0 );
+    unlink file_path('fa', 'faa_sl');
 
-    }
-}
+} 
 
-print "# of cases: $case\n";

==== //depot/maint-5.6/macperl/t/lib/filefind-taint.t#1 (text) ====
Index: perl/t/lib/filefind-taint.t
--- perl/t/lib/filefind-taint.t.~1~	Sat Jul  7 18:00:05 2001
+++ perl/t/lib/filefind-taint.t	Sat Jul  7 18:00:05 2001
@@ -0,0 +1,417 @@
+#!./perl -T
+
+
+my %Expect_File = (); # what we expect for $_ 
+my %Expect_Name = (); # what we expect for $File::Find::name/fullname
+my %Expect_Dir  = (); # what we expect for $File::Find::dir
+my $symlink_exists = eval { symlink("",""); 1 };
+my $cwd;
+my $cwd_untainted;
+
+use Config;
+
+BEGIN {
+    chdir 't' if -d 't';
+    unshift @INC => '../lib';
+
+    for (keys %ENV) { # untaint ENV
+	($ENV{$_}) = $ENV{$_} =~ /(.*)/;
+    }
+
+    # Remove insecure directories from PATH
+    my @path;
+    my $sep = $Config{path_sep};
+    foreach my $dir (split(/\Q$sep/,$ENV{'PATH'}))
+    {
+	##
+	## Match the directory taint tests in mg.c::Perl_magic_setenv()
+	##
+	push(@path,$dir) unless (length($dir) >= 256
+				 or
+				 substr($dir,0,1) ne "/"
+				 or
+				 (stat $dir)[2] & 002);
+    }
+    $ENV{'PATH'} = join($sep,@path);
+}
+
+
+if ( $symlink_exists ) { print "1..45\n"; }
+else                   { print "1..27\n";  }
+
+use File::Find;
+use File::Spec;
+use Cwd;
+
+
+my $NonTaintedCwd = $^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'os2';
+
+cleanup();
+
+find({wanted => sub { print "ok 1\n" if $_ eq 'commonsense.t'; },
+      untaint => 1, untaint_pattern => qr|^(.+)$|}, File::Spec->curdir);
+
+finddepth({wanted => sub { print "ok 2\n" if $_ eq 'commonsense.t'; },
+           untaint => 1, untaint_pattern => qr|^(.+)$|},
+           File::Spec->curdir);
+
+my $case = 2;
+my $FastFileTests_OK = 0;
+
+sub cleanup {
+    if (-d dir_path('for_find')) {
+        chdir(dir_path('for_find'));
+    }
+    if (-d dir_path('fa')) {
+        unlink file_path('fa', 'fa_ord'),
+               file_path('fa', 'fsl'),
+               file_path('fa', 'faa', 'faa_ord'),
+               file_path('fa', 'fab', 'fab_ord'),
+               file_path('fa', 'fab', 'faba', 'faba_ord'),
+               file_path('fb', 'fb_ord'),
+               file_path('fb', 'fba', 'fba_ord');
+        rmdir dir_path('fa', 'faa');
+        rmdir dir_path('fa', 'fab', 'faba');
+        rmdir dir_path('fa', 'fab');
+        rmdir dir_path('fa');
+        rmdir dir_path('fb', 'fba');
+        rmdir dir_path('fb');
+        chdir File::Spec->updir;
+        rmdir dir_path('for_find');
+    }
+}
+
+END {
+    cleanup();
+}
+
+sub Check($) {
+    $case++;
+    if ($_[0]) { print "ok $case\n"; }
+    else       { print "not ok $case\n"; }
+
+}
+
+sub CheckDie($) {
+    $case++;
+    if ($_[0]) { print "ok $case\n"; }
+    else       { print "not ok $case\n"; exit 0; }
+}
+
+sub Skip($) {
+    $case++;
+    print "ok $case # skipped: ",$_[0],"\n"; 
+}
+
+sub touch {
+    CheckDie( open(my $T,'>',$_[0]) );
+}
+
+sub MkDir($$) {
+    CheckDie( mkdir($_[0],$_[1]) );
+}
+
+sub wanted_File_Dir {
+    print "# \$File::Find::dir => '$File::Find::dir'\n";
+    print "# \$_ => '$_'\n";
+    s#\.$## if ($^O eq 'VMS' && $_ ne '.');
+    Check( $Expect_File{$_} );
+    if ( $FastFileTests_OK ) {
+        delete $Expect_File{ $_} 
+          unless ( $Expect_Dir{$_} && ! -d _ );
+    } else {
+        delete $Expect_File{$_} 
+          unless ( $Expect_Dir{$_} && ! -d $_ );
+    }
+}
+
+sub wanted_File_Dir_prune {
+    &wanted_File_Dir;
+    $File::Find::prune=1 if  $_ eq 'faba';
+}
+
+
+sub simple_wanted {
+    print "# \$File::Find::dir => '$File::Find::dir'\n";
+    print "# \$_ => '$_'\n";
+}
+
+
+# Use dir_path() to specify a directory path that's expected for
+# $File::Find::dir (%Expect_Dir). Also use it in file operations like
+# chdir, rmdir etc.
+#
+# dir_path() concatenates directory names to form a _relative_
+# directory path, independant from the platform it's run on, although
+# there are limitations.  Don't try to create an absolute path,
+# because that may fail on operating systems that have the concept of
+# volume names (e.g. Mac OS). Be careful when you want to create an
+# updir path like ../fa (Unix) or ::fa: (Mac OS). Plain directory
+# names will work best. As a special case, you can pass it a "." as
+# first argument, to create a directory path like "./fa/dir" on
+# operating systems other than Mac OS (actually, Mac OS will ignore
+# the ".", if it's the first argument). If there's no second argument,
+# this function will return the empty string on Mac OS and the string
+# "./" otherwise.
+
+sub dir_path {
+    my $first_item = shift @_;
+
+    if ($first_item eq '.') {
+        if ($^O eq 'MacOS') {
+            return '' unless @_;
+            # ignore first argument; return a relative path
+            # with leading ":" and with trailing ":"
+            return File::Spec->catdir("", @_); 
+        } else { # other OS
+            return './' unless @_;
+            my $path = File::Spec->catdir(@_);
+            # add leading "./"
+            $path = "./$path";
+            return $path;
+        }
+
+    } else { # $first_item ne '.'
+        return $first_item unless @_; # return plain filename
+        if ($^O eq 'MacOS') {
+            # relative path with leading ":" and with trailing ":"
+            return File::Spec->catdir("", $first_item, @_);
+        } else { # other OS
+            return File::Spec->catdir($first_item, @_);
+        }
+    }
+}
+
+
+# Use topdir() to specify a directory path that you want to pass to
+#find/finddepth Basically, topdir() does the same as dir_path() (see
+#above), except that there's no trailing ":" on Mac OS.
+
+sub topdir {
+    my $path = dir_path(@_);
+    $path =~ s/:$// if ($^O eq 'MacOS');
+    return $path;
+}
+
+
+# Use file_path() to specify a file path that's expected for $_ (%Expect_File).
+# Also suitable for file operations like unlink etc.
+
+# file_path() concatenates directory names (if any) and a filename to
+# form a _relative_ file path (the last argument is assumed to be a
+# file). It's independant from the platform it's run on, although
+# there are limitations (see the warnings for dir_path() above). As a
+# special case, you can pass it a "." as first argument, to create a
+# file path like "./fa/file" on operating systems other than Mac OS
+# (actually, Mac OS will ignore the ".", if it's the first
+# argument). If there's no second argument, this function will return
+# the empty string on Mac OS and the string "./" otherwise.
+
+sub file_path {
+    my $first_item = shift @_;
+
+    if ($first_item eq '.') {
+        if ($^O eq 'MacOS') {
+            return '' unless @_;
+            # ignore first argument; return a relative path  
+            # with leading ":", but without trailing ":"
+            return File::Spec->catfile("", @_); 
+        } else { # other OS
+            return './' unless @_;
+            my $path = File::Spec->catfile(@_);
+            # add leading "./" 
+            $path = "./$path"; 
+            return $path;
+        }
+
+    } else { # $first_item ne '.'
+        return $first_item unless @_; # return plain filename
+        if ($^O eq 'MacOS') {
+            # relative path with leading ":", but without trailing ":"
+            return File::Spec->catfile("", $first_item, @_);
+        } else { # other OS
+            return File::Spec->catfile($first_item, @_);
+        }
+    }
+}
+
+
+# Use file_path_name() to specify a file path that's expected for
+# $File::Find::Name (%Expect_Name). Note: When the no_chdir => 1
+# option is in effect, $_ is the same as $File::Find::Name. In that
+# case, also use this function to specify a file path that's expected
+# for $_.
+#
+# Basically, file_path_name() does the same as file_path() (see
+# above), except that there's always a leading ":" on Mac OS, even for
+# plain file/directory names.
+
+sub file_path_name {
+    my $path = file_path(@_);
+    $path = ":$path" if (($^O eq 'MacOS') && ($path !~ /:/));
+    return $path;
+}
+
+
+
+MkDir( dir_path('for_find'), 0770 );
+CheckDie(chdir( dir_path('for_find')));
+
+$cwd = cwd(); # save cwd
+( $cwd_untainted ) = $cwd =~ m|^(.+)$|; # untaint it
+
+MkDir( dir_path('fa'), 0770 );
+MkDir( dir_path('fb'), 0770  );
+touch( file_path('fb', 'fb_ord') );
+MkDir( dir_path('fb', 'fba'), 0770  );
+touch( file_path('fb', 'fba', 'fba_ord') );
+if ($^O eq 'MacOS') {
+      CheckDie( symlink(':fb',':fa:fsl') ) if $symlink_exists;
+} else {
+      CheckDie( symlink('../fb','fa/fsl') ) if $symlink_exists;
+}
+touch( file_path('fa', 'fa_ord') );
+
+MkDir( dir_path('fa', 'faa'), 0770  );
+touch( file_path('fa', 'faa', 'faa_ord') );
+MkDir( dir_path('fa', 'fab'), 0770  );
+touch( file_path('fa', 'fab', 'fab_ord') );
+MkDir( dir_path('fa', 'fab', 'faba'), 0770  );
+touch( file_path('fa', 'fab', 'faba', 'faba_ord') );
+
+print "# check untainting (no follow)\n";
+
+# untainting here should work correctly
+
+%Expect_File = (File::Spec->curdir => 1, file_path('fsl') =>
+                1,file_path('fa_ord') => 1, file_path('fab') => 1,
+                file_path('fab_ord') => 1, file_path('faba') => 1,
+                file_path('faa') => 1, file_path('faa_ord') => 1);
+delete $Expect_File{ file_path('fsl') } unless $symlink_exists;
+%Expect_Name = ();
+
+%Expect_Dir = ( dir_path('fa') => 1, dir_path('faa') => 1,
+                dir_path('fab') => 1, dir_path('faba') => 1,
+                dir_path('fb') => 1, dir_path('fba') => 1);
+
+delete @Expect_Dir{ dir_path('fb'), dir_path('fba') } unless $symlink_exists;
+
+File::Find::find( {wanted => \&wanted_File_Dir_prune, untaint => 1,
+		   untaint_pattern => qr|^(.+)$|}, topdir('fa') );
+
+Check( scalar(keys %Expect_File) == 0 );
+
+
+# don't untaint at all, should die
+%Expect_File = ();
+%Expect_Name = ();
+%Expect_Dir  = ();
+undef $@;
+eval {File::Find::find( {wanted => \&simple_wanted}, topdir('fa') );};
+Check( $@ =~ m|Insecure dependency| );
+chdir($cwd_untainted);
+
+
+# untaint pattern doesn't match, should die 
+undef $@;
+
+eval {File::Find::find( {wanted => \&simple_wanted, untaint => 1,
+                         untaint_pattern => qr|^(NO_MATCH)$|},
+                         topdir('fa') );};
+
+Check( $@ =~ m|is still tainted| );
+chdir($cwd_untainted);
+
+
+# untaint pattern doesn't match, should die when we chdir to cwd   
+print "# check untaint_skip (No follow)\n";
+undef $@;
+
+eval {File::Find::find( {wanted => \&simple_wanted, untaint => 1,
+                         untaint_skip => 1, untaint_pattern =>
+                         qr|^(NO_MATCH)$|}, topdir('fa') );};
+
+print "# $@" if $@;
+#$^D = 8;
+if ($NonTaintedCwd) {
+	Skip("$^O does not taint cwd");
+    } 
+else {
+	Check( $@ =~ m|insecure cwd| );
+}
+chdir($cwd_untainted);
+
+
+if ( $symlink_exists ) {
+    print "# --- symbolic link tests --- \n";
+    $FastFileTests_OK= 1;
+
+    print "# check untainting (follow)\n";
+
+    # untainting here should work correctly
+    # no_chdir is in effect, hence we use file_path_name to specify the expected paths for %Expect_File
+
+    %Expect_File = (file_path_name('fa') => 1,
+		    file_path_name('fa','fa_ord') => 1,
+		    file_path_name('fa', 'fsl') => 1,
+                    file_path_name('fa', 'fsl', 'fb_ord') => 1,
+                    file_path_name('fa', 'fsl', 'fba') => 1,
+                    file_path_name('fa', 'fsl', 'fba', 'fba_ord') => 1,
+                    file_path_name('fa', 'fab') => 1,
+                    file_path_name('fa', 'fab', 'fab_ord') => 1,
+                    file_path_name('fa', 'fab', 'faba') => 1,
+                    file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
+                    file_path_name('fa', 'faa') => 1,
+                    file_path_name('fa', 'faa', 'faa_ord') => 1);
+
+    %Expect_Name = ();
+
+    %Expect_Dir = (dir_path('fa') => 1,
+		   dir_path('fa', 'faa') => 1,
+                   dir_path('fa', 'fab') => 1,
+		   dir_path('fa', 'fab', 'faba') => 1,
+		   dir_path('fb') => 1,
+		   dir_path('fb', 'fba') => 1);
+
+    File::Find::find( {wanted => \&wanted_File_Dir, follow_fast => 1,
+                       no_chdir => 1, untaint => 1, untaint_pattern =>
+                       qr|^(.+)$| }, topdir('fa') );
+
+    Check( scalar(keys %Expect_File) == 0 );
+ 
+    
+    # don't untaint at all, should die
+    undef $@;
+
+    eval {File::Find::find( {wanted => \&simple_wanted, follow => 1},
+			    topdir('fa') );};
+
+    Check( $@ =~ m|Insecure dependency| );
+    chdir($cwd_untainted);
+
+    # untaint pattern doesn't match, should die
+    undef $@;
+
+    eval {File::Find::find( {wanted => \&simple_wanted, follow => 1,
+                             untaint => 1, untaint_pattern =>
+                             qr|^(NO_MATCH)$|}, topdir('fa') );};
+
+    Check( $@ =~ m|is still tainted| );
+    chdir($cwd_untainted);
+
+    # untaint pattern doesn't match, should die when we chdir to cwd
+    print "# check untaint_skip (Follow)\n";
+    undef $@;
+
+    eval {File::Find::find( {wanted => \&simple_wanted, untaint => 1,
+                             untaint_skip => 1, untaint_pattern =>
+                             qr|^(NO_MATCH)$|}, topdir('fa') );};
+    if ($NonTaintedCwd) {
+	Skip("$^O does not taint cwd");
+    } 
+    else {
+	Check( $@ =~ m|insecure cwd| );
+    }
+    chdir($cwd_untainted);
+} 
+
End of Patch.