summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-03-25 00:11:10 -0700
committerOri Bernstein <ori@eigenstate.org>2018-03-25 00:11:10 -0700
commit375f3f20f33f050b677c5f51394109ccac7abe74 (patch)
tree3e53610f02b9561ef35ff4f0ac9cc7a4d3960588
parent8da5ac5ac4258588634453d55cec95f29a02647b (diff)
downloadmc-375f3f20f33f050b677c5f51394109ccac7abe74.tar.gz
Clean up setenv a bit.
-rw-r--r--lib/std/env+posixy.myr20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/std/env+posixy.myr b/lib/std/env+posixy.myr
index a5c25b4..cf4d8f7 100644
--- a/lib/std/env+posixy.myr
+++ b/lib/std/env+posixy.myr
@@ -59,20 +59,22 @@ const setenv = {name, val
lock(envlck)
for envp : environ
- if envp != Zenvp
- env = cstrconvp(envp)
- n = min(name.len, env.len - 1)
- if eq(name, env[:n]) && env[n] == ('=' : byte)
- found = true
- break
- ;;
- idx++
+ if envp == Zenvp
+ break
+ ;;
+
+ env = cstrconvp(envp)
+ n = min(name.len, env.len - 1)
+ if eq(name, env[:n]) && env[n] == ('=' : byte)
+ found = true
+ break
;;
+ idx++
;;
if found
std.slfree(cstrconvp(environ[idx]))
else
- idx = env.len - 1
+ idx = environ.len - 1
std.slpush(&environ, Zenvp)
;;
environ[idx] = (e : byte#)