summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-01-17 05:56:12 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-01-17 05:56:12 +0000
commitdf25ddbaa89dbf191c87be190a84a5e3a6d55a27 (patch)
tree5000f6fa3a374e7786040967c522407c89fa9564 /pp_sys.c
parent76d3c696f3f9d8be0bea9b002ddfc255153cfadd (diff)
downloadperl-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.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/pp_sys.c b/pp_sys.c
index ca4d1bd4f3..32fd6864b1 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;
}