Manual integration error in #12235.
[p5sagit/p5-mst-13.2.git] / lib / File / Find.pm
index 41e371e..ae76323 100644 (file)
@@ -1,8 +1,8 @@
 package File::Find;
+use 5.006;
 use strict;
 use warnings;
-use 5.6.0;
-our $VERSION = '1.01';
+our $VERSION = '1.02';
 require Exporter;
 require Cwd;
 
@@ -135,7 +135,7 @@ not in taint-mode, C<untaint> is a no-op.
 
 See above. This should be set using the C<qr> quoting operator.
 The default is set to  C<qr|^([-+@\w./]+)$|>. 
-Note that the parantheses are vital.
+Note that the parentheses are vital.
 
 =item C<untaint_skip>
 
@@ -176,12 +176,15 @@ produces something like:
         ($File::Find::prune = 1);
     }
 
+Notice the C<_> in the above C<int(-M _)>: the C<_> is a magical
+filehandle that caches the information from the preceding
+stat(), lstat(), or filetest.
+
 Set the variable C<$File::Find::dont_use_nlink> if you're using AFS,
 since AFS cheats.
 
-
-Here's another interesting wanted function.  It will find all symlinks
-that don't resolve:
+Here's another interesting wanted function.  It will find all symbolic
+links that don't resolve:
 
     sub wanted {
          -l && !-e && print "bogus link: $File::Find::name\n";
@@ -244,7 +247,7 @@ directories (requires Mac::Files):
  use Mac::Files;
 
  # invisible() --  returns 1 if file/directory is invisible,  
- # 0 if it's visible or undef if an error occured
+ # 0 if it's visible or undef if an error occurred
 
  sub invisible($) { 
    my $file = shift;
@@ -472,7 +475,7 @@ sub _find_opt {
        $pre_process, $post_process, $dangling_symlinks);
     local($dir, $name, $fullname, $prune);
 
-    my $cwd            = $wanted->{bydepth} ? Cwd::fastcwd() : Cwd::cwd();
+    my $cwd            = $wanted->{bydepth} ? Cwd::fastcwd() : Cwd::getcwd();
     my $cwd_untainted  = $cwd;
     my $check_t_cwd    = 1;
     $wanted_callback   = $wanted->{wanted};
@@ -488,7 +491,7 @@ sub _find_opt {
     $untaint_skip      = $wanted->{untaint_skip};
     $dangling_symlinks = $wanted->{dangling_symlinks};
 
-    # for compatability reasons (find.pl, find2perl)
+    # for compatibility reasons (find.pl, find2perl)
     local our ($topdir, $topdev, $topino, $topmode, $topnlink);
 
     # a symbolic link to a directory doesn't increase the link count
@@ -638,16 +641,14 @@ sub _find_dir($$$) {
     my $SE= [];
     my $dir_name= $p_dir;
     my $dir_pref;
-    my $dir_rel;
+    my $dir_rel = $File::Find::current_dir;
     my $tainted = 0;
 
     if ($Is_MacOS) {
        $dir_pref= ($p_dir =~ /:$/) ? $p_dir : "$p_dir:"; # preface
-       $dir_rel= ':'; # directory name relative to current directory
     }
     else {
        $dir_pref= ( $p_dir eq '/' ? '/' : "$p_dir/" );
-       $dir_rel= '.'; # directory name relative to current directory
     }
 
     local ($dir, $name, $prune, *DIR);
@@ -806,12 +807,7 @@ sub _find_dir($$$) {
 
            if ( $nlink == -2 ) {
                $name = $dir = $p_dir; # $File::Find::name / dir
-               if ($Is_MacOS) {
-                   $_ = ':'; # $_
-               }
-               else {
-                   $_ = '.';
-               }
+                $_ = $File::Find::current_dir;
                &$post_process;         # End-of-directory processing
            }
            elsif ( $nlink < 0 ) {  # must be finddepth, report dirname now
@@ -862,7 +858,7 @@ sub _find_dir_symlnk($$$) {
     my $dir_name = $p_dir;
     my $dir_pref;
     my $loc_pref;
-    my $dir_rel;
+    my $dir_rel = $File::Find::current_dir;
     my $byd_flag; # flag for pending stack entry if $bydepth
     my $tainted = 0;
     my $ok = 1;
@@ -870,11 +866,9 @@ sub _find_dir_symlnk($$$) {
     if ($Is_MacOS) {
        $dir_pref = ($p_dir =~ /:$/) ? "$p_dir" : "$p_dir:";
        $loc_pref = ($dir_loc =~ /:$/) ? "$dir_loc" : "$dir_loc:";
-       $dir_rel  = ':'; # directory name relative to current directory
     } else {
        $dir_pref = ( $p_dir   eq '/' ? '/' : "$p_dir/" );
        $loc_pref = ( $dir_loc eq '/' ? '/' : "$dir_loc/" );
-       $dir_rel  = '.'; # directory name relative to current directory
     }
 
     local ($dir, $name, $fullname, $prune, *DIR);