summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram <perl-rt@wizbit.be>2008-05-13 00:13:33 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2008-05-23 06:18:59 +0000
commit68c65ec0adda9d2b3fc21f30f68be0ef10de5ad8 (patch)
tree38704ec666d69df031c83ad2dfecf77f6cbe4db5
parent93c512172a58c199c03358764753a650e33707e2 (diff)
downloadperl-68c65ec0adda9d2b3fc21f30f68be0ef10de5ad8.tar.gz
Re: [perl #41555] Bug in File::Find on Windows when target
Message-ID: <20080512221333.mq0283dlessws4wk@horde.wizbit.be> p4raw-id: //depot/perl@33911
-rw-r--r--lib/File/Find.pm4
-rw-r--r--lib/File/Find/t/find.t67
2 files changed, 67 insertions, 4 deletions
diff --git a/lib/File/Find.pm b/lib/File/Find.pm
index f316962d62..d39063b4e2 100644
--- a/lib/File/Find.pm
+++ b/lib/File/Find.pm
@@ -795,7 +795,7 @@ sub _find_dir($$$) {
if ($Is_MacOS) {
$dir_pref= ($p_dir =~ /:$/) ? $p_dir : "$p_dir:"; # preface
} elsif ($^O eq 'MSWin32') {
- $dir_pref = ($p_dir =~ m|\w:/$| ? $p_dir : "$p_dir/" );
+ $dir_pref = ($p_dir =~ m|\w:/?$| ? $p_dir : "$p_dir/" );
} elsif ($^O eq 'VMS') {
# VMS is returning trailing .dir on directories
@@ -987,7 +987,7 @@ sub _find_dir($$$) {
$dir_pref = "$dir_name:";
}
elsif ($^O eq 'MSWin32') {
- $dir_name = ($p_dir =~ m|\w:/$| ? "$p_dir$dir_rel" : "$p_dir/$dir_rel");
+ $dir_name = ($p_dir =~ m|\w:/?$| ? "$p_dir$dir_rel" : "$p_dir/$dir_rel");
$dir_pref = "$dir_name/";
}
elsif ($^O eq 'VMS') {
diff --git a/lib/File/Find/t/find.t b/lib/File/Find/t/find.t
index 60834bd977..6a71f98cb0 100644
--- a/lib/File/Find/t/find.t
+++ b/lib/File/Find/t/find.t
@@ -18,8 +18,14 @@ BEGIN {
$SIG{'__WARN__'} = sub { $warn_msg = $_[0]; warn "# $_[0]"; }
}
-if ( $symlink_exists ) { print "1..199\n"; }
-else { print "1..85\n"; }
+my $test_count = 85;
+$test_count += 114 if $symlink_exists;
+$test_count += 18 if $^O eq 'MSWin32';
+$test_count += 2 if $^O eq 'MSWin32' and $symlink_exists;
+
+print "1..$test_count\n";
+#if ( $symlink_exists ) { print "1..199\n"; }
+#else { print "1..85\n"; }
my $orig_dir = cwd();
@@ -830,3 +836,60 @@ if ( $symlink_exists ) {
unlink file_path('fa', 'faa_sl');
}
+
+
+# Win32 checks - [perl #41555]
+if ($^O eq 'MSWin32') {
+ require File::Spec::Win32;
+ my ($volume) = File::Spec::Win32->splitpath($orig_dir, 1);
+ print STDERR "VOLUME = $volume\n";
+
+ # with chdir
+ %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('faba_ord') => 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);
+
+
+
+ File::Find::find( {wanted => \&wanted_File_Dir}, topdir('fa'));
+ Check( scalar(keys %Expect_File) == 0 );
+
+ # no_chdir
+ %Expect_File = ($volume . file_path_name('fa') => 1,
+ $volume . file_path_name('fa', 'fsl') => 1,
+ $volume . file_path_name('fa', 'fa_ord') => 1,
+ $volume . file_path_name('fa', 'fab') => 1,
+ $volume . file_path_name('fa', 'fab', 'fab_ord') => 1,
+ $volume . file_path_name('fa', 'fab', 'faba') => 1,
+ $volume . file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
+ $volume . file_path_name('fa', 'faa') => 1,
+ $volume . file_path_name('fa', 'faa', 'faa_ord') => 1);
+
+
+ delete $Expect_File{ $volume . file_path_name('fa', 'fsl') } unless $symlink_exists;
+ %Expect_Name = ();
+
+ %Expect_Dir = ($volume . dir_path('fa') => 1,
+ $volume . dir_path('fa', 'faa') => 1,
+ $volume . dir_path('fa', 'fab') => 1,
+ $volume . dir_path('fa', 'fab', 'faba') => 1);
+
+ File::Find::find( {wanted => \&wanted_File_Dir, no_chdir => 1}, $volume . topdir('fa'));
+ Check( scalar(keys %Expect_File) == 0 );
+}