summaryrefslogtreecommitdiff
path: root/os2
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.berkeley.edu>2002-12-13 05:54:05 -0800
committerhv <hv@crypt.org>2002-12-17 02:17:16 +0000
commitcd4e750ae15ad1c90d874c67a9960de086fdccf5 (patch)
tree80c7ac3165cf08aa37cc9f25202c086ecb25fd90 /os2
parent803b07a779c719a9176a69ed7eb5685bb9f23042 (diff)
downloadperl-cd4e750ae15ad1c90d874c67a9960de086fdccf5.tar.gz
build
Message-ID: <20021213215404.GA2597@math.berkeley.edu> p4raw-id: //depot/perl@18316
Diffstat (limited to 'os2')
-rw-r--r--os2/os2.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/os2/os2.c b/os2/os2.c
index fc05f4e9ae..49b1736ab8 100644
--- a/os2/os2.c
+++ b/os2/os2.c
@@ -2637,18 +2637,30 @@ my_tmpfile ()
#undef rmdir
+/* EMX flavors do not tolerate trailing slashes. t/op/mkdir.t has many
+ trailing slashes, so we need to support this as well. */
+
int
my_rmdir (__const__ char *s)
{
- char buf[MAXPATHLEN];
+ char b[MAXPATHLEN];
+ char *buf = b;
STRLEN l = strlen(s);
+ int rc;
- if (s[l-1] == '/' || s[l-1] == '\\') { /* EMX rmdir fails... */
+ if (s[l-1] == '/' || s[l-1] == '\\') { /* EMX mkdir fails... */
+ if (l >= sizeof b)
+ New(1305, buf, l + 1, char);
strcpy(buf,s);
- buf[l - 1] = 0;
+ while (l > 1 && (s[l-1] == '/' || s[l-1] == '\\'))
+ l--;
+ buf[l] = 0;
s = buf;
}
- return rmdir(s);
+ rc = rmdir(s);
+ if (b != buf)
+ Safefree(buf);
+ return rc;
}
#undef mkdir
@@ -2656,15 +2668,24 @@ my_rmdir (__const__ char *s)
int
my_mkdir (__const__ char *s, long perm)
{
- char buf[MAXPATHLEN];
+ char b[MAXPATHLEN];
+ char *buf = b;
STRLEN l = strlen(s);
+ int rc;
if (s[l-1] == '/' || s[l-1] == '\\') { /* EMX mkdir fails... */
+ if (l >= sizeof b)
+ New(1305, buf, l + 1, char);
strcpy(buf,s);
- buf[l - 1] = 0;
+ while (l > 1 && (s[l-1] == '/' || s[l-1] == '\\'))
+ l--;
+ buf[l] = 0;
s = buf;
}
- return mkdir(s, perm);
+ rc = mkdir(s, perm);
+ if (b != buf)
+ Safefree(buf);
+ return rc;
}
#undef flock