summaryrefslogtreecommitdiffstats
path: root/stream.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-03-16 00:09:30 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-03-16 00:10:42 -0700
commitaca7c64aa69a4e14a2dd57779cd206a5aa15f649 (patch)
tree6a700564ae7356241a9d29f5fe7fc8c4a0ae858e /stream.c
parentef14bd0e49bec4025b80bdc01638b7a34b7778de (diff)
downloadtxr-aca7c64aa69a4e14a2dd57779cd206a5aa15f649.tar.gz
txr-aca7c64aa69a4e14a2dd57779cd206a5aa15f649.tar.bz2
txr-aca7c64aa69a4e14a2dd57779cd206a5aa15f649.zip
* configure: Detect _wspawn* functions.
* stream.c (run): Implement using _wspawnvp on MinGW.
Diffstat (limited to 'stream.c')
-rw-r--r--stream.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/stream.c b/stream.c
index 14ec811b..338f62d8 100644
--- a/stream.c
+++ b/stream.c
@@ -2338,6 +2338,30 @@ static val run(val name, val args)
return status == 0 ? zero : nil;
}
}
+#elif HAVE_WSPAWN
+static val run(val command, val args)
+{
+ const wchar_t **wargv = 0;
+ val iter;
+ int i, nargs, status;
+
+ args = default_bool_arg(args);
+ nargs = c_num(length(args)) + 1;
+
+ wargv = (const wchar_t **) chk_malloc((nargs + 2) * sizeof *wargv);
+
+ for (i = 0, iter = cons(command, args); iter; i++, iter = cdr(iter))
+ wargv[i] = c_str(car(iter));
+ wargv[i] = 0;
+
+ status = _wspawnvp(_P_WAIT, c_str(command), wargv);
+
+ for (i = 0; i < nargs; i++)
+ free((void *) wargv[i]);
+ free((void *) wargv);
+
+ return (status < 0) ? nil : num(status);
+}
#else
static val run(val command, val args)
{