From: Michael G. Schwern Date: Fri, 30 Aug 2002 03:40:45 +0000 (-0700) Subject: File::Spec->catfile not canonicalizing consistently X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=02961b5242f21ef9dd6c7907b07603d757b13077;p=p5sagit%2Fp5-mst-13.2.git File::Spec->catfile not canonicalizing consistently Message-ID: <20020830104044.GF859@ool-18b93024.dyn.optonline.net> p4raw-id: //depot/perl@17828 --- diff --git a/lib/File/Spec/Unix.pm b/lib/File/Spec/Unix.pm index 87ee505..d9615c0 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 186052b..791b004 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 3f18a35..35b2e6f 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('','','')", '' ],