From 9eacdd9372f87d41209921503477c960b8bfbc2e Mon Sep 17 00:00:00 2001 From: Sojourner Truth <jon.w.wilkes@gmail.com> Date: Sun, 10 Jul 2016 17:37:40 -0400 Subject: [PATCH] Try to escape spaces and carets for the spawnl call in Windows --- pd/src/s_inter.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pd/src/s_inter.c b/pd/src/s_inter.c index cbae4754e..02d77c260 100644 --- a/pd/src/s_inter.c +++ b/pd/src/s_inter.c @@ -1407,6 +1407,8 @@ fprintf(stderr, "guidir is %s\n", guidir); #endif /* HAVE_UNISTD_H */ #ifdef MSW + char escaped_scriptbuf[FILENAME_MAX]; + int i, escaped_len; /* in MSW land "guipath" is unused; we just do everything from the libdir. */ /* fprintf(stderr, "%s\n", sys_libdir->s_name); */ @@ -1426,14 +1428,30 @@ fprintf(stderr, "guidir is %s\n", guidir); strcat(wishbuf, "/" PDBINDIR "nw/nw"); sys_bashfilename(wishbuf, wishbuf); - spawnret = _spawnl(P_NOWAIT, wishbuf, "pd-nw", scriptbuf, portbuf, + for (i = 0, escaped_len = 0; i < strlen(scriptbuf); i++) + { + if (escaped_len > (FILENAME_MAX - 3)) + { + fprintf(stderr, "%s: path to GUI is too long\n"); + exit(1); + } + if (scriptbuf[i] == ' ' || + scriptbuf[i] == '^') + { + escaped_scriptbuf[escaped_len++] = '^'; + } + escaped_scriptbuf[escaped_len++] = scriptbuf[i]; + } + escaped_scriptbuf[escaped_len] = '\0'; + spawnret = _spawnl(P_NOWAIT, wishbuf, "pd-nw", escaped_scriptbuf, + portbuf, "localhost", (sys_k12_mode ? "pd-l2ork-k12" : "pd-l2ork"), scriptbuf, 0); if (spawnret < 0) { perror("spawnl"); - fprintf(stderr, "%s: couldn't load TCL\n", wishbuf); + fprintf(stderr, "%s: couldn't load GUI\n", wishbuf); exit(1); } -- GitLab