Handle directories with dots in fileify under EFS.
authorCraig A. Berry <craigberry@mac.com>
Sun, 22 Jan 2012 14:03:26 +0000 (08:03 -0600)
committerCraig A. Berry <craigberry@mac.com>
Tue, 24 Jan 2012 00:42:15 +0000 (18:42 -0600)
When Extended Filename Syntax (EFS) is in effect, it's legal for
directory names to contain dots that are not directory delimiters.
This commit escapes such dots when they are part of the file
portion of the fileified directory spec.

This gets two more of the vms/ext/filespec.t tests passing when
EFS is in effect.

vms/vms.c

index 4f69ec5..9d3ed12 100644 (file)
--- a/vms/vms.c
+++ b/vms/vms.c
@@ -6133,6 +6133,20 @@ int_fileify_dirspec(const char *dir, char *buf, int *utf8_fl)
                 /* The .dir for now, and fix this better later */
                 dirlen = cp2 - trndir;
             }
+            if (decc_efs_charset) {
+                /* Dots are allowed in dir names, so escape them. */
+                char *cp4 = is_dir ? (cp2 - 1) : cp2;
+                  
+                for (; cp4 > cp1; cp4--) {
+                    if (*cp4 == '.') {
+                        if ((cp4 - 1 > trndir) && (*(cp4 - 1) != '^')) {
+                            memmove(cp4 + 1, cp4, trndir + dirlen - cp4 + 1);
+                            *cp4 = '^';
+                            dirlen++;
+                       }
+                    }
+                }
+            }
         }
 
       }