aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorShritesh Bhattarai <shritesh@shritesh.com>2019-04-30 18:43:43 -0500
committerShritesh Bhattarai <shritesh@shritesh.com>2019-04-30 18:43:43 -0500
commit0a693b70e4f31a4e4dc28e86f66a93acc09ed910 (patch)
tree3736825f1ab7e65b78506755c90d5929dd866e2c /std
parent20458f56d84cd588afd924564177293a7fea46c0 (diff)
downloadzig-0a693b70e4f31a4e4dc28e86f66a93acc09ed910.tar.gz
zig-0a693b70e4f31a4e4dc28e86f66a93acc09ed910.zip
wasi: use mem.separate instead
Diffstat (limited to 'std')
-rw-r--r--std/os.zig15
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);
}
}