Manual integration error in #12235.
[p5sagit/p5-mst-13.2.git] / lib / File / Basename.pm
index 4581e7e..c765788 100644 (file)
@@ -135,12 +135,13 @@ BEGIN {
 
 
 
-use 5.005_64;
+use 5.006;
+use warnings;
 our(@ISA, @EXPORT, $VERSION, $Fileparse_fstype, $Fileparse_igncase);
 require Exporter;
 @ISA = qw(Exporter);
 @EXPORT = qw(fileparse fileparse_set_fstype basename dirname);
-$VERSION = "2.6";
+$VERSION = "2.71";
 
 
 #   fileparse_set_fstype() - specify OS-based rules used in future
@@ -176,12 +177,13 @@ sub fileparse {
       $dirpath ||= '';  # should always be defined
     }
   }
-  if ($fstype =~ /^MS(DOS|Win32)/i) {
+  if ($fstype =~ /^MS(DOS|Win32)|epoc/i) {
     ($dirpath,$basename) = ($fullname =~ /^((?:.*[:\\\/])?)(.*)/s);
     $dirpath .= '.\\' unless $dirpath =~ /[\\\/]\z/;
   }
   elsif ($fstype =~ /^MacOS/si) {
     ($dirpath,$basename) = ($fullname =~ /^(.*:)?(.*)/s);
+    $dirpath = ':' unless $dirpath;
   }
   elsif ($fstype =~ /^AmigaOS/i) {
     ($dirpath,$basename) = ($fullname =~ /(.*[:\/])?(.*)/s);
@@ -189,9 +191,13 @@ sub fileparse {
   }
   elsif ($fstype !~ /^VMS/i) {  # default to Unix
     ($dirpath,$basename) = ($fullname =~ m#^(.*/)?(.*)#s);
-    if ($^O eq 'VMS' and $fullname =~ m:/[^/]+/000000/?:) {
+    if ($^O eq 'VMS' and $fullname =~ m:^(/[^/]+/000000(/|$))(.*):) {
       # dev:[000000] is top of VMS tree, similar to Unix '/'
-      ($basename,$dirpath) = ('',$fullname);
+      # so strip it off and treat the rest as "normal"
+      my $devspec  = $1;
+      my $remainder = $3;
+      ($dirpath,$basename) = ($remainder =~ m#^(.*/)?(.*)#s);
+      $dirpath = $devspec.$dirpath;
     }
     $dirpath = './' unless $dirpath;
   }
@@ -208,8 +214,8 @@ sub fileparse {
   }
 
   $tail .= $taint if defined $tail; # avoid warning if $tail == undef
-  wantarray ? ($basename . $taint, $dirpath . $taint, $tail)
-            : $basename . $taint;
+  wantarray ? ($basename .= $taint, $dirpath .= $taint, $tail)
+            : $basename .= $taint;
 }
 
 
@@ -236,7 +242,13 @@ sub dirname {
         if ($_[0] =~ m#/#) { $fstype = '' }
         else { return $dirname || $ENV{DEFAULT} }
     }
-    if ($fstype =~ /MacOS/i) { return $dirname }
+    if ($fstype =~ /MacOS/i) {
+       if( !length($basename) && $dirname !~ /^[^:]+:\z/) {
+           $dirname =~ s/([^:]):\z/$1/s;
+           ($basename,$dirname) = fileparse $dirname;
+       }
+       $dirname .= ":" unless $dirname =~ /:\z/;
+    }
     elsif ($fstype =~ /MSDOS/i) { 
         $dirname =~ s/([^:])[\\\/]*\z/$1/;
         unless( length($basename) ) {
@@ -256,7 +268,7 @@ sub dirname {
         chop $dirname;
         $dirname =~ s#[^:/]+\z## unless length($basename);
     }
-    else { 
+    else {
         $dirname =~ s:(.)/*\z:$1:s;
         unless( length($basename) ) {
            local($File::Basename::Fileparse_fstype) = $fstype;