git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eban 2000-09-25 07:00:55 +00:00
parent 1562b35feb
commit 40412b7730
3 changed files with 12 additions and 9 deletions

View File

@ -1,6 +1,6 @@
Mon Sep 25 13:31:45 2000 WATANABE Hirofumi <eban@os.rim.or.jp> Mon Sep 25 13:31:45 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
* dir.c (rb_glob): DOSISH support. * win32/win32.c (NtCmdGlob): substitute '\\' with '/'.
Mon Sep 25 00:35:01 2000 WATANABE Hirofumi <eban@os.rim.or.jp> Mon Sep 25 00:35:01 2000 WATANABE Hirofumi <eban@os.rim.or.jp>

12
dir.c
View File

@ -511,11 +511,9 @@ has_magic(s, send)
return Qtrue; return Qtrue;
continue; continue;
#if !defined DOSISH
case '\\': case '\\':
if (*p++ == '\0') if (*p++ == '\0')
return Qfalse; return Qfalse;
#endif
} }
if (send && p >= send) break; if (send && p >= send) break;
@ -533,7 +531,7 @@ extract_path(p, pend)
len = pend - p; len = pend - p;
alloc = ALLOC_N(char, len+1); alloc = ALLOC_N(char, len+1);
memcpy(alloc, p, len); memcpy(alloc, p, len);
if (len > 1 && isdirsep(pend[-1])) { if (len > 1 && pend[-1] == '/') {
alloc[len-1] = 0; alloc[len-1] = 0;
} }
else { else {
@ -549,7 +547,7 @@ extract_elem(path)
{ {
char *pend; char *pend;
pend = find_dirsep(path); pend = strchr(path, '/');
if (!pend) pend = path + strlen(path); if (!pend) pend = path + strlen(path);
return extract_path(path, pend); return extract_path(path, pend);
@ -577,8 +575,8 @@ rb_glob(path, func, arg)
p = path; p = path;
while (p) { while (p) {
if (isdirsep(*p)) p++; if (*p == '/') p++;
m = find_dirsep(p); m = strchr(p, '/');
if (has_magic(p, m)) { if (has_magic(p, m)) {
char *dir, *base, *magic, *buf; char *dir, *base, *magic, *buf;
DIR *dirp; DIR *dirp;
@ -607,7 +605,7 @@ rb_glob(path, func, arg)
free(base); free(base);
break; break;
} }
#define BASE (*base && !(isdirsep(*base) && !base[1])) #define BASE (*base && !(*base == '/' && !base[1]))
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
if (recursive) { if (recursive) {

View File

@ -873,13 +873,18 @@ NtCmdGlob (NtCmdLineElement *patt)
{ {
ListInfo listinfo; ListInfo listinfo;
char buffer[MAXPATHLEN], *buf = buffer; char buffer[MAXPATHLEN], *buf = buffer;
char *p, *pend, *pb;
listinfo.head = listinfo.tail = 0; listinfo.head = listinfo.tail = 0;
if (patt->len >= MAXPATHLEN) if (patt->len >= MAXPATHLEN)
buf = ruby_xmalloc(patt->len + 1); buf = ruby_xmalloc(patt->len + 1);
strncpy(buf, patt->str, patt->len); p = patt->str;
pend = p + patt->len;
pb = buf;
for (; p < pend; p = CharNext(p))
*pb++ = *p == '\\' ? '/' : *p;
buf[patt->len] = 0; buf[patt->len] = 0;
rb_glob(buf, insert, (VALUE)&listinfo); rb_glob(buf, insert, (VALUE)&listinfo);
if (buf != buffer) if (buf != buffer)