From 18a305d673e868865ec3e03c02cf20c61a5e49cb Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Mon, 9 Jul 2018 12:22:16 -0400 Subject: [PATCH] refactor so that WSAStartup call happens on Windows regardless of gui mode --- pd/src/s_inter.c | 9 --------- pd/src/s_main.c | 8 +++++++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pd/src/s_inter.c b/pd/src/s_inter.c index ffaf86513..61bc9d940 100644 --- a/pd/src/s_inter.c +++ b/pd/src/s_inter.c @@ -1231,10 +1231,6 @@ int sys_startgui(const char *guidir) if (!getcwd(cwd, FILENAME_MAX)) strcpy(cwd, "."); #endif -#ifdef MSW - short version = MAKEWORD(2, 0); - WSADATA nobby; -#endif #ifdef HAVE_UNISTD_H int stdinpipe[2]; #endif @@ -1242,11 +1238,6 @@ int sys_startgui(const char *guidir) sys_fdpoll = (t_fdpoll *)t_getbytes(0); sys_nfdpoll = 0; inbinbuf = binbuf_new(); - -#ifdef MSW - if (WSAStartup(version, &nobby)) sys_sockerror("WSAstartup"); -#endif - if (sys_nogui) { /* fake the GUI's message giving cwd and font sizes; then diff --git a/pd/src/s_main.c b/pd/src/s_main.c index 41ee4e19a..03823ece9 100644 --- a/pd/src/s_main.c +++ b/pd/src/s_main.c @@ -335,9 +335,15 @@ int sys_main(int argc, char **argv) #ifdef PD_DEBUG fprintf(stderr, "Pd-L2Ork: COMPILED FOR DEBUGGING\n"); #endif + /* We need to call WSAStartup regardless of gui mode, since a user + * might want to make socket connections even in -nogui mode. So we + * go ahead and do that here. */ +#ifdef _WIN32 + short version = MAKEWORD(2, 0); + WSADATA nobby; + if (WSAStartup(version, &nobby)) sys_sockerror("WSAstartup"); /* use Win32 "binary" mode by default since we don't want the * translation that Win32 does by default */ -#ifdef _WIN32 # ifdef _MSC_VER /* MS Visual Studio */ _set_fmode( _O_BINARY ); # else /* MinGW */ -- GitLab