From ba81b22e555c43970dc117186b222bee2b3dd1da Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 29 Jan 2025 21:22:21 +0200 Subject: [PATCH] Fix to revert `File::Copy` for compatibility with earlier versions of Perl --- vendor_perl/File/Copy.pm | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/vendor_perl/File/Copy.pm b/vendor_perl/File/Copy.pm index 1dc1d2d95..63609cc28 100644 --- a/vendor_perl/File/Copy.pm +++ b/vendor_perl/File/Copy.pm @@ -7,14 +7,15 @@ package File::Copy; -use 5.035007; +use 5.006; use strict; use warnings; no warnings 'newline'; -no warnings 'experimental::builtin'; -use builtin 'blessed'; -use overload; use File::Spec; use Config; +# During perl build, we need File::Copy but Scalar::Util might not be built yet +# And then we need these games to avoid loading overload, as that will +# confuse miniperl during the bootstrap of perl. +my $Scalar_Util_loaded = eval q{ require Scalar::Util; require overload; 1 }; # We want HiRes stat and utime if available BEGIN { eval q{ use Time::HiRes qw( stat utime ) } }; our(@ISA, @EXPORT, @EXPORT_OK, $VERSION, $Too_Big, $Syscopy_is_copy); @@ -23,7 +24,7 @@ sub syscopy; sub cp; sub mv; -$VERSION = '2.41'; +$VERSION = '2.34'; require Exporter; @ISA = qw(Exporter); @@ -45,8 +46,8 @@ sub carp { sub _catname { my($from, $to) = @_; if (not defined &basename) { - require File::Basename; - File::Basename->import( 'basename' ); + require File::Basename; + import File::Basename 'basename'; } return File::Spec->catfile($to, basename($from)); @@ -55,7 +56,8 @@ sub _catname { # _eq($from, $to) tells whether $from and $to are identical sub _eq { my ($from, $to) = map { - blessed($_) && overload::Method($_, q{""}) + $Scalar_Util_loaded && Scalar::Util::blessed($_) + && overload::Method($_, q{""}) ? "$_" : $_ } (@_); @@ -98,11 +100,11 @@ sub copy { } if ((($Config{d_symlink} && $Config{d_readlink}) || $Config{d_link}) && - !($^O eq 'os2')) { + !($^O eq 'MSWin32' || $^O eq 'os2')) { my @fs = stat($from); if (@fs) { my @ts = stat($to); - if (@ts && $fs[0] == $ts[0] && $fs[1] eq $ts[1] && !-p $from) { + if (@ts && $fs[0] == $ts[0] && $fs[1] == $ts[1] && !-p $from) { carp("'$from' and '$to' are identical (not copied)"); return 0; } @@ -117,6 +119,7 @@ sub copy { && !$to_a_handle && !($from_a_handle && $^O eq 'os2' ) # OS/2 cannot handle handles && !($from_a_handle && $^O eq 'MSWin32') + && !($from_a_handle && $^O eq 'NetWare') ) { if ($^O eq 'VMS' && -e $from @@ -339,14 +342,14 @@ File::Copy - Copy files or filehandles use File::Copy; - copy("sourcefile", "destinationfile") or die "Copy failed: $!"; - copy("Copy.pm", \*STDOUT); - move("/dev1/sourcefile", "/dev2/destinationfile"); + copy("sourcefile","destinationfile") or die "Copy failed: $!"; + copy("Copy.pm",\*STDOUT); + move("/dev1/sourcefile","/dev2/destinationfile"); use File::Copy "cp"; - my $n = FileHandle->new("/a/file", "r"); - cp($n, "x"); + $n = FileHandle->new("/a/file","r"); + cp($n,"x"); =head1 DESCRIPTION @@ -395,12 +398,9 @@ You may use the syntax C to get at the C alias for this function. The syntax is I the same. The behavior is nearly the same as well: as of version 2.15, C will preserve the source file's permission bits like the shell utility -C would do with default options, while C uses the default -permissions for the target file (which may depend on the process' -C, file ownership, inherited ACLs, etc.). That is, if the -destination file already exists, C will leave its permissions -unchanged; otherwise the permissions are taken from the source file -and modified by the C. If an error occurs in setting +C would do, while C uses the default permissions for the +target file (which may depend on the process' C, file +ownership, inherited ACLs, etc.). If an error occurs in setting permissions, C will return 0, regardless of whether the file was successfully copied.