This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #71710] fixes for File::Find
[perl5.git] / lib / File / Find.pm
index eb4b2de..27c9466 100644 (file)
@@ -1,25 +1,30 @@
 package File::Find;
+use 5.006;
 use strict;
 use warnings;
-use 5.6.0;
-our $VERSION = '1.01';
+use warnings::register;
+our $VERSION = '1.18';
 require Exporter;
 require Cwd;
 
-=head1 NAME
+#
+# Modified to ensure sub-directory traversal order is not inverded by stack
+# push and pops.  That is remains in the same order as in the directory file,
+# or user pre-processing (EG:sorted).
+#
 
-find - traverse a file tree
+=head1 NAME
 
-finddepth - traverse a directory structure depth-first
+File::Find - Traverse a directory tree.
 
 =head1 SYNOPSIS
 
     use File::Find;
-    find(\&wanted, '/foo', '/bar');
+    find(\&wanted, @directories_to_search);
     sub wanted { ... }
 
     use File::Find;
-    finddepth(\&wanted, '/foo', '/bar');
+    finddepth(\&wanted, @directories_to_search);
     sub wanted { ... }
 
     use File::Find;
@@ -27,8 +32,44 @@ finddepth - traverse a directory structure depth-first
 
 =head1 DESCRIPTION
 
-The first argument to find() is either a hash reference describing the
-operations to be performed for each file, or a code reference.
+These are functions for searching through directory trees doing work
+on each file found similar to the Unix I<find> command.  File::Find
+exports two functions, C<find> and C<finddepth>.  They work similarly
+but have subtle differences.
+
+=over 4
+
+=item B<find>
+
+  find(\&wanted,  @directories);
+  find(\%options, @directories);
+
+C<find()> does a depth-first search over the given C<@directories> in
+the order they are given.  For each file or directory found, it calls
+the C<&wanted> subroutine.  (See below for details on how to use the
+C<&wanted> function).  Additionally, for each directory found, it will
+C<chdir()> into that directory and continue the search, invoking the
+C<&wanted> function on each file or subdirectory in the directory.
+
+=item B<finddepth>
+
+  finddepth(\&wanted,  @directories);
+  finddepth(\%options, @directories);
+
+C<finddepth()> works just like C<find()> except that it invokes the
+C<&wanted> function for a directory I<after> invoking it for the
+directory's contents.  It does a postorder traversal instead of a
+preorder traversal, working from the bottom of the directory tree up
+where C<find()> works from the top of the tree down.
+
+=back
+
+=head2 %options
+
+The first argument to C<find()> is either a code reference to your
+C<&wanted> function, or a hash reference describing the operations
+to be performed for each file.  The
+code reference is described in L<The wanted function> below.
 
 Here are the possible keys for the hash:
 
@@ -36,34 +77,35 @@ Here are the possible keys for the hash:
 
 =item C<wanted>
 
-The value should be a code reference.  This code reference is called
-I<the wanted() function> below.
+The value should be a code reference.  This code reference is
+described in L<The wanted function> below. The C<&wanted> subroutine is
+mandatory.
 
 =item C<bydepth>
 
 Reports the name of a directory only AFTER all its entries
-have been reported.  Entry point finddepth() is a shortcut for
-specifying C<{ bydepth => 1 }> in the first argument of find().
+have been reported.  Entry point C<finddepth()> is a shortcut for
+specifying C<< { bydepth => 1 } >> in the first argument of C<find()>.
 
 =item C<preprocess>
 
-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 
+The value should be a code reference. This code reference is used to
+preprocess the current directory. The name of the currently processed
+directory is in C<$File::Find::dir>. Your preprocessing function is
+called after C<readdir()>, but before the loop that calls the C<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 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 
+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 C<$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>
@@ -80,31 +122,40 @@ If either I<follow> or I<follow_fast> is in effect:
 =item *
 
 It is guaranteed that an I<lstat> has been called before the user's
-I<wanted()> function is called. This enables fast file checks involving S< _>.
+C<wanted()> function is called. This enables fast file checks involving S<_>.
+Note that this guarantee no longer holds if I<follow> or I<follow_fast>
+are not set.
 
 =item *
 
 There is a variable C<$File::Find::fullname> which holds the absolute
-pathname of the file with all symbolic links resolved
+pathname of the file with all symbolic links resolved.  If the link is
+a dangling symbolic link, then fullname will be set to C<undef>.
 
 =back
 
+This is a no-op on Win32.
+
 =item C<follow_fast>
 
 This is similar to I<follow> except that it may report some files more
 than once.  It does detect cycles, however.  Since only symbolic links
 have to be hashed, this is much cheaper both in space and time.  If
