summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-08 08:36:44 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-08 08:36:44 +0000
commitc30183b3b99052c0c0cacf0b46ec297c199a597a (patch)
tree0ab4b2f526d999accb3ebcde13bf9d6a80034a8c
parent887e1011c3df922cb83e86f5adae852cc06fb481 (diff)
* win32/win32.c (rb_w32_opendir): store attributes of the second
entries or later too. * win32/win32.c (rb_w32_opendir, rb_w32_readdir): eliminate magic numbers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@12481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--version.h2
-rw-r--r--win32/win32.c59
3 files changed, 36 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ee7d4a0f3..30b68513ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue May 29 11:01:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * win32/win32.c (rb_w32_opendir): store attributes of the second
+ entries or later too.
+
+ * win32/win32.c (rb_w32_opendir, rb_w32_readdir): eliminate magic
+ numbers.
+
Thu Jun 7 20:10:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c, intern.h, ext/thread/thread.c: should not free queue
diff --git a/version.h b/version.h
index b9c58d5581..e0aca32fb1 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2007-06-07"
#define RUBY_VERSION_CODE 186
#define RUBY_RELEASE_CODE 20070607
-#define RUBY_PATCHLEVEL 31
+#define RUBY_PATCHLEVEL 32
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
diff --git a/win32/win32.c b/win32/win32.c
index 99cec1cc93..606f4bf820 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -81,8 +81,6 @@
#define TO_SOCKET(x) _get_osfhandle(x)
-bool NtSyncProcess = TRUE;
-
static struct ChildRecord *CreateChild(const char *, const char *, SECURITY_ATTRIBUTES *, HANDLE, HANDLE, HANDLE);
static bool has_redirection(const char *);
static void StartSockets ();
@@ -502,26 +500,6 @@ FindFreeChildSlot(void)
}
-int
-SafeFree(char **vec, int vecc)
-{
- // vec
- // |
- // V ^---------------------V
- // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
- // | | | .... | NULL | | ..... |\0 | | ..... |\0 |...
- // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
- // |- elements+1 -| ^ 1st element ^ 2nd element
-
- char *p;
-
- p = (char *)vec;
- free(p);
-
- return 0;
-}
-
-
/*
ruby -lne 'BEGIN{$cmds = Hash.new(0); $mask = 1}'
-e '$cmds[$_.downcase] |= $mask' -e '$mask <<= 1 if ARGF.eof'
@@ -1423,8 +1401,12 @@ rb_w32_cmdvector(const char *cmd, char ***vec)
// return the pointer to the current file name.
//
-#define GetBit(bits, i) ((bits)[(i) / 8] & (1 << (i) % 8))
-#define SetBit(bits, i) ((bits)[(i) / 8] |= (1 << (i) % 8))
+#define GetBit(bits, i) ((bits)[(i) / CHAR_BIT] & (1 << (i) % CHAR_BIT))
+#define SetBit(bits, i) ((bits)[(i) / CHAR_BIT] |= (1 << (i) % CHAR_BIT))
+
+#define BitOfIsDir(n) ((n) * 2)
+#define BitOfIsRep(n) ((n) * 2 + 1)
+#define DIRENT_PER_CHAR (CHAR_BIT / 2)
DIR *
rb_w32_opendir(const char *filename)
@@ -1497,9 +1479,9 @@ rb_w32_opendir(const char *filename)
strcpy(p->start, fd.cFileName);
p->bits[0] = 0;
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- SetBit(p->bits, 0);
+ SetBit(p->bits, BitOfIsDir(0));
if (fd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
- SetBit(p->bits, 1);
+ SetBit(p->bits, BitOfIsRep(0));
p->nfiles++;
//
@@ -1511,21 +1493,34 @@ rb_w32_opendir(const char *filename)
while (FindNextFile(fh, &fd)) {
char *newpath;
- len = strlen(fd.cFileName);
+ len = strlen(fd.cFileName) + 1;
//
// bump the string table size by enough for the
// new name and it's null terminator
//
- newpath = (char *)realloc(p->start, idx+len+1);
+ newpath = (char *)realloc(p->start, idx + len);
if (newpath == NULL) {
goto error;
}
p->start = newpath;
strcpy(&p->start[idx], fd.cFileName);
+
+ if (p->nfiles % DIRENT_PER_CHAR == 0) {
+ char *tmp = realloc(p->bits, p->nfiles / DIRENT_PER_CHAR + 1);
+ if (!tmp)
+ goto error;
+ p->bits = tmp;
+ p->bits[p->nfiles / DIRENT_PER_CHAR] = 0;
+ }
+ if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ SetBit(p->bits, BitOfIsDir(p->nfiles));
+ if (fd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
+ SetBit(p->bits, BitOfIsRep(p->nfiles));
+
p->nfiles++;
- idx += len+1;
+ idx += len;
}
FindClose(fh);
p->size = idx;
@@ -1576,8 +1571,8 @@ rb_w32_readdir(DIR *dirp)
//
// Attributes
//
- dirp->dirstr.d_isdir = GetBit(dirp->bits, dirp->loc * 2);
- dirp->dirstr.d_isrep = GetBit(dirp->bits, dirp->loc * 2 + 1);
+ dirp->dirstr.d_isdir = GetBit(dirp->bits, BitOfIsDir(dirp->loc));
+ dirp->dirstr.d_isrep = GetBit(dirp->bits, BitOfIsRep(dirp->loc));
//
// Now set up for the next call to readdir
@@ -2698,7 +2693,7 @@ poll_child_status(struct ChildRecord *child, int *stat_loc)
}
rb_pid_t
-waitpid (rb_pid_t pid, int *stat_loc, int options)
+waitpid(rb_pid_t pid, int *stat_loc, int options)
{
DWORD timeout;