aboutsummaryrefslogtreecommitdiff
path: root/contrib/perl5/lib/File/Spec
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/perl5/lib/File/Spec')
-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
6 files changed, 126 insertions, 145 deletions
diff --git a/contrib/perl5/lib/File/Spec/Functions.pm b/contrib/perl5/lib/File/Spec/Functions.pm
index 140738f44398..0036ac1ded00 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 959e33d0cf3b..9ef55ec84ad8 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 33370f06c195..20bf8c9dcefb 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 2305b75b761f..a81c533235f2 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 a2ac8cac0bb5..60b0ec8e50dc 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 aa95fbde363e..3c019853f112 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(