This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix unixify when beginning with current directory.
authorCraig A. Berry <craigberry@mac.com>
Tue, 5 May 2015 02:25:05 +0000 (21:25 -0500)
committerCraig A. Berry <craigberry@mac.com>
Wed, 6 May 2015 23:51:22 +0000 (18:51 -0500)
VMS::Filespec::unixify has been truncating its return value and
returning early when the input begins with [] meaning the current
directory.  If there was nothing else, we've been getting the right
answer:

    [] --> ./

but if there was a file portion of the name it's been getting
omitted:

    []foo.txt --> ./

which is now fixed.  Looks like it's been broken since inception
in 5.002, though only with the specific [] case and not if there
was an explicit device or directory name.

ext/VMS-Filespec/t/filespec.t
vms/vms.c

index f556703..6d421e1 100644 (file)
@@ -110,6 +110,7 @@ __lyrics_:[__are_.__very_^.__sappy_]__but_^.__rhymes_^.__are_.__true_    unixify
 [.$(macro)]    unixify $(macro)/ ^
 ^+foo.tmp      unixify +foo.tmp ^
 [-.foo^_^_bar] unixify ../foo\ \ bar/ ^
+[]foo.tmp      unixify ./foo.tmp ^
 
 # and back again
 /__some_/__where_/__over_/__the_.__rainbow_    vmsify  __some_:[__where_.__over_]__the_.__rainbow_ ^
@@ -135,6 +136,8 @@ foo-bar-0^.01/      vmsify [.foo-bar-0_01] [.foo-bar-0^.01]
 \ foo.tmp      vmsify ^_foo.tmp ^
 +foo.tmp       vmsify ^+foo.tmp ^
 ../foo\ \ bar/ vmsify [-.foo^_^_bar] ^
+./foo.tmp      vmsify []foo.tmp ^
+
 # Fileifying directory specs
 __down_:[__the_.__garden_.__path_]     fileify __down_:[__the_.__garden_]__path_.dir;1 ^
 [.__down_.__the_.__garden_.__path_]    fileify [.__down_.__the_.__garden_]__path_.dir;1 ^
index 0364415..953d8b8 100644 (file)
--- a/vms/vms.c
+++ b/vms/vms.c
@@ -7073,9 +7073,8 @@ int_tounixspec(const char *spec, char *rslt, int * utf8_fl)
   else {  /* the VMS spec begins with directories */
     cp2++;
     if (*cp2 == ']' || *cp2 == '>') {
-      *(cp1++) = '.'; *(cp1++) = '/'; *(cp1++) = '\0';
-      PerlMem_free(tmp);
-      return rslt;
+      *(cp1++) = '.';
+      *(cp1++) = '/';
     }
     else if ( *cp2 != '^' && *cp2 != '.' && *cp2 != '-') { /* add the implied device */
       if (getcwd(tmp, VMS_MAXRSS-1 ,1) == NULL) {