guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: c-api.test fails on MS-Windows due to non-portable quoting


From: Eli Zaretskii
Subject: Re: c-api.test fails on MS-Windows due to non-portable quoting
Date: Sat, 13 Aug 2016 14:55:27 +0300

> Date: Sat, 13 Aug 2016 12:11:33 +0300
> From: Eli Zaretskii <address@hidden>
> Cc: address@hidden, address@hidden
> 
> > From: Mark H Weaver <address@hidden>
> > Cc: address@hidden,  address@hidden
> > Date: Wed, 10 Aug 2016 13:03:09 -0400
> > 
> > Eli Zaretskii <address@hidden> writes:
> > 
> > >> Date: Wed, 10 Aug 2016 17:26:15 +0300
> > >> From: Eli Zaretskii <address@hidden>
> > >> Cc: address@hidden, address@hidden
> > >> 
> > >> If you suggest to do what I described above, then I obviously agree.
> > >
> > > IOW, do you want me to send a patch along the lines I suggested?
> > 
> > Yes, please!
> 
> Will do when I have enough time (correctly quoting command-line
> arguments on Windows is a tricky business).

On further thought, I decided to reuse code we already have, rather
than write something new.  Is the approach below acceptable?  If it
is, I will post it in Git format wrt the current repo.

--- libguile/simpos.c~0 2016-01-02 16:24:55.000000000 +0200
+++ libguile/simpos.c   2016-08-13 13:56:43.014875000 +0300
@@ -45,12 +45,12 @@
 # include <sys/wait.h>
 #endif
 
+#include "posix.h"
+
 #ifdef __MINGW32__
-# include <process.h>  /* for spawnvp and friends */
+#include "posix-w32.h"
 #endif
 
-#include "posix.h"
-
 
 extern int system();
 
@@ -124,9 +124,9 @@ SCM_DEFINE (scm_system_star, "system*", 
       SCM oldquit;
       SCM sigquit;
 #endif
-#ifdef HAVE_FORK
       int pid;
-#else
+#ifndef HAVE_FORK
+      int p1[2], p2[2];
       int status;
 #endif
       char **execargv;
@@ -177,7 +177,21 @@ SCM_DEFINE (scm_system_star, "system*", 
           return scm_from_int (status);
         }
 #else  /* !HAVE_FORK */
+#ifdef __MINGW32__
+      /* MS-Windows spawnvp needs execargv[] strings quoted if they
+        include special characters, like whitespace.  The required
+        quoting is non-trivial, and also depends on whether
+        execargv[0] is cmd.exe.  So we invoke start_child instead,
+        which already has all that figured out.  */
+      pid = start_child (execargv[0], execargv, 0, p1, 0, p2,
+                        fileno (stdin), fileno (stdout), fileno (stderr));
+      if (pid == -1)
+        SCM_SYSERROR;
+
+      waitpid (pid, &status, 0);
+#else
       status = spawnvp (P_WAIT, execargv[0], (const char * const *)execargv);
+#endif
       scm_sigaction (sigint, SCM_CAR (oldint), SCM_CDR (oldint));
 #ifdef SIGQUIT
       scm_sigaction (sigquit, SCM_CAR (oldquit), SCM_CDR (oldquit));



reply via email to

[Prev in Thread] Current Thread [Next in Thread]