From: Jarkko Hietaniemi Date: Wed, 17 Jan 2001 05:56:12 +0000 (+0000) Subject: Allow for one trailing slash in the directory of mkdir(). X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=df25ddbaa89dbf191c87be190a84a5e3a6d55a27;p=p5sagit%2Fp5-mst-13.2.git Allow for one trailing slash in the directory of mkdir(). p4raw-id: //depot/perl@8461 --- diff --git a/pp_sys.c b/pp_sys.c index ca4d1bd..32fd686 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -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; }