diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-02-01 03:12:21 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-02-01 03:12:21 +0000 |
commit | 73af1e949d5c017068e3f3fabb9e5260b91ffab0 (patch) | |
tree | b87ecb9a91288193e781207cca394bd73dcfa21f /dir.c | |
parent | 1af83e49971e5ca5fa1b0c80a12e7b34d9271cac (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.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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); |