зеркало из https://github.com/github/ruby.git
* win32/win32.c (rb_w32_opendir): removed duplicated code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
d64609463f
Коммит
82159c813b
|
@ -1,3 +1,7 @@
|
||||||
|
Tue May 29 12:31:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* win32/win32.c (rb_w32_opendir): removed duplicated code.
|
||||||
|
|
||||||
Tue May 29 10:55:24 2007 Koichi Sasada <ko1@atdot.net>
|
Tue May 29 10:55:24 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* cont.c: fix bug around Continuation and Fiber.
|
* cont.c: fix bug around Continuation and Fiber.
|
||||||
|
|
|
@ -1447,25 +1447,7 @@ rb_w32_opendir(const char *filename)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
idx = 0;
|
||||||
// now allocate the first part of the string table for the
|
|
||||||
// filenames that we find.
|
|
||||||
//
|
|
||||||
idx = strlen(fd.cFileName)+1;
|
|
||||||
if (!(p->start = (char *)malloc(idx)) || !(p->bits = (char *)malloc(1))) {
|
|
||||||
error:
|
|
||||||
rb_w32_closedir(p);
|
|
||||||
FindClose(fh);
|
|
||||||
errno = ENOMEM;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
strlcpy(p->start, fd.cFileName, idx);
|
|
||||||
p->bits[0] = 0;
|
|
||||||
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
||||||
SetBit(p->bits, BitOfIsDir(0));
|
|
||||||
if (fd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
|
||||||
SetBit(p->bits, BitOfIsRep(0));
|
|
||||||
p->nfiles++;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// loop finding all the files that match the wildcard
|
// loop finding all the files that match the wildcard
|
||||||
|
@ -1473,7 +1455,7 @@ rb_w32_opendir(const char *filename)
|
||||||
// the variable idx should point one past the null terminator
|
// the variable idx should point one past the null terminator
|
||||||
// of the previous string found.
|
// of the previous string found.
|
||||||
//
|
//
|
||||||
while (FindNextFile(fh, &fd)) {
|
do {
|
||||||
len = strlen(fd.cFileName) + 1;
|
len = strlen(fd.cFileName) + 1;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1481,8 +1463,14 @@ rb_w32_opendir(const char *filename)
|
||||||
// new name and it's null terminator
|
// new name and it's null terminator
|
||||||
//
|
//
|
||||||
tmp = realloc(p->start, idx + len);
|
tmp = realloc(p->start, idx + len);
|
||||||
if (!tmp)
|
if (!tmp) {
|
||||||
goto error;
|
error:
|
||||||
|
rb_w32_closedir(p);
|
||||||
|
FindClose(fh);
|
||||||
|
errno = ENOMEM;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
p->start = tmp;
|
p->start = tmp;
|
||||||
strlcpy(&p->start[idx], fd.cFileName, len);
|
strlcpy(&p->start[idx], fd.cFileName, len);
|
||||||
|
|
||||||
|
@ -1500,7 +1488,7 @@ rb_w32_opendir(const char *filename)
|
||||||
|
|
||||||
p->nfiles++;
|
p->nfiles++;
|
||||||
idx += len;
|
idx += len;
|
||||||
}
|
} while (FindNextFile(fh, &fd));
|
||||||
FindClose(fh);
|
FindClose(fh);
|
||||||
p->size = idx;
|
p->size = idx;
|
||||||
p->curr = p->start;
|
p->curr = p->start;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче