aboutsummaryrefslogtreecommitdiffstats
path: root/nt/cmdproxy.c
diff options
context:
space:
mode:
authorNoam Postavsky2015-02-10 18:51:14 +0200
committerEli Zaretskii2015-02-10 18:51:14 +0200
commit680ee61d04e220e0b2eb4246c8f33773e0185852 (patch)
tree026af2929f7f38f4c1725208301de3f4f6a026e8 /nt/cmdproxy.c
parent4b0b27d0018f040bda6a2ec885fa54c666d9c083 (diff)
downloademacs-680ee61d04e220e0b2eb4246c8f33773e0185852.tar.gz
emacs-680ee61d04e220e0b2eb4246c8f33773e0185852.zip
Backport fix for bug#18745 from master.
nt/cmdproxy.c (batch_file_p): New function. (spawn): If calling a quoted batch file pass NULL for progname.
Diffstat (limited to 'nt/cmdproxy.c')
-rw-r--r--nt/cmdproxy.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/nt/cmdproxy.c b/nt/cmdproxy.c
index ce5815291df..16956288fef 100644
--- a/nt/cmdproxy.c
+++ b/nt/cmdproxy.c
@@ -243,6 +243,28 @@ get_next_token (char * buf, const char ** pSrc)
243 return o - buf; 243 return o - buf;
244} 244}
245 245
246/* Return TRUE if PROGNAME is a batch file. */
247BOOL
248batch_file_p (const char *progname)
249{
250 const char *exts[] = {".bat", ".cmd"};
251 int n_exts = sizeof (exts) / sizeof (char *);
252 int i;
253
254 const char *ext = strrchr (progname, '.');
255
256 if (ext)
257 {
258 for (i = 0; i < n_exts; i++)
259 {
260 if (stricmp (ext, exts[i]) == 0)
261 return TRUE;
262 }
263 }
264
265 return FALSE;
266}
267
246/* Search for EXEC file in DIR. If EXEC does not have an extension, 268/* Search for EXEC file in DIR. If EXEC does not have an extension,
247 DIR is searched for EXEC with the standard extensions appended. */ 269 DIR is searched for EXEC with the standard extensions appended. */
248int 270int
@@ -524,6 +546,13 @@ spawn (const char *progname, char *cmdline, const char *dir, int *retcode)
524 memset (&start, 0, sizeof (start)); 546 memset (&start, 0, sizeof (start));
525 start.cb = sizeof (start); 547 start.cb = sizeof (start);
526 548
549 /* CreateProcess handles batch files as progname specially. This
550 special handling fails when both the batch file and arguments are
551 quoted. We pass NULL as progname to avoid the special
552 handling. */
553 if (progname != NULL && cmdline[0] == '"' && batch_file_p (progname))
554 progname = NULL;
555
527 if (CreateProcess (progname, cmdline, &sec_attrs, NULL, TRUE, 556 if (CreateProcess (progname, cmdline, &sec_attrs, NULL, TRUE,
528 0, envblock, dir, &start, &child)) 557 0, envblock, dir, &start, &child))
529 { 558 {