summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
Diffstat (limited to 'win32')
-rw-r--r--win32/Makefile.sub4
-rw-r--r--win32/config.h.in1
-rw-r--r--win32/config.status.in4
-rw-r--r--win32/dir.h20
-rw-r--r--win32/resource.rb2
-rw-r--r--win32/win32.c91
-rw-r--r--win32/win32.h2
7 files changed, 102 insertions, 22 deletions
diff --git a/win32/Makefile.sub b/win32/Makefile.sub
index 227ab68b18..42100a5d92 100644
--- a/win32/Makefile.sub
+++ b/win32/Makefile.sub
@@ -30,13 +30,13 @@ AUTOCONF = autoconf
prefix = /usr
-CFLAGS = -nologo -DNT=1 -Zi -MD -O2b2x -G5
+CFLAGS = -nologo -DNT=1 -Zi -MD -O2b2xg- -G5
CPPFLAGS = -I$(srcdir) -I$(srcdir)/missing
LDFLAGS = $(CFLAGS) -Fm
XLDFLAGS =
#EXTLIBS =
LIBS = user32.lib advapi32.lib wsock32.lib $(EXTLIBS)
-MISSING = crypt.obj alloca.obj win32.obj isinf.obj isnan.obj
+MISSING = crypt.obj win32.obj isinf.obj isnan.obj
LDSHARED =
DLDFLAGS =
SOLIBS =
diff --git a/win32/config.h.in b/win32/config.h.in
index a7e28120e6..f1ba8da5c3 100644
--- a/win32/config.h.in
+++ b/win32/config.h.in
@@ -1,6 +1,7 @@
#define HAVE_PROTOTYPES 1
#define HAVE_STDARG_PROTOTYPES 1
/* #define HAVE_ATTR_NORETURN 1 */
+#define inline __inline
/* #define HAVE_DIRENT_H 1 */
/* #define HAVE_UNISTD_H 1 */
#define HAVE_STDLIB_H 1
diff --git a/win32/config.status.in b/win32/config.status.in
index 461877b886..f337d97b35 100644
--- a/win32/config.status.in
+++ b/win32/config.status.in
@@ -3,8 +3,6 @@ s%@CFLAGS@%-nologo -DNT=1 -Zi -MD -O2b2x -G5%g
s%@CPPFLAGS@%%g
s%@CXXFLAGS@%%g
s%@FFLAGS@%%g
-s%@DEFS@%
- -DUSE_THREAD -DSIZEOF_INT=4 -DSIZEOF_SHORT=2 -DSIZEOF_LONG=4 -DSIZEOF_VOIDP=4 -DSIZEOF_FLOAT=4 -DSIZEOF_DOUBLE=8 -DHAVE_PROTOTYPES=1 -DHAVE_STDARG_PROTOTYPES=1 -DHAVE_STDLIB_H=1 -DHAVE_LIMITS_H=1 -DHAVE_FCNTL_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ST_RDEV=1 -DGETGROUPS_T=int -DRETSIGTYPE=void -DHAVE_ALLOCA=1 -DHAVE_FMOD=1 -DHAVE_WAITPID=1 -DHAVE_GETCWD=1 -DHAVE_CHSIZE=1 -DHAVE_GETGROUPS=1 -DHAVE_GETLOGIN=1 -DRSHIFT=\(x,y\)\ \(\(x\)\>\>y\) -DFILE_COUNT=_cnt -DDLEXT=\".so\" -DDLEXT2=\".dll\" -DRUBY_PLATFORM=\"i586-mswin32\" %g
s%@LDFLAGS@%-nologo%g
s%@LIBS@%user32.lib advapi32.lib wsock32.lib%g
s%@exec_prefix@%${prefix}%g
@@ -34,7 +32,7 @@ s%@RANLIB@%rem%g
s%@AR@%lib -nologo%g
s%@LN_S@%%g
s%@SET_MAKE@%%g
-s%@LIBOBJS@% crypt.obj alloca.obj win32.obj isinf.obj isnan.obj%g
+s%@LIBOBJS@% crypt.obj win32.obj isinf.obj isnan.obj%g
s%@ALLOCA@%%g
s%@DEFAULT_KCODE@%%g
s%@EXEEXT@%.exe%g
diff --git a/win32/dir.h b/win32/dir.h
new file mode 100644
index 0000000000..8aa793de42
--- /dev/null
+++ b/win32/dir.h
@@ -0,0 +1,20 @@
+struct direct
+{
+ long d_namlen;
+ ino_t d_ino;
+ char d_name[256];
+};
+typedef struct {
+ char *start;
+ char *curr;
+ long size;
+ long nfiles;
+ struct direct dirstr;
+} DIR;
+
+DIR* opendir(const char*);
+struct direct* readdir(DIR *);
+long telldir(DIR *);
+void seekdir(DIR *, long);
+void rewinddir(DIR *);
+void closedir(DIR *);
diff --git a/win32/resource.rb b/win32/resource.rb
index d25c26e8f5..9222b829a4 100644
--- a/win32/resource.rb
+++ b/win32/resource.rb
@@ -75,7 +75,7 @@ BEGIN
VALUE "FileVersion", "#{fversion}\\0"
VALUE "Home Page", "http://www.ruby-lang.org/\\0"
VALUE "InternalName", "#{base + ext}\\0"
- VALUE "LegalCopyright", "Copyright (C) 1993-2000 Yukihiro Matsumoto\\0"
+ VALUE "LegalCopyright", "Copyright (C) 1993-2001 Yukihiro Matsumoto\\0"
VALUE "OriginalFilename", "#{base + ext}\\0"
VALUE "Platform", "#{RUBY_PLATFORM}\\0"
VALUE "ProductVersion", "#{fversion}\\0"
diff --git a/win32/win32.c b/win32/win32.c
index bd07bb644e..9fb120e09d 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -29,6 +29,7 @@
#ifndef index
#define index(x, y) strchr((x), (y))
#endif
+#define isdirsep(x) ((x) == '/' || (x) == '\\')
#ifndef bool
#define bool int
@@ -357,7 +358,7 @@ isInternalCmd(char *cmd)
int vecc = NtMakeCmdVector(cmd, &vec, FALSE);
for( i = 0; szInternalCmds[i] ; i++){
- if(!strcmp(szInternalCmds[i], vec[0])){
+ if(!strcasecmp(szInternalCmds[i], vec[0])){
fRet = 1;
break;
}
@@ -777,10 +778,10 @@ char *cmd;
strcpy(cmd2, cmd);
a = argv;
for (s = cmd2; *s;) {
- while (*s && isspace(*s)) s++;
+ while (*s && ISSPACE(*s)) s++;
if (*s)
*(a++) = s;
- while (*s && !isspace(*s)) s++;
+ while (*s && !ISSPACE(*s)) s++;
if (*s)
*s++ = '\0';
}
@@ -1054,7 +1055,7 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
//
ptr = cmdline+(cmdlen - 1);
- while(ptr >= cmdline && isspace(*ptr))
+ while(ptr >= cmdline && ISSPACE(*ptr))
--ptr;
*++ptr = '\0';
@@ -1074,7 +1075,7 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
// zap any leading whitespace
//
- while(isspace(*ptr))
+ while(ISSPACE(*ptr))
ptr++;
base = ptr;
@@ -1277,7 +1278,6 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
}
-#if !defined __MINGW32__
//
// UNIX compatible directory access functions for NT
//
@@ -1309,9 +1309,9 @@ opendir(char *filename)
// check to see if we\'ve got a directory
//
- if ((stat (filename, &sbuf) < 0 ||
+ if ((win32_stat (filename, &sbuf) < 0 ||
sbuf.st_mode & _S_IFDIR == 0) &&
- (!isalpha(filename[0]) || filename[1] != ':' || filename[2] != '\0' ||
+ (!ISALPHA(filename[0]) || filename[1] != ':' || filename[2] != '\0' ||
((1 << (filename[0] & 0x5f) - 'A') & GetLogicalDrives()) == 0)) {
return NULL;
}
@@ -1466,7 +1466,6 @@ closedir(DIR *dirp)
free(dirp->start);
free(dirp);
}
-#endif
//
@@ -2425,13 +2424,23 @@ waitpid (pid_t pid, int *stat_loc, int options)
int _cdecl
gettimeofday(struct timeval *tv, struct timezone *tz)
{
- struct timeb tb;
+ SYSTEMTIME st;
+ time_t t;
+ struct tm tm;
+
+ GetLocalTime(&st);
+ tm.tm_sec = st.wSecond;
+ tm.tm_min = st.wMinute;
+ tm.tm_hour = st.wHour;
+ tm.tm_mday = st.wDay;
+ tm.tm_mon = st.wMonth - 1;
+ tm.tm_year = st.wYear - 1900;
+ tm.tm_isdst = -1;
+ t = mktime(&tm);
+ tv->tv_sec = t;
+ tv->tv_usec = st.wMilliseconds * 1000;
- ftime(&tb);
- tv->tv_sec = tb.time;
- tv->tv_usec = tb.millitm * 1000;
-
- return 0;
+ return 0;
}
char *
@@ -2545,7 +2554,7 @@ myrename(const char *oldpath, const char *newpath)
newatts = GetFileAttributes(newpath);
if (oldatts == -1) {
- printf("file to move doesn't exist");
+ errno = GetLastError();
return -1;
}
@@ -2583,6 +2592,56 @@ myrename(const char *oldpath, const char *newpath)
return res;
}
+static int
+isUNCRoot(const char *path)
+{
+ if (path[0] == '\\' && path[1] == '\\') {
+ const char *p;
+ for (p = path + 3; *p; p = CharNext(p)) {
+ if (*p == '\\')
+ break;
+ }
+ if (p[0] && p[1]) {
+ for (p++; *p; p = CharNext(p)) {
+ if (*p == '\\')
+ break;
+ }
+ if (!p[0] || !p[1])
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
+win32_stat(const char *path, struct stat *st)
+{
+ const char *p;
+ char *buf1 = ALLOCA_N(char, strlen(path) + 1);
+ char *buf2 = ALLOCA_N(char, MAXPATHLEN);
+ char *s;
+ int len;
+
+ for (p = path, s = buf1; *p; p++, s++) {
+ if (*p == '/')
+ *s = '\\';
+ else
+ *s = *p;
+ }
+ *s = '\0';
+ len = strlen(buf1);
+ p = CharPrev(buf1, buf1 + len);
+ if (isUNCRoot(buf1)) {
+ if (*p != '\\')
+ strcat(buf1, "\\");
+ } else if (*p == '\\' || *p == ':')
+ strcat(buf1, ".");
+ if (_fullpath(buf2, buf1, MAXPATHLEN))
+ return stat(buf2, st);
+ else
+ return -1;
+}
+
static long
filetime_to_clock(FILETIME *ft)
{
diff --git a/win32/win32.h b/win32/win32.h
index ebffc5c8ab..ffbe967703 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -162,6 +162,8 @@ extern "C++" {
#define pclose _pclose
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
+#undef rb_sys_stat
+#define rb_sys_stat win32_stat
/* these are defined in nt.c */
#ifdef __MINGW32__