diff options
author | Dan Kegel <[email protected]> | 2021-12-11 11:53:02 -0800 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-12-13 23:05:17 +0100 |
commit | 51fc78c100ea055bdd2eccf0527472c2f9b33ed0 (patch) | |
tree | cdfe9e0f6f68aa0554f1f0b8182de7ef6c4c3542 /src/syscall | |
parent | e4f2b9c0037a757ccb03fe2c8563e33a55e9901e (diff) | |
download | tinygo-51fc78c100ea055bdd2eccf0527472c2f9b33ed0.tar.gz tinygo-51fc78c100ea055bdd2eccf0527472c2f9b33ed0.zip |
os: implement and smoketest os.Clearenv
Diffstat (limited to 'src/syscall')
-rw-r--r-- | src/syscall/syscall_libc.go | 11 | ||||
-rw-r--r-- | src/syscall/syscall_nonhosted.go | 5 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/syscall/syscall_libc.go b/src/syscall/syscall_libc.go index 05df16fd7..25c778650 100644 --- a/src/syscall/syscall_libc.go +++ b/src/syscall/syscall_libc.go @@ -151,6 +151,17 @@ func Unsetenv(key string) (err error) { return } +func Clearenv() { + for _, s := range Environ() { + for j := 0; j < len(s); j++ { + if s[j] == '=' { + Unsetenv(s[0:j]) + break + } + } + } +} + func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { addr := libc_mmap(nil, uintptr(length), int32(prot), int32(flags), int32(fd), uintptr(offset)) if addr == unsafe.Pointer(^uintptr(0)) { diff --git a/src/syscall/syscall_nonhosted.go b/src/syscall/syscall_nonhosted.go index 9e5b70fdc..be1b32c7b 100644 --- a/src/syscall/syscall_nonhosted.go +++ b/src/syscall/syscall_nonhosted.go @@ -77,6 +77,11 @@ func Unsetenv(key string) (err error) { return ENOSYS } +func Clearenv() (err error) { + // stub for now + return ENOSYS +} + func Environ() []string { env := runtime_envs() envCopy := make([]string, len(env)) |