Fix/improve handling of the [000000] special "root"
authorJarkko Hietaniemi <jhi@iki.fi>
Wed, 10 Oct 2001 12:22:02 +0000 (12:22 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Wed, 10 Oct 2001 12:22:02 +0000 (12:22 +0000)
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
lib/File/Spec/VMS.pm

index a7b0470..698ea01 100755 (executable)
@@ -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]'          ],
 
index 1799622..e51286b 100644 (file)
@@ -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 &&