-processing a file more than once (by the user's I<wanted()> function)
+processing a file more than once (by the user's C<wanted()> function)
 is worse than just taking time, the option I<follow> should be used.
 
+This is also a no-op on Win32.
+
 =item C<follow_skip>
 
 C<follow_skip==1>, which is the default, causes all files which are
 neither directories nor symbolic links to be ignored if they are about
-to be processed a second time. If a directory or a symbolic link 
+to be processed a second time. If a directory or a symbolic link
 are about to be processed a second time, File::Find dies.
+
 C<follow_skip==0> causes File::Find to die if any file is about to be
 processed a second time.
+
 C<follow_skip==2> causes File::Find to ignore any duplicate files and
 directories but to proceed normally otherwise.
 
@@ -118,7 +169,7 @@ will be silently ignored.
 
 =item C<no_chdir>
 
-Does not C<chdir()> to each directory as it recurses. The wanted()
+Does not C<chdir()> to each directory as it recurses. The C<wanted()>
 function will need to be aware of this, of course. In this case,
 C<$_> will be the same as C<$File::Find::name>.
 
@@ -127,29 +178,71 @@ C<$_> will be the same as C<$File::Find::name>.
 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 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 
+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>
 
 See above. This should be set using the C<qr> quoting operator.
-The default is set to  C<qr|^([-+@\w./]+)$|>. 
+The default is set to  C<qr|^([-+@\w./]+)$|>.
 Note that the parentheses are vital.
 
 =item C<untaint_skip>
 
-If set, a directory which fails the I<untaint_pattern> is skipped, 
+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
 
-The wanted() function does whatever verifications you want.
-C<$File::Find::dir> contains the current directory name, and C<$_> the
-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 C<follow> or C<follow_fast> are in effect, there is
+=head2 The wanted function
+
+The C<wanted()> function does whatever verifications you want on
+each file and directory.  Note that despite its name, the C<wanted()>
+function is a generic callback function, and does B<not> tell
+File::Find if a file is "wanted" or not.  In fact, its return value
+is ignored.
+
+The wanted function takes no arguments but rather does its work
+through a collection of variables.
+
+=over 4
+
+=item C<$File::Find::dir> is the current directory name,
+
+=item C<$_> is the current filename within that directory
+
+=item C<$File::Find::name> is the complete pathname to the file.
+
+=back
+
+The above variables have all been localized and may be changed without
+affecting data outside of the wanted function.
+
+For example, when examining the file F</some/path/foo.ext> you will have:
+
+    $File::Find::dir  = /some/path/
+    $_                = foo.ext
+    $File::Find::name = /some/path/foo.ext
+
+You are chdir()'d to C<$File::Find::dir> when the function is called,
+unless C<no_chdir> was specified. Note that when changing to
+directories is in effect the root directory (F</>) is a somewhat
+special case inasmuch as the concatenation of C<$File::Find::dir>,
+C<'/'> and C<$_> is not literally equal to C<$File::Find::name>. The
+table below summarizes all variants:
+
+              $File::Find::name  $File::Find::dir  $_
+ default      /                  /                 .
+ no_chdir=>0  /etc               /                 etc
+              /etc/x             /etc              x
+
+ no_chdir=>1  /                  /                 /
+              /etc               /                 /etc
+              /etc/x             /etc              /etc/x
+
+
+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
@@ -178,10 +271,7 @@ produces something like:
 
 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.
+C<stat()>, C<lstat()>, or filetest.
 
 Here's another interesting wanted function.  It will find all symbolic
 links that don't resolve:
@@ -193,16 +283,47 @@ links that don't resolve:
 See also the script C<pfind> on CPAN for a nice application of this
 module.
 
+=head1 WARNINGS
+
+If you run your program with the C<-w> switch, or if you use the
+C<warnings> pragma, File::Find will report warnings for several weird
+situations. You can disable these warnings by putting the statement
+
+    no warnings 'File::Find';
+
+in the appropriate scope. See L<perllexwarn> for more info about lexical
+warnings.
+
 =head1 CAVEAT
 
+=over 2
+
+=item $dont_use_nlink
+
+You can set the variable C<$File::Find::dont_use_nlink> to 1, if you want to
+force File::Find to always stat directories. This was used for file systems
+that do not have an C<nlink> count matching the number of sub-directories.
+Examples are ISO-9660 (CD-ROM), AFS, HPFS (OS/2 file system), FAT (DOS file
+system) and a couple of others.
+
+You shouldn't need to set this variable, since File::Find should now detect
+such file systems on-the-fly and switch itself to using stat. This works even
+for parts of your file system, like a mounted CD-ROM.
+
+If you do set C<$File::Find::dont_use_nlink> to 1, you will notice slow-downs.
+
+=item symlinks
+
 Be aware that the option to follow symbolic links can be dangerous.
 Depending on the structure of the directory tree (including symbolic
 links to directories) you might traverse a given (physical) directory
-more than once (only if C<follow_fast> is in effect). 
+more than once (only if C<follow_fast> is in effect).
 Furthermore, deleting or changing files in a symbolically linked directory
 might cause very unpleasant surprises, since you delete or change files
 in an unknown directory.
 
+=back
+
 =head1 NOTES
 
 =over 4
@@ -213,46 +334,46 @@ Mac OS (Classic) users should note a few differences:
 
 =over 4
 
-=item *   
+=item *
 
-The path separator is ':', not '/', and the current directory is denoted 
-as ':', not '.'. You should be careful about specifying relative pathnames. 
-While a full path always begins with a volume name, a relative pathname 
-should always begin with a ':'.  If specifying a volume name only, a 
+The path separator is ':', not '/', and the current directory is denoted
+as ':', not '.'. You should be careful about specifying relative pathnames.
+While a full path always begins with a volume name, a relative pathname
+should always begin with a ':'.  If specifying a volume name only, a
 trailing ':' is required.
 
-=item *   
+=item *
 
-C<$File::Find::dir> is guaranteed to end with a ':'. If C<$_> 
-contains the name of a directory, that name may or may not end with a 
-':'. Likewise, C<$File::Find::name>, which contains the complete 
-pathname to that directory, and C<$File::Find::fullname>, which holds 
+C<$File::Find::dir> is guaranteed to end with a ':'. If C<$_>
+contains the name of a directory, that name may or may not end with a
+':'. Likewise, C<$File::Find::name>, which contains the complete
+pathname to that directory, and C<$File::Find::fullname>, which holds
 the absolute pathname of that directory with all symbolic links resolved,
 may or may not end with a ':'.
 
-=item *   
+=item *
 
-The default C<untaint_pattern> (see above) on Mac OS is set to  
+The default C<untaint_pattern> (see above) on Mac OS is set to
 C<qr|^(.+)$|>. Note that the parentheses are vital.
 
-=item *   
+=item *
 
-The invisible system file "Icon\015" is ignored. While this file may 
-appear in every directory, there are some more invisible system files 
-on every volume, which are all located at the volume root level (i.e. 
-"MacintoshHD:"). These system files are B<not> excluded automatically. 
-Your filter may use the following code to recognize invisible files or 
+The invisible system file "Icon\015" is ignored. While this file may
+appear in every directory, there are some more invisible system files
+on every volume, which are all located at the volume root level (i.e.
+"MacintoshHD:"). These system files are B<not> excluded automatically.
+Your filter may use the following code to recognize invisible files or
 directories (requires Mac::Files):
 
  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 occurred
 
- sub invisible($) { 
+ sub invisible($) {
    my $file = shift;
-   my ($fileCat, $fileInfo); 
-   my $invisible_flag =  1 << 14; 
+   my ($fileCat, $fileInfo);
+   my $invisible_flag =  1 << 14;
 
    if ( $fileCat = FSpGetCatInfo($file) ) {
      if ($fileInfo = $fileCat->ioFlFndrInfo() ) {
@@ -262,28 +383,38 @@ directories (requires Mac::Files):
    return undef;
  }
 
-Generally, invisible files are system files, unless an odd application 
-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 
+Generally, invisible files are system files, unless an odd application
+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
 (see MacPerl.pm for details).
 
 Files that appear on the desktop actually reside in an (hidden) directory
 named "Desktop Folder" on the particular disk volume. Note that, although
-all desktop files appear to be on the same "virtual" desktop, each disk 
+all desktop files appear to be on the same "virtual" desktop, each disk
 volume actually maintains its own "Desktop Folder" directory.
 
 =back
 
 =back
 
+=head1 BUGS AND CAVEATS
+
+Despite the name of the C<finddepth()> function, both C<find()> and
+C<finddepth()> perform a depth-first search of the directory
+hierarchy.
+
 =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.
 
+=head1 SEE ALSO
+
+find, find2perl.
+
 =cut
 
 our @ISA = qw(Exporter);
@@ -292,7 +423,7 @@ our @EXPORT = qw(find finddepth);
 
 use strict;
 my $Is_VMS;
-my $Is_MacOS;
+my $Is_Win32;
 
 require File::Basename;
 require File::Spec;
@@ -317,7 +448,7 @@ sub contract_name {
     my $abs_name= $cdir . $fn;
 
     if (substr($fn,0,3) eq '../') {
-       1 while $abs_name =~ s!/[^/]*/\.\./!/!;
+       1 while $abs_name =~ s!/[^/]*/\.\./+!/!;
     }
 
     return $abs_name;
@@ -325,7 +456,7 @@ sub contract_name {
 
 # return the absolute name of a directory or file
 sub contract_name_Mac {
-    my ($cdir,$fn) = @_; 
+    my ($cdir,$fn) = @_;
     my $abs_name;
 
     if ($fn =~ /^(:+)(.*)$/) { # valid pathname starting with a ':'
@@ -335,8 +466,8 @@ sub contract_name_Mac {
            $abs_name = $cdir . $2;
            return $abs_name;
        }
-       else { 
-           # need to move up the tree, but 
+       else {
+           # need to move up the tree, but
            # only if it's not a volume name
            for (my $i=1; $i<$colon_count; $i++) {
                unless ($cdir =~ /^[^:]+:$/) { # volume name
@@ -364,7 +495,7 @@ sub contract_name_Mac {
                return $abs_name;
            }
        }
-       else { # argh!, $fn is not a valid directory/file 
+       else { # argh!, $fn is not a valid directory/file
             return undef;
        }
     }
@@ -374,32 +505,20 @@ sub PathCombine($$) {
     my ($Base,$Name) = @_;
     my $AbsName;
 
-    if ($Is_MacOS) {
-       # $Name is the resolved symlink (always a full path on MacOS),
-       # i.e. there's no need to call contract_name_Mac()
-       $AbsName = $Name; 
-
-       # (simple) check for recursion
-       if ( ( $Base =~ /^$AbsName/) && (-d $AbsName) ) { # recursion
-           return undef;
-       }
+    if (substr($Name,0,1) eq '/') {
+       $AbsName= $Name;
     }
     else {
-       if (substr($Name,0,1) eq '/') {
-           $AbsName= $Name;
-       }
-       else {
-           $AbsName= contract_name($Base,$Name);
-       }
+       $AbsName= contract_name($Base,$Name);
+    }
 
-       # (simple) check for recursion
-       my $newlen= length($AbsName);
-       if ($newlen <= length($Base)) {
-           if (($newlen == length($Base) || substr($Base,$newlen,1) eq '/')
-               && $AbsName eq substr($Base,0,$newlen))
-           {
-               return undef;
-           }
+    # (simple) check for recursion
+    my $newlen= length($AbsName);
+    if ($newlen <= length($Base)) {
+       if (($newlen == length($Base) || substr($Base,$newlen,1) eq '/')
+           && $AbsName eq substr($Base,0,$newlen))
+       {
+           return undef;
        }
     }
     return $AbsName;
@@ -436,7 +555,7 @@ sub Follow_SymLink($) {
        return undef unless defined $DEV;  #  dangling symbolic link
     }
 
-    if ($full_check && $SLnkSeen{$DEV, $INO}++) {
+    if ($full_check && defined $DEV && $SLnkSeen{$DEV, $INO}++) {
        if ( ($follow_skip < 1) || ((-d _) && ($follow_skip < 2)) ) {
            die "$AbsName encountered a second time";
        }
@@ -460,7 +579,7 @@ sub is_tainted_pp {
     local $@;
     eval { eval "# $nada" };
     return length($@) != 0;
-} 
+}
 
 sub _find_opt {
     my $wanted = shift;
@@ -474,8 +593,23 @@ sub _find_opt {
        $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();
+    local *_ = \my $a;
+
+    my $cwd            = $wanted->{bydepth} ? Cwd::fastcwd() : Cwd::getcwd();
+    if ($Is_VMS) {
+       # VMS returns this by default in VMS format which just doesn't
+       # work for the rest of this module.
+       $cwd = VMS::Filespec::unixpath($cwd);
+
+       # Apparently this is not expected to have a trailing space.
+       # To attempt to make VMS/UNIX conversions mostly reversable,
+       # a trailing slash is needed.  The run-time functions ignore the
+       # resulting double slash, but it causes the perl tests to fail.
+        $cwd =~ s#/\z##;
+
+       # This comes up in upper case now, but should be lower.
+       # In the future this could be exact case, no need to change.
+    }
     my $cwd_untainted  = $cwd;
     my $check_t_cwd    = 1;
     $wanted_callback   = $wanted->{wanted};
@@ -483,8 +617,9 @@ sub _find_opt {
     $pre_process       = $wanted->{preprocess};
     $post_process      = $wanted->{postprocess};
     $no_chdir          = $wanted->{no_chdir};
-    $full_check        = $wanted->{follow};
-    $follow            = $full_check || $wanted->{follow_fast};
+    $full_check        = $Is_Win32 ? 0 : $wanted->{follow};
+    $follow            = $Is_Win32 ? 0 :
+                             $full_check || $wanted->{follow_fast};
     $follow_skip       = $wanted->{follow_skip};
     $untaint           = $wanted->{untaint};
     $untaint_pat       = $wanted->{untaint_pattern};
@@ -496,52 +631,36 @@ sub _find_opt {
 
     # a symbolic link to a directory doesn't increase the link count
     $avoid_nlink      = $follow || $File::Find::dont_use_nlink;
-    
+
     my ($abs_dir, $Is_Dir);
 
     Proc_Top_Item:
     foreach my $TOP (@_) {
        my $top_item = $TOP;
 
-       if ($Is_MacOS) {
-           ($topdev,$topino,$topmode,$topnlink) = $follow ? stat $top_item : lstat $top_item;
-           $top_item = ":$top_item"
-               if ( (-d _) && ( $top_item !~ /:/ ) );
+       ($topdev,$topino,$topmode,$topnlink) = $follow ? stat $top_item : lstat $top_item;
+
+       if ($Is_Win32) {
+           $top_item =~ s|[/\\]\z||
+             unless $top_item =~ m{^(?:\w:)?[/\\]$};
        }
        else {
            $top_item =~ s|/\z|| unless $top_item eq '/';
-           ($topdev,$topino,$topmode,$topnlink) = $follow ? stat $top_item : lstat $top_item;
        }
 
        $Is_Dir= 0;
 
        if ($follow) {
 
-           if ($Is_MacOS) {
-               $cwd = "$cwd:" unless ($cwd =~ /:$/); # for safety
-
-               if ($top_item eq $File::Find::current_dir) {
-                   $abs_dir = $cwd;
-               }
-               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" if $^W;
-                       next Proc_Top_Item;
-                   }
-               }
-
+           if (substr($top_item,0,1) eq '/') {
+               $abs_dir = $top_item;
            }
-           else {
-               if (substr($top_item,0,1) eq '/') {
-                   $abs_dir = $top_item;
-               }
-               elsif ($top_item eq $File::Find::current_dir) {
-                   $abs_dir = $cwd;
-               }
-               else {  # care about any  ../
-                   $abs_dir = contract_name("$cwd/",$top_item);
-               }
+           elsif ($top_item eq $File::Find::current_dir) {
+               $abs_dir = $cwd;
+           }
+           else {  # care about any  ../
+               $top_item =~ s/\.dir\z//i if $Is_VMS;
+               $abs_dir = contract_name("$cwd/",$top_item);
            }
            $abs_dir= Follow_SymLink($abs_dir);
            unless (defined $abs_dir) {
@@ -549,13 +668,14 @@ sub _find_opt {
                    if (ref $dangling_symlinks eq 'CODE') {
                        $dangling_symlinks->($top_item, $cwd);
                    } else {
-                       warn "$top_item is a dangling symbolic link\n" if $^W;
+                       warnings::warnif "$top_item is a dangling symbolic link\n";
                    }
                }
                next Proc_Top_Item;
            }
 
            if (-d _) {
+               $top_item =~ s/\.dir\z//i if $Is_VMS;
                _find_dir_symlnk($wanted, $abs_dir, $top_item);
                $Is_Dir= 1;
            }
@@ -563,11 +683,11 @@ sub _find_opt {
        else { # no follow
            $topdir = $top_item;
            unless (defined $topnlink) {
-               warn "Can't stat $top_item: $!\n" if $^W;
+               warnings::warnif "Can't stat $top_item: $!\n";
                next Proc_Top_Item;
            }
            if (-d _) {
-               $top_item =~ s/\.dir\z// if $Is_VMS;
+               $top_item =~ s/\.dir\z//i if $Is_VMS;
                _find_dir($wanted, $top_item, $topnlink);
                $Is_Dir= 1;
            }
@@ -578,12 +698,7 @@ sub _find_opt {
 
        unless ($Is_Dir) {
            unless (($_,$dir) = File::Basename::fileparse($abs_dir)) {
-               if ($Is_MacOS) {
-                   ($dir,$_) = (':', $top_item); # $File::Find::dir, $_
-               }
-               else {
-                   ($dir,$_) = ('./', $top_item);
-               }
+               ($dir,$_) = ('./', $top_item);
            }
 
            $abs_dir = $dir;
@@ -600,13 +715,14 @@ sub _find_opt {
            }
 
            unless ($no_chdir || chdir $abs_dir) {
-               warn "Couldn't chdir $abs_dir: $!\n" if $^W;
+               warnings::warnif "Couldn't chdir $abs_dir: $!\n";
                next Proc_Top_Item;
            }
 
            $name = $abs_dir . $_; # $File::Find::name
+           $_ = $name if $no_chdir;
 
-           { &$wanted_callback }; # protect against wild "next"
+           { $wanted_callback->() }; # protect against wild "next"
 
        }
 
@@ -641,16 +757,26 @@ 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;
+    my $no_nlink;
+
+    if ($Is_Win32) {
+       $dir_pref
+         = ($p_dir =~ m{^(?:\w:[/\\]?|[/\\])$} ? $p_dir : "$p_dir/" );
+    } elsif ($Is_VMS) {
+
+       #       VMS is returning trailing .dir on directories
+       #       and trailing . on files and symbolic links
+       #       in UNIX syntax.
+       #
+
+       $p_dir =~ s/\.(dir)?$//i unless $p_dir eq '.';
 
-    if ($Is_MacOS) {
-       $dir_pref= ($p_dir =~ /:$/) ? $p_dir : "$p_dir:"; # preface
-       $dir_rel= ':'; # directory name relative to current directory
+       $dir_pref = ($p_dir =~ m/[\]>]+$/ ? $p_dir : "$p_dir/" );
     }
     else {
        $dir_pref= ( $p_dir eq '/' ? '/' : "$p_dir/" );
-       $dir_rel= '.'; # directory name relative to current directory
     }
 
     local ($dir, $name, $prune, *DIR);
@@ -668,8 +794,8 @@ sub _find_dir($$$) {
                }
            }
        }
-       unless (chdir $udir) {
-           warn "Can't cd to $udir: $!\n" if $^W;
+       unless (chdir ($Is_VMS && $udir !~ /[\/\[<]+/ ? "./$udir" : $udir)) {
+           warnings::warnif "Can't cd to $udir: $!\n";
            return;
        }
     }
@@ -677,18 +803,14 @@ sub _find_dir($$$) {
     # push the starting directory
     push @Stack,[$CdLvl,$p_dir,$dir_rel,-1]  if  $bydepth;
 
-    if ($Is_MacOS) {
-       $p_dir = $dir_pref;  # ensure trailing ':'
-    }
-
     while (defined $SE) {
        unless ($bydepth) {
-           $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 ); # $_
            # prune may happen here
            $prune= 0;
-           { &$wanted_callback };      # protect against wild "next"
+           { $wanted_callback->() };   # protect against wild "next"
            next if $prune;
        }
 
@@ -699,53 +821,54 @@ sub _find_dir($$$) {
                ( $udir ) = $dir_rel =~ m|$untaint_pat|;
                unless (defined $udir) {
                    if ($untaint_skip == 0) {
-                       if ($Is_MacOS) {
-                           die "directory ($p_dir) $dir_rel is still tainted";
-                       }
-                       else {
-                           die "directory (" . ($p_dir ne '/' ? $p_dir : '') . "/) $dir_rel is still tainted";
-                       }
+                       die "directory (" . ($p_dir ne '/' ? $p_dir : '') . "/) $dir_rel is still tainted";
                    } else { # $untaint_skip == 1
-                       next; 
+                       next;
                    }
                }
            }
-           unless (chdir $udir) {
-               if ($Is_MacOS) {
-                   warn "Can't cd to ($p_dir) $udir: $!\n" if $^W;
-               }
-               else {
-                   warn "Can't cd to (" . ($p_dir ne '/' ? $p_dir : '') . "/) $udir: $!\n" if $^W;
-               }
+           unless (chdir ($Is_VMS && $udir !~ /[\/\[<]+/ ? "./$udir" : $udir)) {
+               warnings::warnif "Can't cd to (" .
+                   ($p_dir ne '/' ? $p_dir : '') . "/) $udir: $!\n";
                next;
            }
            $CdLvl++;
        }
 
-       if ($Is_MacOS) {
-           $dir_name = "$dir_name:" unless ($dir_name =~ /:$/);
-       }
-
-       $dir= $dir_name; # $File::Find::dir 
+       $dir= $dir_name; # $File::Find::dir
 
        # 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" if $^W;
+           warnings::warnif "Can't opendir($dir_name): $!\n";
            next;
        }
        @filenames = readdir DIR;
        closedir(DIR);
-       @filenames = &$pre_process(@filenames) if $pre_process;
+       @filenames = $pre_process->(@filenames) if $pre_process;
        push @Stack,[$CdLvl,$dir_name,"",-2]   if $post_process;
 
-       if ($nlink == 2 && !$avoid_nlink) {
+       # default: use whatever was specifid
+        # (if $nlink >= 2, and $avoid_nlink == 0, this will switch back)
+        $no_nlink = $avoid_nlink;
+        # if dir has wrong nlink count, force switch to slower stat method
+        $no_nlink = 1 if ($nlink < 2);
+
+       if ($nlink == 2 && !$no_nlink) {
            # This dir has no subdirectories.
            for my $FN (@filenames) {
+               if ($Is_VMS) {
+               # Big hammer here - Compensate for VMS trailing . and .dir
+               # No win situation until this is changed, but this
+               # will handle the majority of the cases with breaking the fewest
+
+                   $FN =~ s/\.dir\z//i;
+                   $FN =~ s#\.$## if ($FN ne '.');
+               }
                next if $FN =~ $File::Find::skip_pattern;
                
                $name = $dir_pref . $FN; # $File::Find::name
                $_ = ($no_chdir ? $name : $FN); # $_
-               { &$wanted_callback }; # protect against wild "next"
+               { $wanted_callback->() }; # protect against wild "next"
            }
 
        }
@@ -753,9 +876,14 @@ sub _find_dir($$$) {
            # This dir has subdirectories.
            $subcount = $nlink - 2;
 
+           # HACK: insert directories at this position. so as to preserve
+           # the user pre-processed ordering of files.
+           # EG: directory traversal is in user sorted order, not at random.
+            my $stack_top = @Stack;
+
            for my $FN (@filenames) {
                next if $FN =~ $File::Find::skip_pattern;
-               if ($subcount > 0 || $avoid_nlink) {
+               if ($subcount > 0 || $no_nlink) {
                    # Seen all the subdirs?
                    # check for directoriness.
                    # stat is faster for a file in the current directory
@@ -763,19 +891,22 @@ sub _find_dir($$$) {
 
                    if (-d _) {
                        --$subcount;
-                       $FN =~ s/\.dir\z// if $Is_VMS;
-                       push @Stack,[$CdLvl,$dir_name,$FN,$sub_nlink];
+                       $FN =~ s/\.dir\z//i if $Is_VMS;
+                       # HACK: replace push to preserve dir traversal order
+                       #push @Stack,[$CdLvl,$dir_name,$FN,$sub_nlink];
+                       splice @Stack, $stack_top, 0,
+                                [$CdLvl,$dir_name,$FN,$sub_nlink];
                    }
                    else {
                        $name = $dir_pref . $FN; # $File::Find::name
                        $_= ($no_chdir ? $name : $FN); # $_
-                       { &$wanted_callback }; # protect against wild "next"
+                       { $wanted_callback->() }; # protect against wild "next"
                    }
                }
                else {
                    $name = $dir_pref . $FN; # $File::Find::name
                    $_= ($no_chdir ? $name : $FN); # $_
-                   { &$wanted_callback }; # protect against wild "next"
+                   { $wanted_callback->() }; # protect against wild "next"
                }
            }
        }
@@ -785,22 +916,31 @@ sub _find_dir($$$) {
            ($Level, $p_dir, $dir_rel, $nlink) = @$SE;
            if ($CdLvl > $Level && !$no_chdir) {
                my $tmp;
-               if ($Is_MacOS) {
-                   $tmp = (':' x ($CdLvl-$Level)) . ':';
+               if ($Is_VMS) {
+                   $tmp = '[' . ('-' x ($CdLvl-$Level)) . ']';
                }
                else {
                    $tmp = join('/',('..') x ($CdLvl-$Level));
                }
-               die "Can't cd to $dir_name" . $tmp
+               die "Can't cd to $tmp from $dir_name"
                    unless chdir ($tmp);
                $CdLvl = $Level;
            }
 
-           if ($Is_MacOS) {
-               # $pdir always has a trailing ':', except for the starting dir,
-               # where $dir_rel eq ':'
-               $dir_name = "$p_dir$dir_rel";
-               $dir_pref = "$dir_name:";
+           if ($^O eq 'MSWin32') {
+               $dir_name = ($p_dir =~ m|\w:/?$| ? "$p_dir$dir_rel" : "$p_dir/$dir_rel");
+               $dir_pref = "$dir_name/";
+           }
+           elsif ($^O eq 'VMS') {
+                if ($p_dir =~ m/[\]>]+$/) {
+                    $dir_name = $p_dir;
+                    $dir_name =~ s/([\]>]+)$/.$dir_rel$1/;
+                    $dir_pref = $dir_name;
+                }
+                else {
+                    $dir_name = "$p_dir/$dir_rel";
+                    $dir_pref = "$dir_name/";
+                }
            }
            else {
                $dir_name = ($p_dir eq '/' ? "/$dir_rel" : "$p_dir/$dir_rel");
@@ -809,35 +949,20 @@ sub _find_dir($$$) {
 
            if ( $nlink == -2 ) {
                $name = $dir = $p_dir; # $File::Find::name / dir
-               if ($Is_MacOS) {
-                   $_ = ':'; # $_
-               }
-               else {
-                   $_ = '.';
-               }
-               &$post_process;         # End-of-directory processing
+                $_ = $File::Find::current_dir;
+               $post_process->();              # End-of-directory processing
            }
            elsif ( $nlink < 0 ) {  # must be finddepth, report dirname now
                $name = $dir_name;
-               if ($Is_MacOS) {
-                   if ($dir_rel eq ':') { # must be the top dir, where we started
-                       $name =~ s|:$||; # $File::Find::name
-                       $p_dir = "$p_dir:" unless ($p_dir =~ /:$/);
-                   }
-                   $dir = $p_dir; # $File::Find::dir
-                   $_ = ($no_chdir ? $name : $dir_rel); # $_
+               if ( substr($name,-2) eq '/.' ) {
+                   substr($name, length($name) == 2 ? -1 : -2) = '';
                }
-               else {
-                   if ( substr($name,-2) eq '/.' ) {
-                       $name =~ s|/\.$||;
-                   }
-                   $dir = $p_dir;
-                   $_ = ($no_chdir ? $dir_name : $dir_rel );
-                   if ( substr($_,-2) eq '/.' ) {
-                       s|/\.$||;
-                   }
+               $dir = $p_dir;
+               $_ = ($no_chdir ? $dir_name : $dir_rel );
+               if ( substr($_,-2) eq '/.' ) {
+                   substr($_, length($_) == 2 ? -1 : -2) = '';
                }
-               { &$wanted_callback }; # protect against wild "next"
+               { $wanted_callback->() }; # protect against wild "next"
             }
             else {
                push @Stack,[$CdLvl,$p_dir,$dir_rel,-1]  if  $bydepth;
@@ -865,20 +990,13 @@ 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;
 
-    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
-    }
+    $dir_pref = ( $p_dir   eq '/' ? '/' : "$p_dir/" );
+    $loc_pref = ( $dir_loc eq '/' ? '/' : "$dir_loc/" );
 
     local ($dir, $name, $fullname, $prune, *DIR);
 
@@ -887,8 +1005,8 @@ sub _find_dir_symlnk($$$) {
        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 
+           # 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";
@@ -900,24 +1018,20 @@ sub _find_dir_symlnk($$$) {
        }
        $ok = chdir($updir_loc) unless ($p_dir eq $File::Find::current_dir);
        unless ($ok) {
-           warn "Can't cd to $updir_loc: $!\n" if $^W;
+           warnings::warnif "Can't cd to $updir_loc: $!\n";
            return;
        }
     }
 
     push @Stack,[$dir_loc,$updir_loc,$p_dir,$dir_rel,-1]  if  $bydepth;
 
-    if ($Is_MacOS) {
-       $p_dir = $dir_pref; # ensure trailing ':'
-    }
-
     while (defined $SE) {
 
        unless ($bydepth) {
            # change (back) to parent directory (always untainted)
            unless ($no_chdir) {
                unless (chdir $updir_loc) {
-                   warn "Can't cd to $updir_loc: $!\n" if $^W;
+                   warnings::warnif "Can't cd to $updir_loc: $!\n";
                    next;
                }
            }
@@ -928,7 +1042,7 @@ sub _find_dir_symlnk($$$) {
            # prune may happen here
            $prune= 0;
            lstat($_); # make sure  file tests with '_' work
-           { &$wanted_callback }; # protect against wild "next"
+           { $wanted_callback->() }; # protect against wild "next"
            next if $prune;
        }
 
@@ -936,7 +1050,7 @@ sub _find_dir_symlnk($$$) {
        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 
+               # 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) {
@@ -948,42 +1062,66 @@ sub _find_dir_symlnk($$$) {
                }
            }
            unless (chdir $updir_loc) {
-               warn "Can't cd to $updir_loc: $!\n" if $^W;
+               warnings::warnif "Can't cd to $updir_loc: $!\n";
                next;
            }
        }
 
-       if ($Is_MacOS) {
-           $dir_name = "$dir_name:" unless ($dir_name =~ /:$/);
-       }
-
        $dir = $dir_name; # $File::Find::dir
 
        # 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" if $^W;
+           warnings::warnif "Can't opendir($dir_loc): $!\n";
            next;
        }
        @filenames = readdir DIR;
        closedir(DIR);
 
        for my $FN (@filenames) {
+           if ($Is_VMS) {
+           # Big hammer here - Compensate for VMS trailing . and .dir
+           # No win situation until this is changed, but this
+           # will handle the majority of the cases with breaking the fewest.
+
+               $FN =~ s/\.dir\z//i;
+               $FN =~ s#\.$## if ($FN ne '.');
+           }
            next if $FN =~ $File::Find::skip_pattern;
 
            # follow symbolic links / do an lstat
            $new_loc = Follow_SymLink($loc_pref.$FN);
 
            # ignore if invalid symlink
-           next unless defined $new_loc;
+           unless (defined $new_loc) {
+               if (!defined -l _ && $dangling_symlinks) {
+                   if (ref $dangling_symlinks eq 'CODE') {
+                       $dangling_symlinks->($FN, $dir_pref);
+                   } else {
+                       warnings::warnif "$dir_pref$FN is a dangling symbolic link\n";
+                   }
+               }
+
+               $fullname = undef;
+               $name = $dir_pref . $FN;
+               $_ = ($no_chdir ? $name : $FN);
+               { $wanted_callback->() };
+               next;
+           }
 
            if (-d _) {
+               if ($Is_VMS) {
+                   $FN =~ s/\.dir\z//i;
+                   $FN =~ s#\.$## if ($FN ne '.');
+                   $new_loc =~ s/\.dir\z//i;
+                   $new_loc =~ s#\.$## if ($new_loc ne '.');
+               }
                push @Stack,[$new_loc,$updir_loc,$dir_name,$FN,1];
            }
            else {
-               $fullname = $new_loc; # $File::Find::fullname 
+               $fullname = $new_loc; # $File::Find::fullname
                $name = $dir_pref . $FN; # $File::Find::name
                $_ = ($no_chdir ? $name : $FN); # $_
-               { &$wanted_callback }; # protect against wild "next"
+               { $wanted_callback->() }; # protect against wild "next"
            }
        }
 
@@ -991,48 +1129,29 @@ sub _find_dir_symlnk($$$) {
     continue {
        while (defined($SE = pop @Stack)) {
            ($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 eq ':'
-               $dir_name = "$p_dir$dir_rel";
-               $dir_pref = "$dir_name:";
-               $loc_pref = ($dir_loc =~ /:$/) ? $dir_loc : "$dir_loc:";
-           }
-           else {
-               $dir_name = ($p_dir eq '/' ? "/$dir_rel" : "$p_dir/$dir_rel");
-               $dir_pref = "$dir_name/";
-               $loc_pref = "$dir_loc/";
-           }
+           $dir_name = ($p_dir eq '/' ? "/$dir_rel" : "$p_dir/$dir_rel");
+           $dir_pref = "$dir_name/";
+           $loc_pref = "$dir_loc/";
            if ( $byd_flag < 0 ) {  # must be finddepth, report dirname now
                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;
+                   unless (chdir $updir_loc) { # $updir_loc (parent dir) is always untainted
+                       warnings::warnif "Can't cd to $updir_loc: $!\n";
                        next;
                    }
                }
                $fullname = $dir_loc; # $File::Find::fullname
                $name = $dir_name; # $File::Find::name
-               if ($Is_MacOS) {
-                   if ($dir_rel eq ':') { # must be the top dir, where we started
-                       $name =~ s|:$||; # $File::Find::name
-                       $p_dir = "$p_dir:" unless ($p_dir =~ /:$/);
-                   }
-                   $dir = $p_dir; # $File::Find::dir
-                    $_ = ($no_chdir ? $name : $dir_rel); # $_
+               if ( substr($name,-2) eq '/.' ) {
+                   substr($name, length($name) == 2 ? -1 : -2) = ''; # $File::Find::name
                }
-               else {
-                   if ( substr($name,-2) eq '/.' ) {
-                       $name =~ s|/\.$||; # $File::Find::name
-                   }
-                   $dir = $p_dir; # $File::Find::dir
-                   $_ = ($no_chdir ? $dir_name : $dir_rel); # $_
-                   if ( substr($_,-2) eq '/.' ) {
-                       s|/\.$||;
-                   }
+               $dir = $p_dir; # $File::Find::dir
+               $_ = ($no_chdir ? $dir_name : $dir_rel); # $_
+               if ( substr($_,-2) eq '/.' ) {
+                   substr($_, length($_) == 2 ? -1 : -2) = '';
                }
 
                lstat($_); # make sure file tests with '_' work
-               { &$wanted_callback }; # protect against wild "next"
+               { $wanted_callback->() }; # protect against wild "next"
            }
            else {
                push @Stack,[$dir_loc, $updir_loc, $p_dir, $dir_rel,-1]  if  $bydepth;
@@ -1046,19 +1165,25 @@ sub _find_dir_symlnk($$$) {
 sub wrap_wanted {
     my $wanted = shift;
     if ( ref($wanted) eq 'HASH' ) {
+        unless( exists $wanted->{wanted} and ref( $wanted->{wanted} ) eq 'CODE' ) {
+            die 'no &wanted subroutine given';
+        }
        if ( $wanted->{follow} || $wanted->{follow_fast}) {
            $wanted->{follow_skip} = 1 unless defined $wanted->{follow_skip};
        }
        if ( $wanted->{untaint} ) {
-           $wanted->{untaint_pattern} = $File::Find::untaint_pattern  
+           $wanted->{untaint_pattern} = $File::Find::untaint_pattern
                unless defined $wanted->{untaint_pattern};
            $wanted->{untaint_skip} = 0 unless defined $wanted->{untaint_skip};
        }
        return $wanted;
     }
-    else {
+    elsif( ref( $wanted ) eq 'CODE' ) {
        return { wanted => $wanted };
     }
+    else {
+       die 'no &wanted subroutine given';
+    }
 }
 
 sub find {
@@ -1081,12 +1206,6 @@ if ($^O eq 'VMS') {
     $Is_VMS = 1;
     $File::Find::dont_use_nlink  = 1;
 }
-elsif ($^O eq 'MacOS') {
-    $Is_MacOS = 1;
-    $File::Find::dont_use_nlink  = 1;
-    $File::Find::skip_pattern    = qr/^Icon\015\z/;
-    $File::Find::untaint_pattern = qr|^(.+)$|;
-}
 
 # this _should_ work properly on all platforms
 # where File::Find can be expected to work
@@ -1094,7 +1213,8 @@ $File::Find::current_dir = File::Spec->curdir || '.';
 
 $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 'NetWare';
+       $^O eq 'interix' || $^O eq 'cygwin' || $^O eq 'epoc' || $^O eq 'qnx' ||
+          $^O eq 'nto';
 
 # 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
@@ -1105,8 +1225,8 @@ unless ($File::Find::dont_use_nlink) {
     $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 
+# 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 $@;