diff options
| author | Shritesh Bhattarai <shritesh@shritesh.com> | 2019-04-30 18:43:43 -0500 |
|---|---|---|
| committer | Shritesh Bhattarai <shritesh@shritesh.com> | 2019-04-30 18:43:43 -0500 |
| commit | 0a693b70e4f31a4e4dc28e86f66a93acc09ed910 (patch) | |
| tree | 3736825f1ab7e65b78506755c90d5929dd866e2c | |
| parent | 20458f56d84cd588afd924564177293a7fea46c0 (diff) | |
| download | zig-0a693b70e4f31a4e4dc28e86f66a93acc09ed910.tar.gz zig-0a693b70e4f31a4e4dc28e86f66a93acc09ed910.zip | |
wasi: use mem.separate instead
| -rw-r--r-- | std/os.zig | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/std/os.zig b/std/os.zig index b7e8e0e96c..c55597f135 100644 --- a/std/os.zig +++ b/std/os.zig @@ -779,17 +779,10 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap { for (environ) |env| { if (env) |ptr| { - var line_i: usize = 0; - while (ptr[line_i] != 0 and ptr[line_i] != '=') : (line_i += 1) {} - if (ptr[line_i] != '=') { - return error.Unexpected; - } - const key = ptr[0..line_i]; - - var end_i: usize = line_i; - while (ptr[end_i] != 0) : (end_i += 1) {} - const value = ptr[line_i + 1 .. end_i]; - + const pair = mem.toSlice(u8, ptr); + var parts = mem.separate(pair, "="); + const key = parts.next().?; + const value = parts.next().?; try result.set(key, value); } } |
