From: David Mitchell Date: Sat, 27 Mar 2010 18:07:30 +0000 (+0000) Subject: RT #73714: Regression in 5.12: File::Copy and initial spaces X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fff5c6e2d16a6c4070b5580acb55b3663ed90c08;p=p5sagit%2Fp5-mst-13.2.git RT #73714: Regression in 5.12: File::Copy and initial spaces Commit 81ec4fbc8320b72171c9fbea0fa0456b3a687f92 removed some obsolete code that processed with leading spaces in filenames (not needed with 3-arg open), but didn't quite clean out everything. This meant that trying to copy to a file whose name had a leading space would unceremoniously die with Undefined subroutine &File::Copy::_protect called --- diff --git a/lib/File/Copy.pm b/lib/File/Copy.pm index 4dc8c6d..c3823ac 100644 --- a/lib/File/Copy.pm +++ b/lib/File/Copy.pm @@ -22,7 +22,7 @@ sub syscopy; sub cp; sub mv; -$VERSION = '2.17'; +$VERSION = '2.18'; require Exporter; @ISA = qw(Exporter); @@ -242,8 +242,7 @@ sub copy { if ($to_a_handle) { $to_h = $to; } else { - $to = _protect($to) if $to =~ /^\s/s; - $to_h = \do { local *FH }; + $to_h = \do { local *FH }; # XXX is this line obsolete? open $to_h, ">", $to or goto fail_open2; binmode $to_h or die "($!,$^E)"; $closeto = 1; diff --git a/lib/File/Copy.t b/lib/File/Copy.t index 2644bce..cc1c3ff 100644 --- a/lib/File/Copy.t +++ b/lib/File/Copy.t @@ -14,7 +14,7 @@ use Test::More; my $TB = Test::More->builder; -plan tests => 461; +plan tests => 463; # We're going to override rename() later on but Perl has to see an override # at compile time to honor it. @@ -223,6 +223,17 @@ for my $cross_partition_test (0..1) { unlink "file-$$" or die $!; unlink "copy-$$" or die $!; + + # RT #73714 copy to file with leading whitespace failed + + open(F, ">file-$$") or die $!; + close F; + copy "file-$$", " copy-$$"; + warn "XXX\n"; + ok -e " copy-$$", "copy with leading whitespace"; + unlink "file-$$" or die "unlink: $!"; + unlink " copy-$$" or die "unlink: $!"; + }