From: Jarkko Hietaniemi Date: Wed, 10 Oct 2001 12:22:02 +0000 (+0000) Subject: Fix/improve handling of the [000000] special "root" X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=737c380eddfcfb819f42666b6b5bd6171d245f53;p=p5sagit%2Fp5-mst-13.2.git Fix/improve handling of the [000000] special "root" directory, by putting cwd in canonical form when doing abs2rel, and prepending a 000000 to directory "chunks" if missing from base or path. Also adjust test to reflect the (improved) output from abs2rel. From Charles Lane. p4raw-id: //depot/perl@12391 --- diff --git a/lib/File/Spec.t b/lib/File/Spec.t index a7b0470..698ea01 100755 --- a/lib/File/Spec.t +++ b/lib/File/Spec.t @@ -239,7 +239,7 @@ BEGIN { [ "VMS->abs2rel('[t1.t2]file','[t1.t2.t3]')", '[-]file' ], [ "VMS->abs2rel('[t1.t2.t3.t4]','[t1.t2.t3]')", '[t4]' ], [ "VMS->abs2rel('[t4.t5.t6]','[t1.t2.t3]')", '[---.t4.t5.t6]' ], -[ "VMS->abs2rel('[000000]','[t1.t2.t3]')", '[---.000000]' ], +[ "VMS->abs2rel('[000000]','[t1.t2.t3]')", '[---]' ], [ "VMS->abs2rel('a:[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ], [ "VMS->abs2rel('[a.-.b.c.-]','[t1.t2.t3]')", '[---.b]' ], diff --git a/lib/File/Spec/VMS.pm b/lib/File/Spec/VMS.pm index 1799622..e51286b 100644 --- a/lib/File/Spec/VMS.pm +++ b/lib/File/Spec/VMS.pm @@ -406,6 +406,7 @@ sub abs2rel { # Figure out the effective $base and clean it up. if ( !defined( $base ) || $base eq '' ) { $base = cwd() ; + $base = $self->canonpath( $base ) ; } elsif ( ! $self->file_name_is_absolute( $base ) ) { $base = $self->rel2abs( $base ) ; @@ -428,7 +429,9 @@ sub abs2rel { # Now, remove all leading components that are the same my @pathchunks = $self->splitdir( $path_directories ); + unshift(@pathchunks,'000000') unless $pathchunks[0] eq '000000'; my @basechunks = $self->splitdir( $base_directories ); + unshift(@basechunks,'000000') unless $basechunks[0] eq '000000'; while ( @pathchunks && @basechunks &&