authorgravatar for shritesh@shritesh.comShritesh Bhattarai <shritesh@shritesh.com> 2019-04-30 18:43:43-05:00
committergravatar for shritesh@shritesh.comShritesh Bhattarai <shritesh@shritesh.com> 2019-04-30 18:43:43-05:00
log0a693b70e4f31a4e4dc28e86f66a93acc09ed910
tree3736825f1ab7e65b78506755c90d5929dd866e2c
parent20458f56d84cd588afd924564177293a7fea46c0

wasi: use mem.separate instead


1 files changed, 4 insertions(+), 11 deletions(-)

std/os.zig+4-11
......@@ -779,17 +779,10 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap {
779779
780780 for (environ) |env| {
781781 if (env) |ptr| {
782 var line_i: usize = 0;
783 while (ptr[line_i] != 0 and ptr[line_i] != '=') : (line_i += 1) {}
784 if (ptr[line_i] != '=') {
785 return error.Unexpected;
786 }
787 const key = ptr[0..line_i];
788
789 var end_i: usize = line_i;
790 while (ptr[end_i] != 0) : (end_i += 1) {}
791 const value = ptr[line_i + 1 .. end_i];
792
782 const pair = mem.toSlice(u8, ptr);
783 var parts = mem.separate(pair, "=");
784 const key = parts.next().?;
785 const value = parts.next().?;
793786 try result.set(key, value);
794787 }
795788 }