Project

General

Profile

Bug #1260 ยป win32.patch

cfis (Charlie Savage), 03/10/2009 05:01 PM

View differences:

win32/win32.c (working copy)
#include <mbstring.h>
#if _MSC_VER >= 1400
#include <crtdbg.h>
#include <rtcapi.h>
#endif
#ifdef __MINGW32__
#include <mswsock.h>
......
return NULL;
if (!(sbuf.st_mode & S_IFDIR) &&
(!ISALPHA(filename[0]) || filename[1] != ':' || filename[2] != '\0' ||
((1 << (filename[0] & 0x5f) - 'A') & GetLogicalDrives()) == 0)) {
((1 << ((filename[0] & 0x5f) - 'A')) & GetLogicalDrives()) == 0)) {
errno = ENOTDIR;
return NULL;
}
......
static int
extract_fd(rb_fdset_t *dst, fd_set *src, int (*func)(SOCKET))
{
int s = 0;
unsigned int s = 0;
if (!src || !dst) return 0;
while (s < src->fd_count) {
SOCKET fd = src->fd_array[s];
if (!func || (*func)(fd)) { /* move it to dst */
int d;
unsigned int d;
for (d = 0; d < dst->fdset->fd_count; d++) {
if (dst->fdset->fd_array[d] == fd)
......
static int
copy_fd(fd_set *dst, fd_set *src)
{
int s;
unsigned int s;
if (!src || !dst) return 0;
for (s = 0; s < src->fd_count; ++s) {
SOCKET fd = src->fd_array[s];
int d;
unsigned int d;
for (d = 0; d < dst->fd_count; ++d) {
if (dst->fd_array[d] == fd)
break;
......
rb_w32_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex,
struct timeval *timeout)
{
int r;
unsigned int r;
rb_fdset_t pipe_rd;
rb_fdset_t cons_rd;
rb_fdset_t else_rd;
......
if (pid == -1) {
int count = 0;
DWORD ret;
int ret;
HANDLE events[MAXCHILDNUM];
FOREACH_CHILD(child) {
......
lt /= 10; /* to usec */
lt -= (LONG_LONG)((1970-1601)*365.2425) * 24 * 60 * 60 * 1000 * 1000;
tv->tv_sec = lt / (1000 * 1000);
tv->tv_sec = (long)(lt / (1000 * 1000));
tv->tv_usec = lt % (1000 * 1000);
return tv->tv_sec > 0 ? 0 : -1;
......
CloseHandle(ol.hEvent);
if (!(_osfile(fd) & (FDEV | FPIPE))) {
LONG high = ol.OffsetHigh;
LONG low = ol.Offset + read;
DWORD high = ol.OffsetHigh;
DWORD low = ol.Offset + read;
if (low < ol.Offset)
++high;
SetFilePointer((HANDLE)_osfhnd(fd), low, &high, FILE_BEGIN);
......
CloseHandle(ol.hEvent);
if (!(_osfile(fd) & (FDEV | FPIPE))) {
LONG high = ol.OffsetHigh;
LONG low = ol.Offset + written;
DWORD high = ol.OffsetHigh;
DWORD low = ol.Offset + written;
if (low < ol.Offset)
++high;
SetFilePointer((HANDLE)_osfhnd(fd), low, &high, FILE_BEGIN);
    (1-1/1)