From 737c380eddfcfb819f42666b6b5bd6171d245f53 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Wed, 10 Oct 2001 12:22:02 +0000 Subject: [PATCH] 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 --- lib/File/Spec.t | 2 +- lib/File/Spec/VMS.pm | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/File/Spec.t b/lib/File/Spec.t index a7b0470b69..698ea015e7 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 17996220bd..e51286bade 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 && -- 2.34.1