summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-01 03:12:21 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-01 03:12:21 +0000
commit73af1e949d5c017068e3f3fabb9e5260b91ffab0 (patch)
treeb87ecb9a91288193e781207cca394bd73dcfa21f /dir.c
parent1af83e49971e5ca5fa1b0c80a12e7b34d9271cac (diff)
2000-02-01
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index 780f269134..2eb01106a0 100644
--- a/dir.c
+++ b/dir.c
@@ -510,7 +510,7 @@ extract_path(p, pend)
len = pend - p;
alloc = ALLOC_N(char, len+1);
memcpy(alloc, p, len);
- if (len > 0 && pend[-1] == '/') {
+ if (len > 1 && pend[-1] == '/') {
alloc[len-1] = 0;
}
else {
@@ -579,8 +579,9 @@ glob(path, func, arg)
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
if (fnmatch(magic, dp->d_name, FNM_PERIOD|FNM_PATHNAME) == 0) {
char *fix = ALLOC_N(char, strlen(base)+NAMLEN(dp)+2);
+ #define BASE (*base && !(*base == '/' && !base[1]))
- sprintf(fix, "%s%s%s", base, (*base)?"/":"", dp->d_name);
+ sprintf(fix, "%s%s%s", base, (BASE)?"/":"", dp->d_name);
if (!m) {
(*func)(fix, arg);
free(fix);