summaryrefslogtreecommitdiffstats
path: root/contrib/perl5/lib/File
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2002-03-16 20:14:30 +0000
committermarkm <markm@FreeBSD.org>2002-03-16 20:14:30 +0000
commit3eac21f49bc763a6c0044b4afbc0c7ece760144f (patch)
tree4cf1274fa3ca68f7ecf6a3051e0c2243e378afc5 /contrib/perl5/lib/File
parent259bd53c06712c4ffb0ab7e06898c19ebf221b21 (diff)
downloadFreeBSD-src-3eac21f49bc763a6c0044b4afbc0c7ece760144f.zip
FreeBSD-src-3eac21f49bc763a6c0044b4afbc0c7ece760144f.tar.gz
Vendor import Perl 5.6.1
Diffstat (limited to 'contrib/perl5/lib/File')
-rw-r--r--contrib/perl5/lib/File/Basename.pm20
-rw-r--r--contrib/perl5/lib/File/Copy.pm33
-rw-r--r--contrib/perl5/lib/File/Find.pm98
-rw-r--r--contrib/perl5/lib/File/Path.pm39
-rw-r--r--contrib/perl5/lib/File/Spec.pm5
-rw-r--r--contrib/perl5/lib/File/Spec/Functions.pm4
-rw-r--r--contrib/perl5/lib/File/Spec/Mac.pm61
-rw-r--r--contrib/perl5/lib/File/Spec/OS2.pm5
-rw-r--r--contrib/perl5/lib/File/Spec/Unix.pm46
-rw-r--r--contrib/perl5/lib/File/Spec/VMS.pm69
-rw-r--r--contrib/perl5/lib/File/Spec/Win32.pm86
11 files changed, 267 insertions, 199 deletions
diff --git a/contrib/perl5/lib/File/Basename.pm b/contrib/perl5/lib/File/Basename.pm
index 4581e7e..94aac2d 100644
--- a/contrib/perl5/lib/File/Basename.pm
+++ b/contrib/perl5/lib/File/Basename.pm
@@ -176,7 +176,7 @@ 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/;
}
@@ -189,9 +189,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;
}
@@ -236,7 +240,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 +266,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;
diff --git a/contrib/perl5/lib/File/Copy.pm b/contrib/perl5/lib/File/Copy.pm
index e6cf786..24d1ffd 100644
--- a/contrib/perl5/lib/File/Copy.pm
+++ b/contrib/perl5/lib/File/Copy.pm
@@ -37,7 +37,7 @@ sub _catname { # Will be replaced by File::Spec when it arrives
import File::Basename 'basename';
}
if ($^O eq 'VMS') { $to = VMS::Filespec::vmspath($to) . basename($from); }
- elsif ($^O eq 'MacOS') { $to .= ':' . basename($from); }
+ elsif ($^O eq 'MacOS') { $to =~ s/^([^:]+)$/:$1/; $to .= ':' . basename($from); }
elsif ($to =~ m|\\|) { $to .= '\\' . basename($from); }
else { $to .= '/' . basename($from); }
}
@@ -69,6 +69,7 @@ sub copy {
&& !($from_a_handle && $^O eq 'os2' ) # OS/2 cannot handle handles
&& !($from_a_handle && $^O eq 'mpeix') # and neither can MPE/iX.
&& !($from_a_handle && $^O eq 'MSWin32')
+ && !($from_a_handle && $^O eq 'MacOS')
)
{
return syscopy($from, $to);
@@ -83,7 +84,7 @@ sub copy {
if ($from_a_handle) {
*FROM = *$from{FILEHANDLE};
} else {
- $from = "./$from" if $from =~ /^\s/s;
+ $from = _protect($from) if $from =~ /^\s/s;
open(FROM, "< $from\0") or goto fail_open1;
binmode FROM or die "($!,$^E)";
$closefrom = 1;
@@ -92,7 +93,7 @@ sub copy {
if ($to_a_handle) {
*TO = *$to{FILEHANDLE};
} else {
- $to = "./$to" if $to =~ /^\s/s;
+ $to = _protect($to) if $to =~ /^\s/s;
open(TO,"> $to\0") or goto fail_open2;
binmode TO or die "($!,$^E)";
$closeto = 1;
@@ -180,6 +181,13 @@ sub move {
*cp = \&copy;
*mv = \&move;
+
+if ($^O eq 'MacOS') {
+ *_protect = sub { MacPerl::MakeFSSpec($_[0]) };
+} else {
+ *_protect = sub { "./$_[0]" };
+}
+
# &syscopy is an XSUB under OS/2
unless (defined &syscopy) {
if ($^O eq 'VMS') {
@@ -196,6 +204,23 @@ unless (defined &syscopy) {
return 0 unless @_ == 2;
return Win32::CopyFile(@_, 1);
};
+ } elsif ($^O eq 'MacOS') {
+ require Mac::MoreFiles;
+ *syscopy = sub {
+ my($from, $to) = @_;
+ my($dir, $toname);
+
+ return 0 unless -e $from;
+
+ if ($to =~ /(.*:)([^:]+):?$/) {
+ ($dir, $toname) = ($1, $2);
+ } else {
+ ($dir, $toname) = (":", $to);
+ }
+
+ unlink($to);
+ Mac::MoreFiles::FSpFileCopy($from, $dir, $toname, 1);
+ };
} else {
$Syscopy_is_copy = 1;
*syscopy = \&copy;
@@ -221,7 +246,7 @@ File::Copy - Copy files or filehandles
use POSIX;
use File::Copy cp;
- $n=FileHandle->new("/dev/null","r");
+ $n = FileHandle->new("/a/file","r");
cp($n,"x");'
=head1 DESCRIPTION
diff --git a/contrib/perl5/lib/File/Find.pm b/contrib/perl5/lib/File/Find.pm
index ac73f1b..3a621c0 100644
--- a/contrib/perl5/lib/File/Find.pm
+++ b/contrib/perl5/lib/File/Find.pm
@@ -42,6 +42,22 @@ Reports the name of a directory only AFTER all its entries
have been reported. Entry point finddepth() is a shortcut for
specifying C<{ bydepth => 1 }> in the first argument of find().
+=item C<preprocess>
+
+The value should be a code reference. This code reference is used to
+preprocess a directory; it is called after readdir() but before the loop that
+calls the wanted() function. It is called with a list of strings and is
+expected to return a list of strings. The code can be used to sort the
+strings alphabetically, numerically, or to filter out directory entries based
+on their name alone.
+
+=item C<postprocess>
+
+The value should be a code reference. It is invoked just before leaving the
+current directory. It is called in void context with no arguments. The name
+of the current directory is in $File::Find::dir. This hook is handy for
+summarizing a directory, such as calculating its disk usage.
+
=item C<follow>
Causes symbolic links to be followed. Since directory trees with symbolic
@@ -55,7 +71,7 @@ If either I<follow> or I<follow_fast> is in effect:
=item *
-It is guarantueed that an I<lstat> has been called before the user's
+It is guaranteed that an I<lstat> has been called before the user's
I<wanted()> function is called. This enables fast file checks involving S< _>.
=item *
@@ -67,11 +83,10 @@ pathname of the file with all symbolic links resolved
=item C<follow_fast>
-This is similar to I<follow> except that it may report some files
-more than once. It does detect cycles however.
-Since only symbolic links have to be hashed, this is
-much cheaper both in space and time.
-If processing a file more than once (by the user's I<wanted()> function)
+This is similar to I<follow> except that it may report some files more
+than once. It does detect cycles, however. Since only symbolic links
+have to be hashed, this is much cheaper both in space and time. If
+processing a file more than once (by the user's I<wanted()> function)
is worse than just taking time, the option I<follow> should be used.
=item C<follow_skip>
@@ -97,14 +112,14 @@ C<$_> will be the same as C<$File::Find::name>.
If find is used in taint-mode (-T command line switch or if EUID != UID
or if EGID != GID) then internally directory names have to be untainted
before they can be cd'ed to. Therefore they are checked against a regular
-expression I<untaint_pattern>. Note, that all names passed to the
+expression I<untaint_pattern>. Note that all names passed to the
user's I<wanted()> function are still tainted.
=item C<untaint_pattern>
See above. This should be set using the C<qr> quoting operator.
The default is set to C<qr|^([-+@\w./]+)$|>.
-Note that the paranthesis which are vital.
+Note that the parantheses are vital.
=item C<untaint_skip>
@@ -116,15 +131,15 @@ are skipped. The default is to 'die' in such a case.
The wanted() function does whatever verifications you want.
C<$File::Find::dir> contains the current directory name, and C<$_> the
current filename within that directory. C<$File::Find::name> contains
-the complete pathname to the file. You are chdir()'d to C<$File::Find::dir> when
-the function is called, unless C<no_chdir> was specified.
-When <follow> or <follow_fast> are in effect there is also a
-C<$File::Find::fullname>.
-The function may set C<$File::Find::prune> to prune the tree
-unless C<bydepth> was specified.
-Unless C<follow> or C<follow_fast> is specified, for compatibility
-reasons (find.pl, find2perl) there are in addition the following globals
-available: C<$File::Find::topdir>, C<$File::Find::topdev>, C<$File::Find::topino>,
+the complete pathname to the file. You are chdir()'d to
+C<$File::Find::dir> when the function is called, unless C<no_chdir>
+was specified. When <follow> or <follow_fast> are in effect, there is
+also a C<$File::Find::fullname>. The function may set
+C<$File::Find::prune> to prune the tree unless C<bydepth> was
+specified. Unless C<follow> or C<follow_fast> is specified, for
+compatibility reasons (find.pl, find2perl) there are in addition the
+following globals available: C<$File::Find::topdir>,
+C<$File::Find::topdev>, C<$File::Find::topino>,
C<$File::Find::topmode> and C<$File::Find::topnlink>.
This library is useful for the C<find2perl> tool, which when fed,
@@ -161,7 +176,7 @@ module.
=head1 CAVEAT
-Be aware that the option to follow symblic links can be dangerous.
+Be aware that the option to follow symbolic links can be dangerous.
Depending on the structure of the directory tree (including symbolic
links to directories) you might traverse a given (physical) directory
more than once (only if C<follow_fast> is in effect).
@@ -183,7 +198,8 @@ require File::Basename;
my %SLnkSeen;
my ($wanted_callback, $avoid_nlink, $bydepth, $no_chdir, $follow,
- $follow_skip, $full_check, $untaint, $untaint_skip, $untaint_pat);
+ $follow_skip, $full_check, $untaint, $untaint_skip, $untaint_pat,
+ $pre_process, $post_process);
sub contract_name {
my ($cdir,$fn) = @_;
@@ -282,6 +298,8 @@ sub _find_opt {
my $cwd_untainted = $cwd;
$wanted_callback = $wanted->{wanted};
$bydepth = $wanted->{bydepth};
+ $pre_process = $wanted->{preprocess};
+ $post_process = $wanted->{postprocess};
$no_chdir = $wanted->{no_chdir};
$full_check = $wanted->{follow};
$follow = $full_check || $wanted->{follow_fast};
@@ -373,7 +391,7 @@ sub _find_opt {
$name = $abs_dir . $_;
- &$wanted_callback;
+ { &$wanted_callback }; # protect against wild "next"
}
@@ -429,7 +447,7 @@ sub _find_dir($$$) {
$_= ($no_chdir ? $dir_name : $dir_rel );
# prune may happen here
$prune= 0;
- &$wanted_callback;
+ { &$wanted_callback }; # protect against wild "next"
next if $prune;
}
@@ -464,6 +482,8 @@ sub _find_dir($$$) {
}
@filenames = readdir DIR;
closedir(DIR);
+ @filenames = &$pre_process(@filenames) if $pre_process;
+ push @Stack,[$CdLvl,$dir_name,"",-2] if $post_process;
if ($nlink == 2 && !$avoid_nlink) {
# This dir has no subdirectories.
@@ -472,7 +492,7 @@ sub _find_dir($$$) {
$name = $dir_pref . $FN;
$_ = ($no_chdir ? $name : $FN);
- &$wanted_callback;
+ { &$wanted_callback }; # protect against wild "next"
}
}
@@ -496,13 +516,13 @@ sub _find_dir($$$) {
else {
$name = $dir_pref . $FN;
$_= ($no_chdir ? $name : $FN);
- &$wanted_callback;
+ { &$wanted_callback }; # protect against wild "next"
}
}
else {
$name = $dir_pref . $FN;
$_= ($no_chdir ? $name : $FN);
- &$wanted_callback;
+ { &$wanted_callback }; # protect against wild "next"
}
}
}
@@ -518,7 +538,11 @@ sub _find_dir($$$) {
}
$dir_name = ($p_dir eq '/' ? "/$dir_rel" : "$p_dir/$dir_rel");
$dir_pref = "$dir_name/";
- if ( $nlink < 0 ) { # must be finddepth, report dirname now
+ if ( $nlink == -2 ) {
+ $name = $dir = $p_dir;
+ $_ = ".";
+ &$post_process; # End-of-directory processing
+ } elsif ( $nlink < 0 ) { # must be finddepth, report dirname now
$name = $dir_name;
if ( substr($name,-2) eq '/.' ) {
$name =~ s|/\.$||;
@@ -528,7 +552,7 @@ sub _find_dir($$$) {
if ( substr($_,-2) eq '/.' ) {
s|/\.$||;
}
- &$wanted_callback;
+ { &$wanted_callback }; # protect against wild "next"
} else {
push @Stack,[$CdLvl,$p_dir,$dir_rel,-1] if $bydepth;
last;
@@ -584,13 +608,25 @@ sub _find_dir_symlnk($$$) {
while (defined $SE) {
unless ($bydepth) {
+ # change to parent directory
+ unless ($no_chdir) {
+ my $udir = $pdir_loc;
+ if ($untaint) {
+ $udir = $1 if $pdir_loc =~ m|$untaint_pat|;
+ }
+ unless (chdir $udir) {
+ warn "Can't cd to $udir: $!\n";
+ next;
+ }
+ }
$dir= $p_dir;
$name= $dir_name;
$_= ($no_chdir ? $dir_name : $dir_rel );
$fullname= $dir_loc;
# prune may happen here
$prune= 0;
- &$wanted_callback;
+ lstat($_); # make sure file tests with '_' work
+ { &$wanted_callback }; # protect against wild "next"
next if $prune;
}
@@ -640,7 +676,7 @@ sub _find_dir_symlnk($$$) {
$fullname = $new_loc;
$name = $dir_pref . $FN;
$_ = ($no_chdir ? $name : $FN);
- &$wanted_callback;
+ { &$wanted_callback }; # protect against wild "next"
}
}
@@ -673,7 +709,8 @@ sub _find_dir_symlnk($$$) {
s|/\.$||;
}
- &$wanted_callback;
+ lstat($_); # make sure file tests with '_' work
+ { &$wanted_callback }; # protect against wild "next"
} else {
push @Stack,[$dir_loc, $pdir_loc, $p_dir, $dir_rel,-1] if $bydepth;
last;
@@ -721,7 +758,8 @@ if ($^O eq 'VMS') {
}
$File::Find::dont_use_nlink = 1
- if $^O eq 'os2' || $^O eq 'dos' || $^O eq 'amigaos' || $^O eq 'MSWin32';
+ if $^O eq 'os2' || $^O eq 'dos' || $^O eq 'amigaos' || $^O eq 'MSWin32' ||
+ $^O eq 'cygwin' || $^O eq 'epoc';
# Set dont_use_nlink in your hint file if your system's stat doesn't
# report the number of links in a directory as an indication
diff --git a/contrib/perl5/lib/File/Path.pm b/contrib/perl5/lib/File/Path.pm
index 46f360a..0eb6128 100644
--- a/contrib/perl5/lib/File/Path.pm
+++ b/contrib/perl5/lib/File/Path.pm
@@ -97,38 +97,42 @@ use File::Basename ();
use Exporter ();
use strict;
-our $VERSION = "1.0403";
+our $VERSION = "1.0404";
our @ISA = qw( Exporter );
our @EXPORT = qw( mkpath rmtree );
my $Is_VMS = $^O eq 'VMS';
+my $Is_MacOS = $^O eq 'MacOS';
# These OSes complain if you want to remove a file that you have no
# write permission to:
-my $force_writeable = ($^O eq 'os2' || $^O eq 'dos' || $^O eq 'MSWin32'
- || $^O eq 'amigaos');
+my $force_writeable = ($^O eq 'os2' || $^O eq 'dos' || $^O eq 'MSWin32' ||
+ $^O eq 'amigaos' || $^O eq 'MacOS' || $^O eq 'epoc');
sub mkpath {
my($paths, $verbose, $mode) = @_;
# $paths -- either a path string or ref to list of paths
# $verbose -- optional print "mkdir $path" for each directory created
# $mode -- optional permissions, defaults to 0777
- local($")="/";
+ local($")=$Is_MacOS ? ":" : "/";
$mode = 0777 unless defined($mode);
$paths = [$paths] unless ref $paths;
my(@created,$path);
foreach $path (@$paths) {
$path .= '/' if $^O eq 'os2' and $path =~ /^\w:\z/s; # feature of CRT
- next if -d $path;
# Logic wants Unix paths, so go with the flow.
- $path = VMS::Filespec::unixify($path) if $Is_VMS;
- my $parent = File::Basename::dirname($path);
- # Allow for creation of new logical filesystems under VMS
- if (not $Is_VMS or $parent !~ m:/[^/]+/000000/?:) {
- unless (-d $parent or $path eq $parent) {
- push(@created,mkpath($parent, $verbose, $mode));
+ if ($Is_VMS) {
+ next if $path eq '/';
+ $path = VMS::Filespec::unixify($path);
+ if ($path =~ m:^(/[^/]+)/?\z:) {
+ $path = $1.'/000000';
}
}
+ next if -d $path;
+ my $parent = File::Basename::dirname($path);
+ unless (-d $parent or $path eq $parent) {
+ push(@created,mkpath($parent, $verbose, $mode));
+ }
print "mkdir $path\n" if $verbose;
unless (mkdir($path,$mode)) {
my $e = $!;
@@ -157,7 +161,12 @@ sub rmtree {
my($root);
foreach $root (@{$roots}) {
- $root =~ s#/\z##;
+ if ($Is_MacOS) {
+ $root = ":$root" if $root !~ /:/;
+ $root =~ s#([^:])\z#$1:#;
+ } else {
+ $root =~ s#/\z##;
+ }
(undef, undef, my $rp) = lstat $root or next;
$rp &= 07777; # don't forget setuid, setgid, sticky bits
if ( -d _ ) {
@@ -182,7 +191,11 @@ sub rmtree {
# is faster if done in reverse ASCIIbetical order
@files = reverse @files if $Is_VMS;
($root = VMS::Filespec::unixify($root)) =~ s#\.dir\z## if $Is_VMS;
- @files = map("$root/$_", grep $_!~/^\.{1,2}\z/s,@files);
+ if ($Is_MacOS) {
+ @files = map("$root$_", @files);
+ } else {
+ @files = map("$root/$_", grep $_!~/^\.{1,2}\z/s,@files);
+ }
$count += rmtree(\@files,$verbose,$safe);
if ($safe &&
($Is_VMS ? !&VMS::Filespec::candelete($root) : !-w $root)) {
diff --git a/contrib/perl5/lib/File/Spec.pm b/contrib/perl5/lib/File/Spec.pm
index 40f5345..3f79d74 100644
--- a/contrib/perl5/lib/File/Spec.pm
+++ b/contrib/perl5/lib/File/Spec.pm
@@ -3,12 +3,13 @@ package File::Spec;
use strict;
use vars qw(@ISA $VERSION);
-$VERSION = '0.8';
+$VERSION = 0.82 ;
my %module = (MacOS => 'Mac',
MSWin32 => 'Win32',
os2 => 'OS2',
- VMS => 'VMS');
+ VMS => 'VMS',
+ epoc => 'Epoc');
my $module = $module{$^O} || 'Unix';
require "File/Spec/$module.pm";
diff --git a/contrib/perl5/lib/File/Spec/Functions.pm b/contrib/perl5/lib/File/Spec/Functions.pm
index 140738f..0036ac1 100644
--- a/contrib/perl5/lib/File/Spec/Functions.pm
+++ b/contrib/perl5/lib/File/Spec/Functions.pm
@@ -3,7 +3,9 @@ package File::Spec::Functions;
use File::Spec;
use strict;
-use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
+
+$VERSION = '1.1';
require Exporter;
diff --git a/contrib/perl5/lib/File/Spec/Mac.pm b/contrib/perl5/lib/File/Spec/Mac.pm
index 959e33d..9ef55ec 100644
--- a/contrib/perl5/lib/File/Spec/Mac.pm
+++ b/contrib/perl5/lib/File/Spec/Mac.pm
@@ -1,8 +1,11 @@
package File::Spec::Mac;
use strict;
-use vars qw(@ISA);
+use vars qw(@ISA $VERSION);
require File::Spec::Unix;
+
+$VERSION = '1.2';
+
@ISA = qw(File::Spec::Unix);
=head1 NAME
@@ -79,9 +82,9 @@ sub catdir {
shift;
my @args = @_;
my $result = shift @args;
- $result =~ s/:\z//;
+ $result =~ s/:\Z(?!\n)//;
foreach (@args) {
- s/:\z//;
+ s/:\Z(?!\n)//;
s/^://s;
$result .= ":$_";
}
@@ -150,7 +153,7 @@ sub rootdir {
require Mac::Files;
my $system = Mac::Files::FindFolder(&Mac::Files::kOnSystemDisk,
&Mac::Files::kSystemFolderType);
- $system =~ s/:.*\z/:/s;
+ $system =~ s/:.*\Z(?!\n)/:/s;
return $system;
}
@@ -189,12 +192,16 @@ folder named "HD" in the current working directory on a drive named "HD"),
relative wins. Use ":" in the appropriate place in the path if you want to
distinguish unambiguously.
+As a special case, the file name '' is always considered to be absolute.
+
=cut
sub file_name_is_absolute {
my ($self,$file) = @_;
if ($file =~ /:/) {
return ($file !~ m/^:/s);
+ } elsif ( $file eq '' ) {
+ return 1 ;
} else {
return (! -e ":$file");
}
@@ -228,7 +235,7 @@ sub splitpath {
my ($volume,$directory,$file) = ('','','');
if ( $nofile ) {
- ( $volume, $directory ) = $path =~ m@((?:[^:]+(?::|\z))?)(.*)@s;
+ ( $volume, $directory ) = $path =~ m@((?:[^:]+(?::|\Z(?!\n)))?)(.*)@s;
}
else {
$path =~
@@ -242,8 +249,8 @@ sub splitpath {
}
# Make sure non-empty volumes and directories end in ':'
- $volume .= ':' if $volume =~ m@[^:]\z@ ;
- $directory .= ':' if $directory =~ m@[^:]\z@ ;
+ $volume .= ':' if $volume =~ m@[^:]\Z(?!\n)@ ;
+ $directory .= ':' if $directory =~ m@[^:]\Z(?!\n)@ ;
return ($volume,$directory,$file);
}
@@ -259,7 +266,7 @@ sub splitdir {
# check to be sure that there will not be any before handling the
# simple case.
#
- if ( $directories !~ m@:\z@ ) {
+ if ( $directories !~ m@:\Z(?!\n)@ ) {
return split( m@:@, $directories );
}
else {
@@ -286,11 +293,11 @@ sub catpath {
my $segment ;
for $segment ( @_ ) {
- if ( $result =~ m@[^/]\z@ && $segment =~ m@^[^/]@s ) {
+ if ( $result =~ m@[^/]\Z(?!\n)@ && $segment =~ m@^[^/]@s ) {
$result .= "/$segment" ;
}
- elsif ( $result =~ m@/\z@ && $segment =~ m@^/@s ) {
- $result =~ s@/+\z@/@;
+ elsif ( $result =~ m@/\Z(?!\n)@ && $segment =~ m@^/@s ) {
+ $result =~ s@/+\Z(?!\n)@/@;
$segment =~ s@^/+@@s;
$result .= "$segment" ;
}
@@ -304,6 +311,12 @@ sub catpath {
=item abs2rel
+See L<File::Spec::Unix/abs2rel> for general documentation.
+
+Unlike C<File::Spec::Unix->abs2rel()>, this function will make
+checks against the local filesystem if necessary. See
+L</file_name_is_absolute> for details.
+
=cut
sub abs2rel {
@@ -341,31 +354,15 @@ sub abs2rel {
=item rel2abs
-Converts a relative path to an absolute path.
-
- $abs_path = File::Spec->rel2abs( $destination ) ;
- $abs_path = File::Spec->rel2abs( $destination, $base ) ;
-
-If $base is not present or '', then L<cwd()> is used. If $base is relative,
-then it is converted to absolute form using L</rel2abs()>. This means that it
-is taken to be relative to L<cwd()>.
-
-On systems with the concept of a volume, this assumes that both paths
-are on the $base volume, and ignores the $destination volume.
-
-On systems that have a grammar that indicates filenames, this ignores the
-$base filename as well. Otherwise all path components are assumed to be
-directories.
-
-If $path is absolute, it is cleaned up and returned using L</canonpath()>.
-
-Based on code written by Shigio Yamaguchi.
+See L<File::Spec::Unix/rel2abs> for general documentation.
-No checks against the filesystem are made.
+Unlike C<File::Spec::Unix->rel2abs()>, this function will make
+checks against the local filesystem if necessary. See
+L</file_name_is_absolute> for details.
=cut
-sub rel2abs($;$;) {
+sub rel2abs {
my ($self,$path,$base ) = @_;
if ( ! $self->file_name_is_absolute( $path ) ) {
diff --git a/contrib/perl5/lib/File/Spec/OS2.pm b/contrib/perl5/lib/File/Spec/OS2.pm
index 33370f0..20bf8c9 100644
--- a/contrib/perl5/lib/File/Spec/OS2.pm
+++ b/contrib/perl5/lib/File/Spec/OS2.pm
@@ -1,8 +1,11 @@
package File::Spec::OS2;
use strict;
-use vars qw(@ISA);
+use vars qw(@ISA $VERSION);
require File::Spec::Unix;
+
+$VERSION = '1.1';
+
@ISA = qw(File::Spec::Unix);
sub devnull {
diff --git a/contrib/perl5/lib/File/Spec/Unix.pm b/contrib/perl5/lib/File/Spec/Unix.pm
index 2305b75..a81c533 100644
--- a/contrib/perl5/lib/File/Spec/Unix.pm
+++ b/contrib/perl5/lib/File/Spec/Unix.pm
@@ -1,6 +1,9 @@
package File::Spec::Unix;
use strict;
+use vars qw($VERSION);
+
+$VERSION = '1.2';
use Cwd;
@@ -35,7 +38,7 @@ sub canonpath {
$path =~ s|(/\.)+/|/|g; # xx/././xx -> xx/xx
$path =~ s|^(\./)+||s unless $path eq "./"; # ./xx -> xx
$path =~ s|^/(\.\./)+|/|s; # /../../xx -> xx
- $path =~ s|/\z|| unless $path eq "/"; # xx/ -> xx
+ $path =~ s|/\Z(?!\n)|| unless $path eq "/"; # xx/ -> xx
return $path;
}
@@ -146,7 +149,7 @@ directory. (Does not strip symlinks, only '.', '..', and equivalents.)
sub no_upwards {
my $self = shift;
- return grep(!/^\.{1,2}\z/s, @_);
+ return grep(!/^\.{1,2}\Z(?!\n)/s, @_);
}
=item case_tolerant
@@ -162,7 +165,12 @@ sub case_tolerant {
=item file_name_is_absolute
-Takes as argument a path and returns true, if it is an absolute path.
+Takes as argument a path and returns true if it is an absolute path.
+
+This does not consult the local filesystem on Unix, Win32, or OS/2. It
+does sometimes on MacOS (see L<File::Spec::MacOS/file_name_is_absolute>).
+It does consult the working environment for VMS (see
+L<File::Spec::VMS/file_name_is_absolute>).
=cut
@@ -223,7 +231,7 @@ sub splitpath {
$directory = $path;
}
else {
- $path =~ m|^ ( (?: .* / (?: \.\.?\z )? )? ) ([^/]*) |xs;
+ $path =~ m|^ ( (?: .* / (?: \.\.?\Z(?!\n) )? )? ) ([^/]*) |xs;
$directory = $1;
$file = $2;
}
@@ -263,7 +271,7 @@ sub splitdir {
# check to be sure that there will not be any before handling the
# simple case.
#
- if ( $directories !~ m|/\z| ) {
+ if ( $directories !~ m|/\Z(?!\n)| ) {
return split( m|/|, $directories );
}
else {
@@ -308,8 +316,8 @@ sub catpath {
Takes a destination path and an optional base path returns a relative path
from the base path to the destination path:
- $rel_path = File::Spec->abs2rel( $destination ) ;
- $rel_path = File::Spec->abs2rel( $destination, $base ) ;
+ $rel_path = File::Spec->abs2rel( $path ) ;
+ $rel_path = File::Spec->abs2rel( $path, $base ) ;
If $base is not present or '', then L<cwd()> is used. If $base is relative,
then it is converted to absolute form using L</rel2abs()>. This means that it
@@ -325,9 +333,13 @@ directories.
If $path is relative, it is converted to absolute form using L</rel2abs()>.
This means that it is taken to be relative to L<cwd()>.
-Based on code written by Shigio Yamaguchi.
+No checks against the filesystem are made on most systems. On MacOS,
+the filesystem may be consulted (see
+L<File::Spec::MacOS/file_name_is_absolute>). On VMS, there is
+interaction with the working environment, as logicals and
+macros are expanded.
-No checks against the filesystem are made.
+Based on code written by Shigio Yamaguchi.
=cut
@@ -385,15 +397,15 @@ sub abs2rel {
Converts a relative path to an absolute path.
- $abs_path = File::Spec->rel2abs( $destination ) ;
- $abs_path = File::Spec->rel2abs( $destination, $base ) ;
+ $abs_path = File::Spec->rel2abs( $path ) ;
+ $abs_path = File::Spec->rel2abs( $path, $base ) ;
If $base is not present or '', then L<cwd()> is used. If $base is relative,
then it is converted to absolute form using L</rel2abs()>. This means that it
is taken to be relative to L<cwd()>.
On systems with the concept of a volume, this assumes that both paths
-are on the $base volume, and ignores the $destination volume.
+are on the $base volume, and ignores the $path volume.
On systems that have a grammar that indicates filenames, this ignores the
$base filename as well. Otherwise all path components are assumed to be
@@ -401,13 +413,17 @@ directories.
If $path is absolute, it is cleaned up and returned using L</canonpath()>.
-Based on code written by Shigio Yamaguchi.
+No checks against the filesystem are made on most systems. On MacOS,
+the filesystem may be consulted (see
+L<File::Spec::MacOS/file_name_is_absolute>). On VMS, there is
+interaction with the working environment, as logicals and
+macros are expanded.
-No checks against the filesystem are made.
+Based on code written by Shigio Yamaguchi.
=cut
-sub rel2abs($;$;) {
+sub rel2abs {
my ($self,$path,$base ) = @_;
# Clean up $path
diff --git a/contrib/perl5/lib/File/Spec/VMS.pm b/contrib/perl5/lib/File/Spec/VMS.pm
index a2ac8ca..60b0ec8 100644
--- a/contrib/perl5/lib/File/Spec/VMS.pm
+++ b/contrib/perl5/lib/File/Spec/VMS.pm
@@ -1,8 +1,11 @@
package File::Spec::VMS;
use strict;
-use vars qw(@ISA);
+use vars qw(@ISA $VERSION);
require File::Spec::Unix;
+
+$VERSION = '1.1';
+
@ISA = qw(File::Spec::Unix);
use Cwd;
@@ -37,6 +40,11 @@ sub eliminate_macros {
my($self,$path) = @_;
return '' unless $path;
$self = {} unless ref $self;
+
+ if ($path =~ /\s/) {
+ return join ' ', map { $self->eliminate_macros($_) } split /\s+/, $path;
+ }
+
my($npath) = unixify($path);
my($complex) = 0;
my($head,$macro,$tail);
@@ -56,7 +64,7 @@ sub eliminate_macros {
$complex = 1;
}
}
- else { ($macro = unixify($self->{$macro})) =~ s#/\z##; }
+ else { ($macro = unixify($self->{$macro})) =~ s#/\Z(?!\n)##; }
$npath = "$head$macro$tail";
}
}
@@ -86,8 +94,14 @@ sub fixpath {
$self = bless {} unless ref $self;
my($fixedpath,$prefix,$name);
- if ($path =~ m#^\$\([^\)]+\)\z#s || $path =~ m#[/:>\]]#) {
- if ($force_path or $path =~ /(?:DIR\)|\])\z/) {
+ if ($path =~ /\s/) {
+ return join ' ',
+ map { $self->fixpath($_,$force_path) }
+ split /\s+/, $path;
+ }
+
+ if ($path =~ m#^\$\([^\)]+\)\Z(?!\n)#s || $path =~ m#[/:>\]]#) {
+ if ($force_path or $path =~ /(?:DIR\)|\])\Z(?!\n)/) {
$fixedpath = vmspath($self->eliminate_macros($path));
}
else {
@@ -97,7 +111,7 @@ sub fixpath {
elsif ((($prefix,$name) = ($path =~ m#^\$\(([^\)]+)\)(.+)#s)) && $self->{$prefix}) {
my($vmspre) = $self->eliminate_macros("\$($prefix)");
# is it a dir or just a name?
- $vmspre = ($vmspre =~ m|/| or $prefix =~ /DIR\z/) ? vmspath($vmspre) : '';
+ $vmspre = ($vmspre =~ m|/| or $prefix =~ /DIR\Z(?!\n)/) ? vmspath($vmspre) : '';
$fixedpath = ($vmspre ? $vmspre : $self->{$prefix}) . $name;
$fixedpath = vmspath($fixedpath) if $force_path;
}
@@ -136,7 +150,7 @@ sub canonpath {
my($self,$path) = @_;
if ($path =~ m|/|) { # Fake Unix
- my $pathify = $path =~ m|/\z|;
+ my $pathify = $path =~ m|/\Z(?!\n)|;
$path = $self->SUPER::canonpath($path);
if ($pathify) { return vmspath($path); }
else { return vmsify($path); }
@@ -169,8 +183,8 @@ sub catdir {
if (@dirs) {
my $path = (@dirs == 1 ? $dirs[0] : $self->catdir(@dirs));
my ($spath,$sdir) = ($path,$dir);
- $spath =~ s/\.dir\z//; $sdir =~ s/\.dir\z//;
- $sdir = $self->eliminate_macros($sdir) unless $sdir =~ /^[\w\-]+\z/s;
+ $spath =~ s/\.dir\Z(?!\n)//; $sdir =~ s/\.dir\Z(?!\n)//;
+ $sdir = $self->eliminate_macros($sdir) unless $sdir =~ /^[\w\-]+\Z(?!\n)/s;
$rslt = $self->fixpath($self->eliminate_macros($spath)."/$sdir",1);
# Special case for VMS absolute directory specs: these will have had device
@@ -181,7 +195,7 @@ sub catdir {
}
else {
if (not defined $dir or not length $dir) { $rslt = ''; }
- elsif ($dir =~ /^\$\([^\)]+\)\z/s) { $rslt = $dir; }
+ elsif ($dir =~ /^\$\([^\)]+\)\Z(?!\n)/s) { $rslt = $dir; }
else { $rslt = vmspath($dir); }
}
return $self->canonpath($rslt);
@@ -202,8 +216,8 @@ sub catfile {
if (@files) {
my $path = (@files == 1 ? $files[0] : $self->catdir(@files));
my $spath = $path;
- $spath =~ s/\.dir\z//;
- if ($spath =~ /^[^\)\]\/:>]+\)\z/s && basename($file) eq $file) {
+ $spath =~ s/\.dir\Z(?!\n)//;
+ if ($spath =~ /^[^\)\]\/:>]+\)\Z(?!\n)/s && basename($file) eq $file) {
$rslt = "$spath$file";
}
else {
@@ -251,7 +265,7 @@ sub rootdir {
Returns a string representation of the first writable directory
from the following list or '' if none are writable:
- sys$scratch
+ sys$scratch:
$ENV{TMPDIR}
=cut
@@ -259,7 +273,7 @@ from the following list or '' if none are writable:
my $tmpdir;
sub tmpdir {
return $tmpdir if defined $tmpdir;
- foreach ('sys$scratch', $ENV{TMPDIR}) {
+ foreach ('sys$scratch:', $ENV{TMPDIR}) {
next unless defined && -d && -w _;
$tmpdir = $_;
last;
@@ -310,7 +324,7 @@ Checks for VMS directory spec as well as Unix separators.
sub file_name_is_absolute {
my ($self,$file) = @_;
# If it's a logical name, expand it.
- $file = $ENV{$file} while $file =~ /^[\w\$\-]+\z/s && $ENV{$file};
+ $file = $ENV{$file} while $file =~ /^[\w\$\-]+\Z(?!\n)/s && $ENV{$file};
return scalar($file =~ m!^/!s ||
$file =~ m![<\[][^.\-\]>]! ||
$file =~ /:[^<\[]/);
@@ -341,7 +355,7 @@ sub splitdir {
$dirspec =~ s/\]\[//g; $dirspec =~ s/\-\-/-.-/g;
$dirspec = "[$dirspec]" unless $dirspec =~ /[\[<]/; # make legal
my(@dirs) = split('\.', vmspath($dirspec));
- $dirs[0] =~ s/^[\[<]//s; $dirs[-1] =~ s/[\]>]\z//s;
+ $dirs[0] =~ s/^[\[<]//s; $dirs[-1] =~ s/[\]>]\Z(?!\n)//s;
@dirs;
}
@@ -355,7 +369,7 @@ Construct a complete filespec using VMS syntax
sub catpath {
my($self,$dev,$dir,$file) = @_;
if ($dev =~ m|^/+([^/]+)|) { $dev = "$1:"; }
- else { $dev .= ':' unless $dev eq '' or $dev =~ /:\z/; }
+ else { $dev .= ':' unless $dev eq '' or $dev =~ /:\Z(?!\n)/; }
if (length($dev) or length($dir)) {
$dir = "[$dir]" unless $dir =~ /[\[<\/]/;
$dir = vmspath($dir);
@@ -400,17 +414,16 @@ sub abs2rel {
}
# Split up paths
- my ( undef, $path_directories, $path_file ) =
- $self->splitpath( $path, 1 ) ;
+ my ( $path_directories, $path_file ) =
+ ($self->splitpath( $path, 1 ))[1,2] ;
$path_directories = $1
- if $path_directories =~ /^\[(.*)\]\z/s ;
+ if $path_directories =~ /^\[(.*)\]\Z(?!\n)/s ;
- my ( undef, $base_directories, undef ) =
- $self->splitpath( $base, 1 ) ;
+ my $base_directories = ($self->splitpath( $base, 1 ))[1] ;
$base_directories = $1
- if $base_directories =~ /^\[(.*)\]\z/s ;
+ if $base_directories =~ /^\[(.*)\]\Z(?!\n)/s ;
# Now, remove all leading components that are the same
my @pathchunks = $self->splitdir( $path_directories );
@@ -427,7 +440,7 @@ sub abs2rel {
# @basechunks now contains the directories to climb out of,
# @pathchunks now has the directories to descend in to.
$path_directories = '-.' x @basechunks . join( '.', @pathchunks ) ;
- $path_directories =~ s{\.\z}{} ;
+ $path_directories =~ s{\.\Z(?!\n)}{} ;
return $self->canonpath( $self->catpath( '', $path_directories, $path_file ) ) ;
}
@@ -438,7 +451,7 @@ Use VMS syntax when converting filespecs.
=cut
-sub rel2abs($;$;) {
+sub rel2abs {
my $self = shift ;
return vmspath(File::Spec::Unix::rel2abs( $self, @_ ))
if ( join( '', @_ ) =~ m{/} ) ;
@@ -458,17 +471,17 @@ sub rel2abs($;$;) {
}
# Split up paths
- my ( undef, $path_directories, $path_file ) =
- $self->splitpath( $path ) ;
+ my ( $path_directories, $path_file ) =
+ ($self->splitpath( $path ))[1,2] ;
- my ( $base_volume, $base_directories, undef ) =
+ my ( $base_volume, $base_directories ) =
$self->splitpath( $base ) ;
$path_directories = '' if $path_directories eq '[]' ||
$path_directories eq '<>';
my $sep = '' ;
$sep = '.'
- if ( $base_directories =~ m{[^.\]>]\z} &&
+ if ( $base_directories =~ m{[^.\]>]\Z(?!\n)} &&
$path_directories =~ m{^[^.\[<]}s
) ;
$base_directories = "$base_directories$sep$path_directories";
diff --git a/contrib/perl5/lib/File/Spec/Win32.pm b/contrib/perl5/lib/File/Spec/Win32.pm
index aa95fbd..3c01985 100644
--- a/contrib/perl5/lib/File/Spec/Win32.pm
+++ b/contrib/perl5/lib/File/Spec/Win32.pm
@@ -2,8 +2,11 @@ package File::Spec::Win32;
use strict;
use Cwd;
-use vars qw(@ISA);
+use vars qw(@ISA $VERSION);
require File::Spec::Unix;
+
+$VERSION = '1.2';
+
@ISA = qw(File::Spec::Unix);
=head1 NAME
@@ -40,6 +43,7 @@ from the following list:
$ENV{TMPDIR}
$ENV{TEMP}
$ENV{TMP}
+ C:/temp
/tmp
/
@@ -49,7 +53,7 @@ my $tmpdir;
sub tmpdir {
return $tmpdir if defined $tmpdir;
my $self = shift;
- foreach (@ENV{qw(TMPDIR TEMP TMP)}, qw(/tmp /)) {
+ foreach (@ENV{qw(TMPDIR TEMP TMP)}, qw(C:/temp /tmp /)) {
next unless defined && -d;
$tmpdir = $_;
last;
@@ -105,8 +109,8 @@ sub canonpath {
$path =~ s|([^\\])\\+|$1\\|g; # xx////xx -> xx/xx
$path =~ s|(\\\.)+\\|\\|g; # xx/././xx -> xx/xx
$path =~ s|^(\.\\)+||s unless $path eq ".\\"; # ./xx -> xx
- $path =~ s|\\\z||
- unless $path =~ m#^([A-Z]:)?\\\z#s; # xx/ -> xx
+ $path =~ s|\\\Z(?!\n)||
+ unless $path =~ m#^([A-Z]:)?\\\Z(?!\n)#s; # xx/ -> xx
return $path;
}
@@ -146,7 +150,7 @@ sub splitpath {
(?:\\\\|//)[^\\/]+[\\/][^\\/]+
)?
)
- ( (?:.*[\\\\/](?:\.\.?\z)?)? )
+ ( (?:.*[\\\\/](?:\.\.?\Z(?!\n))?)? )
(.*)
}xs;
$volume = $1;
@@ -187,7 +191,7 @@ sub splitdir {
# check to be sure that there will not be any before handling the
# simple case.
#
- if ( $directories !~ m|[\\/]\z| ) {
+ if ( $directories !~ m|[\\/]\Z(?!\n)| ) {
return split( m|[\\/]|, $directories );
}
else {
@@ -216,7 +220,7 @@ sub catpath {
# If it's UNC, make sure the glue separator is there, reusing
# whatever separator is first in the $volume
$volume .= $1
- if ( $volume =~ m@^([\\/])[\\/][^\\/]+[\\/][^\\/]+\z@s &&
+ if ( $volume =~ m@^([\\/])[\\/][^\\/]+[\\/][^\\/]+\Z(?!\n)@s &&
$directory =~ m@^[^\\/]@s
) ;
@@ -224,8 +228,8 @@ sub catpath {
# If the volume is not just A:, make sure the glue separator is
# there, reusing whatever separator is first in the $volume if possible.
- if ( $volume !~ m@^[a-zA-Z]:\z@s &&
- $volume =~ m@[^\\/]\z@ &&
+ if ( $volume !~ m@^[a-zA-Z]:\Z(?!\n)@s &&
+ $volume =~ m@[^\\/]\Z(?!\n)@ &&
$file =~ m@[^\\/]@
) {
$volume =~ m@([\\/])@ ;
@@ -239,34 +243,6 @@ sub catpath {
}
-=item abs2rel
-
-Takes a destination path and an optional base path returns a relative path
-from the base path to the destination path:
-
- $rel_path = File::Spec->abs2rel( $destination ) ;
- $rel_path = File::Spec->abs2rel( $destination, $base ) ;
-
-If $base is not present or '', then L</cwd()> is used. If $base is relative,
-then it is converted to absolute form using L</rel2abs()>. This means that it
-is taken to be relative to L<cwd()>.
-
-On systems with the concept of a volume, this assumes that both paths
-are on the $destination volume, and ignores the $base volume.
-
-On systems that have a grammar that indicates filenames, this ignores the
-$base filename as well. Otherwise all path components are assumed to be
-directories.
-
-If $path is relative, it is converted to absolute form using L</rel2abs()>.
-This means that it is taken to be relative to L</cwd()>.
-
-Based on code written by Shigio Yamaguchi.
-
-No checks against the filesystem are made.
-
-=cut
-
sub abs2rel {
my($self,$path,$base) = @_;
@@ -293,8 +269,7 @@ sub abs2rel {
my ( $path_volume, $path_directories, $path_file ) =
$self->splitpath( $path, 1 ) ;
- my ( undef, $base_directories, undef ) =
- $self->splitpath( $base, 1 ) ;
+ my $base_directories = ($self->splitpath( $base, 1 ))[1] ;
# Now, remove all leading components that are the same
my @pathchunks = $self->splitdir( $path_directories );
@@ -337,33 +312,8 @@ sub abs2rel {
) ;
}
-=item rel2abs
-
-Converts a relative path to an absolute path.
-
- $abs_path = File::Spec->rel2abs( $destination ) ;
- $abs_path = File::Spec->rel2abs( $destination, $base ) ;
-
-If $base is not present or '', then L<cwd()> is used. If $base is relative,
-then it is converted to absolute form using L</rel2abs()>. This means that it
-is taken to be relative to L</cwd()>.
-
-Assumes that both paths are on the $base volume, and ignores the
-$destination volume.
-
-On systems that have a grammar that indicates filenames, this ignores the
-$base filename as well. Otherwise all path components are assumed to be
-directories.
-
-If $path is absolute, it is cleaned up and returned using L</canonpath()>.
-
-Based on code written by Shigio Yamaguchi.
-
-No checks against the filesystem are made.
-
-=cut
-sub rel2abs($;$;) {
+sub rel2abs {
my ($self,$path,$base ) = @_;
if ( ! $self->file_name_is_absolute( $path ) ) {
@@ -378,10 +328,10 @@ sub rel2abs($;$;) {
$base = $self->canonpath( $base ) ;
}
- my ( undef, $path_directories, $path_file ) =
- $self->splitpath( $path, 1 ) ;
+ my ( $path_directories, $path_file ) =
+ ($self->splitpath( $path, 1 ))[1,2] ;
- my ( $base_volume, $base_directories, undef ) =
+ my ( $base_volume, $base_directories ) =
$self->splitpath( $base, 1 ) ;
$path = $self->catpath(
OpenPOWER on IntegriCloud