In abs2rel() fix handling of directory trees so that the test $file = File::Spec::VMS->abs2rel('[t1.t2.t3]file', '[t1.t2.t3]') returns 'file' instead of an empty string.

In canonpath(), fix case where '[]' was totally optimized away instead of just returning '[]'.

$file = File::Spec::VMS->abs2rel('[t1.t2.t3]','[t1.t2.t3]');

TODO:

The canonpath() routine still has a bug where it does not ignore characters preceded by a '^' when it is searching for directory fragments to remove. In particular, '^.' is a period character in a directory specification, not a '^' character followed by a delimiter.

In an OpenVMS file specification, the '^' character is an escape code for special handling of the following characters or ascii representation of hexadecimal notation. If a real '^' is found in a OpenVMS file specification it will be preceded by a '^'.

I do not know how to recode canonpath() to fix that.

Also, UNIX format specifications are being unexpectedly translated to OpenVMS format specifications somewhere. This is not good as it can cause a loss of accurate path information under some conditions.

vmsify() and unixify() are not always reversible operations.

-John
[EMAIL PROTECTED]
Personal Opinion Only
--- /rsync_root/perl/lib/File/Spec/VMS.pm       Sat Nov 19 09:14:06 2005
+++ lib/File/Spec/VMS.pm        Sun Dec  4 09:16:05 2005
@@ -71,7 +71,7 @@
        $path =~ s/\[[^\]\.]+\.-\./\[/g;        # [foo.-.       ==> [
        $path =~ s/\.[^\]\.]+\.-\]/\]/g;        # .foo.-]       ==> ]
        $path =~ s/\[[^\]\.]+\.-\]/\[000000\]/g;# [foo.-]       ==> [000000]
-       $path =~ s/\[\]//;                      # []            ==>
+       $path =~ s/\[\]// unless $path eq '[]'; # []            ==>
        return $path;
     }
 }
@@ -335,8 +335,10 @@
 
     # Now, remove all leading components that are the same
     my @pathchunks = $self->splitdir( $path_directories );
+    my $pathchunks = @pathchunks;
     unshift(@pathchunks,'000000') unless $pathchunks[0] eq '000000';
     my @basechunks = $self->splitdir( $base_directories );
+    my $basechunks = @basechunks;
     unshift(@basechunks,'000000') unless $basechunks[0] eq '000000';
 
     while ( @pathchunks && 
@@ -347,11 +349,15 @@
         shift @basechunks ;
     }
 
-    return $self->curdir unless @pathchunks || @basechunks;
-
     # @basechunks now contains the directories to climb out of,
     # @pathchunks now has the directories to descend in to.
-    $path_directories = join '.', ('-' x @basechunks, @pathchunks) ;
+    if ((@basechunks > 0) || ($basechunks != $pathchunks)) {
+      $path_directories = join '.', ('-' x @basechunks, @pathchunks) ;
+    }
+    else {
+      $path_directories = join '.', @pathchunks;
+    }
+    $path_directories = '['.$path_directories.']';
     return $self->canonpath( $self->catpath( '', $path_directories, $path_file 
) ) ;
 }
 

Reply via email to