diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2025-03-12 12:04:59 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2025-03-12 15:38:28 +0100 |
commit | d63b52e059a7d77b98a2ef005920a85feb1e2446 (patch) | |
tree | bc3f8f9879d5b32aadaa0835508741a1b07471f0 /libphobos/src/std/process.d | |
parent | 6e4045513d789587b2c7750e9016c7035b461299 (diff) | |
download | gcc-d63b52e059a7d77b98a2ef005920a85feb1e2446.zip gcc-d63b52e059a7d77b98a2ef005920a85feb1e2446.tar.gz gcc-d63b52e059a7d77b98a2ef005920a85feb1e2446.tar.bz2 |
libphobos: Merge upstream phobos 0faae92d6
Phobos changes:
- Import phobos v2.111.0-beta.1.
- Added `bitCast' function to `std.conv'.
- Added `readfln' and `File.readfln' functions to `std.stdio'.
- New procedural API for `std.sumtype'.
libphobos/ChangeLog:
* src/MERGE: Merge upstream phobos 0faae92d6.
* testsuite/libphobos.phobos/std_array.d: Regenerate.
* testsuite/libphobos.phobos/std_conv.d: Regenerate.
* testsuite/libphobos.phobos/std_functional.d: Regenerate.
* testsuite/libphobos.phobos/std_sumtype.d: Regenerate.
Diffstat (limited to 'libphobos/src/std/process.d')
-rw-r--r-- | libphobos/src/std/process.d | 60 |
1 files changed, 10 insertions, 50 deletions
diff --git a/libphobos/src/std/process.d b/libphobos/src/std/process.d index ca7880b..1a020c8 100644 --- a/libphobos/src/std/process.d +++ b/libphobos/src/std/process.d @@ -4315,14 +4315,14 @@ version (Posix) import core.sys.posix.stdlib; } -private void toAStringz(in string[] a, const(char)**az) +private const(char)** toAStringz(in string[] a) { import std.string : toStringz; - foreach (string s; a) - { - *az++ = toStringz(s); - } - *az = null; + auto p = (new const(char)*[1 + a.length]).ptr; + foreach (i, string s; a) + p[i] = toStringz(s); + p[a.length] = null; + return p; } @@ -4452,45 +4452,17 @@ extern(C) private int execv_(in string pathname, in string[] argv) { - import core.exception : OutOfMemoryError; - import std.exception : enforce; - auto argv_ = cast(const(char)**)core.stdc.stdlib.malloc((char*).sizeof * (1 + argv.length)); - enforce!OutOfMemoryError(argv_ !is null, "Out of memory in std.process."); - scope(exit) core.stdc.stdlib.free(argv_); - - toAStringz(argv, argv_); - - return execv(pathname.tempCString(), argv_); + return execv(pathname.tempCString(), toAStringz(argv)); } private int execve_(in string pathname, in string[] argv, in string[] envp) { - import core.exception : OutOfMemoryError; - import std.exception : enforce; - auto argv_ = cast(const(char)**)core.stdc.stdlib.malloc((char*).sizeof * (1 + argv.length)); - enforce!OutOfMemoryError(argv_ !is null, "Out of memory in std.process."); - scope(exit) core.stdc.stdlib.free(argv_); - auto envp_ = cast(const(char)**)core.stdc.stdlib.malloc((char*).sizeof * (1 + envp.length)); - enforce!OutOfMemoryError(envp_ !is null, "Out of memory in std.process."); - scope(exit) core.stdc.stdlib.free(envp_); - - toAStringz(argv, argv_); - toAStringz(envp, envp_); - - return execve(pathname.tempCString(), argv_, envp_); + return execve(pathname.tempCString(), toAStringz(argv), toAStringz(envp)); } private int execvp_(in string pathname, in string[] argv) { - import core.exception : OutOfMemoryError; - import std.exception : enforce; - auto argv_ = cast(const(char)**)core.stdc.stdlib.malloc((char*).sizeof * (1 + argv.length)); - enforce!OutOfMemoryError(argv_ !is null, "Out of memory in std.process."); - scope(exit) core.stdc.stdlib.free(argv_); - - toAStringz(argv, argv_); - - return execvp(pathname.tempCString(), argv_); + return execvp(pathname.tempCString(), toAStringz(argv)); } private int execvpe_(in string pathname, in string[] argv, in string[] envp) @@ -4532,19 +4504,7 @@ version (Posix) } else version (Windows) { - import core.exception : OutOfMemoryError; - import std.exception : enforce; - auto argv_ = cast(const(char)**)core.stdc.stdlib.malloc((char*).sizeof * (1 + argv.length)); - enforce!OutOfMemoryError(argv_ !is null, "Out of memory in std.process."); - scope(exit) core.stdc.stdlib.free(argv_); - auto envp_ = cast(const(char)**)core.stdc.stdlib.malloc((char*).sizeof * (1 + envp.length)); - enforce!OutOfMemoryError(envp_ !is null, "Out of memory in std.process."); - scope(exit) core.stdc.stdlib.free(envp_); - - toAStringz(argv, argv_); - toAStringz(envp, envp_); - - return execvpe(pathname.tempCString(), argv_, envp_); + return execvpe(pathname.tempCString(), toAStringz(argv), toAStringz(envp)); } else { |