diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-05-07 01:24:19 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-05-07 01:24:19 +0000 |
commit | 101e51674871122572db1eb9982dc8d132eb2ae9 (patch) | |
tree | 8839e368dc2ef6047ec395f67fa7d2c4a57abf9b /vms | |
parent | 3d0ae7ba72551d8af1ecbcfb8a67d9a77f1cf195 (diff) | |
download | perl-101e51674871122572db1eb9982dc8d132eb2ae9.tar.gz |
workaround for CRT bug in chdir() (from Charles Lane, via
Peter Prymmer)
p4raw-id: //depot/perl@6078
Diffstat (limited to 'vms')
-rw-r--r-- | vms/vms.c | 24 | ||||
-rw-r--r-- | vms/vmsish.h | 5 |
2 files changed, 28 insertions, 1 deletions
@@ -911,6 +911,30 @@ my_mkdir(char *dir, Mode_t mode) } /* 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 */ +/*}}}*/ static void create_mbx(unsigned short int *chan, struct dsc$descriptor_s *namdsc) diff --git a/vms/vmsish.h b/vms/vmsish.h index e53c604d16..c21f8f329e 100644 --- a/vms/vmsish.h +++ b/vms/vmsish.h @@ -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 @@ struct utimbuf { /* 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 @@ char * my_gconvert (double, int, int, char *); 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); |