2929#include < locale.h>
3030#include < signal.h>
3131#include < stdio.h>
32+ #if defined(_MSC_VER)
33+ #define snprintf _snprintf
34+ #endif
3235#include < stdlib.h>
33- #include < strings.h>
3436#include < string.h>
37+ #if !defined(_MSC_VER)
38+ #include < strings.h>
39+ #else
40+ #define strcasecmp _stricmp
41+ #endif
3542#include < limits.h> /* PATH_MAX */
3643#include < assert.h>
37- #include < unistd.h>
44+ #if !defined(_MSC_VER)
45+ #include < unistd.h> /* setuid, getuid */
46+ #else
47+ #include < direct.h>
48+ #define chdir _chdir
49+ #define getcwd _getcwd
50+ #include < process.h>
51+ #define getpid _getpid
52+ #endif
3853#include < errno.h>
3954#include < sys/types.h>
40- #include < unistd.h> /* setuid, getuid */
4155
42- #ifdef __MINGW32__
56+ #if defined( __MINGW32__) || defined(_MSC_VER)
4357# include < platform_win32.h> /* winapi_perror() */
4458# ifdef PTW32_STATIC_LIB
4559extern " C" {
@@ -69,13 +83,15 @@ extern "C" {
6983# include < node_stat_watcher.h>
7084# include < node_timer.h>
7185#endif
86+ #if !defined(_MSC_VER)
7287#include < node_child_process.h>
88+ #endif
7389#include < node_constants.h>
7490#include < node_stdio.h>
7591#include < node_javascript.h>
7692#include < node_version.h>
7793#include < node_string.h>
78- #ifdef HAVE_OPENSSL
94+ #if HAVE_OPENSSL
7995# include < node_crypto.h>
8096#endif
8197#include < node_script.h>
@@ -87,7 +103,7 @@ using namespace v8;
87103# ifdef __APPLE__
88104# include < crt_externs.h>
89105# define environ (*_NSGetEnviron ())
90- # else
106+ # elif !defined(_MSC_VER)
91107extern char **environ;
92108# endif
93109
@@ -2086,7 +2102,7 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
20862102 versions->Set (String::NewSymbol (" ares" ), String::New (ARES_VERSION_STR));
20872103 snprintf (buf, 20 , " %d.%d" , UV_VERSION_MAJOR, UV_VERSION_MINOR);
20882104 versions->Set (String::NewSymbol (" uv" ), String::New (buf));
2089- #ifdef HAVE_OPENSSL
2105+ #if HAVE_OPENSSL
20902106 // Stupid code to slice out the version string.
20912107 int c, l = strlen (OPENSSL_VERSION_TEXT);
20922108 for (i = 0 ; i < l; i++) {
@@ -2154,13 +2170,14 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
21542170 }
21552171
21562172 size_t size = 2 *PATH_MAX;
2157- char execPath[size];
2173+ char * execPath = new char [size];
21582174 if (uv_exepath (execPath, &size) != 0 ) {
21592175 // as a last ditch effort, fallback on argv[0] ?
21602176 process->Set (String::NewSymbol (" execPath" ), String::New (argv[0 ]));
21612177 } else {
21622178 process->Set (String::NewSymbol (" execPath" ), String::New (execPath, size));
21632179 }
2180+ delete [] execPath;
21642181
21652182
21662183 // define various internal methods
@@ -2531,7 +2548,7 @@ void EmitExit(v8::Handle<v8::Object> process) {
25312548
25322549int Start (int argc, char *argv[]) {
25332550
2534- #if defined __MINGW32__ && defined PTW32_STATIC_LIB
2551+ #if ( defined( __MINGW32__) || defined(_MSC_VER)) && defined( PTW32_STATIC_LIB)
25352552 pthread_win32_process_attach_np ();
25362553#endif
25372554
@@ -2568,7 +2585,7 @@ int Start(int argc, char *argv[]) {
25682585 V8::Dispose ();
25692586#endif // NDEBUG
25702587
2571- #if defined __MINGW32__ && defined PTW32_STATIC_LIB
2588+ #if ( defined( __MINGW32__) || defined(_MSC_VER)) && defined( PTW32_STATIC_LIB)
25722589 pthread_win32_process_detach_np ();
25732590#endif
25742591
0 commit comments