Fix breakages that prevended -DPERL_POISON from compiling.
[p5sagit/p5-mst-13.2.git] / lib / File / Copy.pm
index 6316b97..57670e1 100644 (file)
@@ -37,6 +37,11 @@ sub croak {
     goto &Carp::croak;
 }
 
+sub carp {
+    require Carp;
+    goto &Carp::carp;
+}
+
 my $macfiles;
 if ($^O eq 'MacOS') {
        $macfiles = eval { require Mac::MoreFiles };
@@ -78,7 +83,10 @@ sub copy {
                         : (ref(\$to) eq 'GLOB'));
 
     if ($from eq $to) { # works for references, too
-       croak("'$from' and '$to' are identical (not copied)");
+       carp("'$from' and '$to' are identical (not copied)");
+        # The "copy" was a success as the source and destination contain
+        # the same data.
+        return 1;
     }
 
     if ((($Config{d_symlink} && $Config{d_readlink}) || $Config{d_link}) &&
@@ -87,7 +95,8 @@ sub copy {
        if (@fs) {
            my @ts = stat($to);
            if (@ts && $fs[0] == $ts[0] && $fs[1] == $ts[1]) {
-               croak("'$from' and '$to' are identical (not copied)");
+               carp("'$from' and '$to' are identical (not copied)");
+                return 0;
            }
        }
     }
@@ -182,7 +191,10 @@ sub copy {
 }
 
 sub move {
+    croak("Usage: move(FROM, TO) ") unless @_ == 2;
+
     my($from,$to) = @_;
+
     my($fromsz,$tosz1,$tomt1,$tosz2,$tomt2,$sts,$ossts);
 
     if (-d $to && ! -d $from) {
@@ -209,6 +221,7 @@ sub move {
     {
         local $@;
         eval {
+            local $SIG{__DIE__};
             copy($from,$to) or die;
             my($atime, $mtime) = (stat($from))[8,9];
             utime($atime, $mtime, $to);