summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2002-08-29 20:40:45 -0700
committerhv <hv@crypt.org>2002-09-04 11:31:42 +0000
commit02961b5242f21ef9dd6c7907b07603d757b13077 (patch)
tree306837c6a34b8b4a5fe918e318f8a15d11dfb45b /lib
parent522b859adcc800ddbbe593fba580633bb305644f (diff)
downloadperl-02961b5242f21ef9dd6c7907b07603d757b13077.tar.gz
File::Spec->catfile not canonicalizing consistently
Message-ID: <20020830104044.GF859@ool-18b93024.dyn.optonline.net> p4raw-id: //depot/perl@17828
Diffstat (limited to 'lib')
-rw-r--r--lib/File/Spec/Unix.pm2
-rw-r--r--lib/File/Spec/Win32.pm2
-rw-r--r--lib/File/Spec/t/Spec.t27
3 files changed, 25 insertions, 6 deletions
diff --git a/lib/File/Spec/Unix.pm b/lib/File/Spec/Unix.pm
index 87ee505102..d9615c06b4 100644
--- a/lib/File/Spec/Unix.pm
+++ b/lib/File/Spec/Unix.pm
@@ -88,7 +88,7 @@ complete path ending with a filename
sub catfile {
my $self = shift;
- my $file = pop @_;
+ my $file = File::Spec->canonpath(pop @_);
return $file unless @_;
my $dir = $self->catdir(@_);
$dir .= "/" unless substr($dir,-1) eq "/";
diff --git a/lib/File/Spec/Win32.pm b/lib/File/Spec/Win32.pm
index 186052bb4d..791b004d07 100644
--- a/lib/File/Spec/Win32.pm
+++ b/lib/File/Spec/Win32.pm
@@ -95,7 +95,7 @@ complete path ending with a filename
sub catfile {
my $self = shift;
- my $file = pop @_;
+ my $file = $self->canonpath(pop @_);
return $file unless @_;
my $dir = $self->catdir(@_);
$dir .= "\\" unless substr($dir,-1) eq "\\";
diff --git a/lib/File/Spec/t/Spec.t b/lib/File/Spec/t/Spec.t
index 3f18a35277..35b2e6f254 100644
--- a/lib/File/Spec/t/Spec.t
+++ b/lib/File/Spec/t/Spec.t
@@ -50,7 +50,11 @@ if ($^O eq 'MacOS') {
@tests = (
# [ Function , Expected , Platform ]
-[ "Unix->catfile('a','b','c')", 'a/b/c' ],
+[ "Unix->catfile('a','b','c')", 'a/b/c' ],
+[ "Unix->catfile('a','b','./c')", 'a/b/c' ],
+[ "Unix->catfile('./a','b','c')", 'a/b/c' ],
+[ "Unix->catfile('c')", 'c' ],
+[ "Unix->catfile('./c')", 'c' ],
[ "Unix->splitpath('file')", ',,file' ],
[ "Unix->splitpath('/d1/d2/d3/')", ',/d1/d2/d3/,' ],
@@ -87,8 +91,6 @@ if ($^O eq 'MacOS') {
[ "Unix->catdir('','d1','d2','d3')", '/d1/d2/d3' ],
[ "Unix->catdir('d1','d2','d3')", 'd1/d2/d3' ],
-[ "Unix->catfile('a','b','c')", 'a/b/c' ],
-
[ "Unix->canonpath('')", '' ],
[ "Unix->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
[ "Unix->canonpath('/.')", '/' ],
@@ -184,7 +186,12 @@ if ($^O eq 'MacOS') {
[ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\B:\\d2\\d3' ],
[ "Win32->catdir('A:/')", 'A:\\' ],
-[ "Win32->catfile('a','b','c')", 'a\\b\\c' ],
+[ "Win32->catfile('a','b','c')", 'a\\b\\c' ],
+[ "Win32->catfile('a','b','.\\c')", 'a\\b\\c' ],
+[ "Win32->catfile('.\\a','b','c')", 'a\\b\\c' ],
+[ "Win32->catfile('c')", 'c' ],
+[ "Win32->catfile('.\\c')", 'c' ],
+
[ "Win32->canonpath('')", '' ],
[ "Win32->canonpath('a:')", 'A:' ],
@@ -226,6 +233,13 @@ if ($^O eq 'MacOS') {
[ "Win32->rel2abs('temp','//prague_main/work')", '\\\\prague_main\\work\\temp' ],
[ "Win32->rel2abs('../','//prague_main/work')", '\\\\prague_main\\work\\..' ],
+
+[ "VMS->catfile('a','b','c')", '[.a.b]c' ],
+[ "VMS->catfile('a','b','[]c')", '[.a.b]c' ],
+[ "VMS->catfile('[.a]','b','c')", '[.a.b]c' ],
+[ "VMS->catfile('c')", 'c' ],
+[ "VMS->catfile('[]c')", 'c' ],
+
[ "VMS->splitpath('file')", ',,file' ],
[ "VMS->splitpath('[d1.d2.d3]')", ',[d1.d2.d3],' ],
[ "VMS->splitpath('[.d1.d2.d3]')", ',[.d1.d2.d3],' ],
@@ -294,7 +308,12 @@ if ($^O eq 'MacOS') {
[ "VMS->rel2abs('[t1]','[t1.t2.t3]')", '[t1]' ],
[ "OS2->catdir('A:/d1','B:/d2','d3','')", 'A:/d1/B:/d2/d3' ],
+
[ "OS2->catfile('a','b','c')", 'a/b/c' ],
+[ "OS2->catfile('a','b','./c')", 'a/b/c' ],
+[ "OS2->catfile('./a','b','c')", 'a/b/c' ],
+[ "OS2->catfile('c')", 'c' ],
+[ "OS2->catfile('./c')", 'c' ],
[ "Mac->catpath('','','')", '' ],