diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-11-25 02:20:08 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-25 02:20:08 -0500 |
| commit | 5a98dd42b38b9188cfb96c9ab57dc91af923029f (patch) | |
| tree | 5b48dea38aeb28cf82b9ee98092bad4aea004d90 /lib/std/process.zig | |
| parent | 69b780647abd14f0809a58006242397f3e94ac51 (diff) | |
| parent | 321726465d3151d80e651b0c3001177a3ef53fff (diff) | |
| download | zig-5a98dd42b38b9188cfb96c9ab57dc91af923029f.tar.gz zig-5a98dd42b38b9188cfb96c9ab57dc91af923029f.zip | |
Merge pull request #3728 from ziglang/null-terminated-pointers
sentinel-terminated pointers
Diffstat (limited to 'lib/std/process.zig')
| -rw-r--r-- | lib/std/process.zig | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/std/process.zig b/lib/std/process.zig index fca10a240d..9880108465 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -77,7 +77,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap { // TODO: Verify that the documentation is incorrect // https://github.com/WebAssembly/WASI/issues/27 - var environ = try allocator.alloc(?[*]u8, environ_count + 1); + var environ = try allocator.alloc(?[*:0]u8, environ_count + 1); defer allocator.free(environ); var environ_buf = try std.heap.wasm_allocator.alloc(u8, environ_buf_size); defer allocator.free(environ_buf); @@ -397,7 +397,7 @@ pub fn argsAlloc(allocator: *mem.Allocator) ![][]u8 { return os.unexpectedErrno(args_sizes_get_ret); } - var argv = try allocator.alloc([*]u8, count); + var argv = try allocator.alloc([*:0]u8, count); defer allocator.free(argv); var argv_buf = try allocator.alloc(u8, buf_size); @@ -473,14 +473,14 @@ pub fn argsFree(allocator: *mem.Allocator, args_alloc: []const []u8) void { } test "windows arg parsing" { - testWindowsCmdLine(c"a b\tc d", [_][]const u8{ "a", "b", "c", "d" }); - testWindowsCmdLine(c"\"abc\" d e", [_][]const u8{ "abc", "d", "e" }); - testWindowsCmdLine(c"a\\\\\\b d\"e f\"g h", [_][]const u8{ "a\\\\\\b", "de fg", "h" }); - testWindowsCmdLine(c"a\\\\\\\"b c d", [_][]const u8{ "a\\\"b", "c", "d" }); - testWindowsCmdLine(c"a\\\\\\\\\"b c\" d e", [_][]const u8{ "a\\\\b c", "d", "e" }); - testWindowsCmdLine(c"a b\tc \"d f", [_][]const u8{ "a", "b", "c", "\"d", "f" }); - - testWindowsCmdLine(c"\".\\..\\zig-cache\\build\" \"bin\\zig.exe\" \".\\..\" \".\\..\\zig-cache\" \"--help\"", [_][]const u8{ + testWindowsCmdLine("a b\tc d", [_][]const u8{ "a", "b", "c", "d" }); + testWindowsCmdLine("\"abc\" d e", [_][]const u8{ "abc", "d", "e" }); + testWindowsCmdLine("a\\\\\\b d\"e f\"g h", [_][]const u8{ "a\\\\\\b", "de fg", "h" }); + testWindowsCmdLine("a\\\\\\\"b c d", [_][]const u8{ "a\\\"b", "c", "d" }); + testWindowsCmdLine("a\\\\\\\\\"b c\" d e", [_][]const u8{ "a\\\\b c", "d", "e" }); + testWindowsCmdLine("a b\tc \"d f", [_][]const u8{ "a", "b", "c", "\"d", "f" }); + + testWindowsCmdLine("\".\\..\\zig-cache\\build\" \"bin\\zig.exe\" \".\\..\" \".\\..\\zig-cache\" \"--help\"", [_][]const u8{ ".\\..\\zig-cache\\build", "bin\\zig.exe", ".\\..", |
