Peter Prymmer ([EMAIL PROTECTED]) writes:
> Charles Lane wrote:

>> > Hmm this is DEC C version dependent.  I'd guess that putting a warning
>> > into the pod for File::Find wouldn't be appropriate and I am not
>> > sure about that for VMS::Filespec.  Maybe README.vms or VMS::Filespec?
>>
>> maybe instead we should make Perl call a "my_chdir", just like my_mkdir...
>> then it won't matter whether the user has the trailing slash or not.

> Yes that sounds to me like a reasonable (i.e. very perlian) thing to do.
> I had developed my script on an Alpha that had DECC 6.0 and was shocked
> by the bug on the VAX.  While I am not sure if the architecture matters
> to the bug in the C RTL but it appears that:

> #if defined(__DECC_VER) && __DECC_VER == 50390006

I'm using DECC 5.5-003 on an Alpha and also have the "trailing
slash" problem.  So rather than version/architecture testing, I suggest
we just strip 'em all and not worry about it further.

Patch follows:


--- iperlsys.h-orig     Fri Apr 21 07:39:46 2000
+++ iperlsys.h  Fri Apr 21 07:39:31 2000
@@ -551,7 +551,7 @@
 
 #define PerlDir_mkdir(name, mode)      Mkdir((name), (mode))
 #ifdef VMS
-#  define PerlDir_chdir(n)             chdir(((n) && *(n)) ? (n) : "SYS$LOGIN")
+#  define PerlDir_chdir(n)             Chdir(((n) && *(n)) ? (n) : "SYS$LOGIN")
 #else 
 #  define PerlDir_chdir(name)          chdir((name))
 #endif
--- vms/vms.c-orig      Fri Apr 21 07:37:30 2000
+++ vms/vms.c   Fri Apr 21 08:55:47 2000
@@ -915,4 +915,28 @@
 }  /* end of my_mkdir */
 /*}}}*/
 
+/*{{{int my_chdir(char *)*/
+int
+my_chdir(char *dir)
+{
+  STRLEN dirlen = strlen(dir);
+  dTHX;
+
+  /* zero length string sometimes gives ACCVIO */
+  if (dirlen == 0) return -1;
+
+  /* some versions of CRTL chdir() doesn't tolerate trailing /, since 
+   * that implies
+   * null file name/type.  However, it's commonplace under Unix,
+   * so we'll allow it for a gain in portability.
+   */
+  if (dir[dirlen-1] == '/') {
+    char *newdir = savepvn(dir,dirlen-1);
+    int ret = chdir(newdir);
+    Safefree(newdir);
+    return ret;
+  }
+  else return chdir(dir);
+}  /* end of my_chdir */
+/*}}}*/
 
--- vms/vmsish.h-orig   Fri Apr 21 07:37:23 2000
+++ vms/vmsish.h        Fri Apr 21 07:36:46 2000
@@ -109,6 +109,7 @@
 #define do_rmdir               Perl_do_rmdir
 #define kill_file              Perl_kill_file
 #define my_mkdir               Perl_my_mkdir
+#define my_chdir               Perl_my_chdir
 #define my_utime               Perl_my_utime
 #define rmsexpand      Perl_rmsexpand
 #define rmsexpand_ts   Perl_rmsexpand_ts
@@ -447,8 +448,9 @@
 /* Ditto for sys$hash_passwrod() . . . */
 #define crypt  my_crypt
 
-/* Tweak arg to mkdir first, so we can tolerate trailing /. */
+/* Tweak arg to mkdir & chdir first, so we can tolerate trailing /. */
 #define Mkdir(dir,mode) my_mkdir((dir),(mode))
+#define Chdir(dir) my_chdir((dir))
 
 /* Use our own stat() clones, which handle Unix-style directory names */
 #define Stat(name,bufptr) flex_stat(name,bufptr)
@@ -638,6 +640,7 @@
 int    do_rmdir (char *);
 int    kill_file (char *);
 int    my_mkdir (char *, Mode_t);
+int    my_chdir (char *);
 int    my_utime (char *, struct utimbuf *);
 char * rmsexpand (char *, char *, char *, unsigned);
 char * rmsexpand_ts (char *, char *, char *, unsigned);
--
 Drexel University       \V                     --Chuck Lane
----------------->--------*------------<[EMAIL PROTECTED]
     (215) 895-1545      / \  Particle Physics  [EMAIL PROTECTED]
FAX: (215) 895-5934        /~~~~~~~~~~~         [EMAIL PROTECTED]

Reply via email to