[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

[patch 5.005_63] (was Why was File::Find broken ($topdev))



On  3 Jan, David Dyck wrote:
> It seems the new File::Find (and find.pl) are no longer
> backward compatible with older scripts that used $topdev.
>  (If I should submit this via perlbug, let me know)
> 
> I have some perl scripts that were generated long ago with
> find2perl, and included -xdev
>   (sub wanted was comparing $dev (from the lstat of $_) with $topdev)
> 

Sorry for that, the need for these globals was documented in Find.pm so
I missed them.
Here is a patch

*** perl5.005_63/lib/File/Find.pm	Thu Jan  6 13:16:02 2000
--- perl5.005_63_ORIG/lib/File/Find.pm	Thu Dec 23 12:55:59 1999
***************
*** 122,131 ****
  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 compatibility
- reasons (find.pl, find2perl) there are in addition the following globals
- available: C<$File::Find::topdir>, C<$File::Find::topdev>, C<$File::Find::topino>,
- C<$File::Find::topmode> and C<$File::Find::topnlink>.
  
  This library is useful for the C<find2perl> tool, which when fed,
  
--- 122,127 ----
***************
*** 290,297 ****
      $untaint_pat      = $wanted->{untaint_pattern};
      $untaint_skip     = $wanted->{untaint_skip};
  
-     # for compatability reasons (find.pl, find2perl)
-     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;
--- 286,291 ----
***************
*** 301,307 ****
  	die "insecure cwd in find(depth)"  unless defined($cwd_untainted);
      }
      
!     my ($abs_dir, $Is_Dir);
  
      Proc_Top_Item:
      foreach my $TOP (@_) {
--- 295,301 ----
  	die "insecure cwd in find(depth)"  unless defined($cwd_untainted);
      }
      
!     my ($abs_dir, $nlink, $Is_Dir);
  
      Proc_Top_Item:
      foreach my $TOP (@_) {
***************
*** 330,344 ****
              }
          }
  	else { # no follow
!             $topdir = $top_item;
!             ($topdev,$topino,$topmode,$topnlink) = lstat $top_item;
!             unless (defined $topnlink) {
                  warn "Can't stat $top_item: $!\n";
                  next Proc_Top_Item;
              }
              if (-d _) {
  		$top_item =~ s/\.dir$// if $Is_VMS;
! 		_find_dir($wanted, $top_item, $topnlink);
  		$Is_Dir= 1;
              }
  	    else {
--- 324,337 ----
              }
          }
  	else { # no follow
!             $nlink = (lstat $top_item)[3];
!             unless (defined $nlink) {
                  warn "Can't stat $top_item: $!\n";
                  next Proc_Top_Item;
              }
              if (-d _) {
  		$top_item =~ s/\.dir$// if $Is_VMS;
! 		_find_dir($wanted, $top_item, $nlink);
  		$Is_Dir= 1;
              }
  	    else {

-- 
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
Institute of Technology, RWTH Aachen
D 52056 Aachen, Germany


References to:
David Dyck <dcd@tc.fluke.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]