diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-01-17 05:56:12 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-01-17 05:56:12 +0000 |
commit | df25ddbaa89dbf191c87be190a84a5e3a6d55a27 (patch) | |
tree | 5000f6fa3a374e7786040967c522407c89fa9564 /pp_sys.c | |
parent | 76d3c696f3f9d8be0bea9b002ddfc255153cfadd (diff) | |
download | perl-df25ddbaa89dbf191c87be190a84a5e3a6d55a27.tar.gz |
Allow for one trailing slash in the directory of mkdir().
p4raw-id: //depot/perl@8461
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -3588,15 +3588,23 @@ PP(pp_mkdir) #ifndef HAS_MKDIR int oldumask; #endif - STRLEN n_a; + STRLEN len; char *tmps; + bool copy = FALSE; if (MAXARG > 1) mode = POPi; else mode = 0777; - tmps = SvPV(TOPs, n_a); + tmps = SvPV(TOPs, len); + /* Different operating and file systems take differently to + * trailing slashes. To err on the side of portability, we + * snip away one trailing slash. */ + if (tmps[len-1] == '/') { + tmps = savepvn(tmps, len - 1); + copy = TRUE; + } TAINT_PROPER("mkdir"); #ifdef HAS_MKDIR @@ -3607,6 +3615,8 @@ PP(pp_mkdir) PerlLIO_umask(oldumask); PerlLIO_chmod(tmps, (mode & ~oldumask) & 0777); #endif + if (copy) + Safefree(tmps); RETURN; } |