ci: fix os.environ :-|
parent
accd4d83bf
commit
8a362588aa
|
@ -66,6 +66,13 @@ pub fn unsetenv(name string) int {
|
||||||
// See: https://linux.die.net/man/5/environ for unix platforms.
|
// See: https://linux.die.net/man/5/environ for unix platforms.
|
||||||
// See: https://docs.microsoft.com/bg-bg/windows/win32/api/processenv/nf-processenv-getenvironmentstrings
|
// See: https://docs.microsoft.com/bg-bg/windows/win32/api/processenv/nf-processenv-getenvironmentstrings
|
||||||
// os.environ returns a map of all the current environment variables
|
// os.environ returns a map of all the current environment variables
|
||||||
|
type PChar = &char
|
||||||
|
type PPChar = &&char
|
||||||
|
|
||||||
|
fn deref_ppchar(x &PChar) &char {
|
||||||
|
return &char(*x)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn environ() map[string]string {
|
pub fn environ() map[string]string {
|
||||||
mut res := map[string]string{}
|
mut res := map[string]string{}
|
||||||
$if windows {
|
$if windows {
|
||||||
|
@ -83,18 +90,21 @@ pub fn environ() map[string]string {
|
||||||
}
|
}
|
||||||
C.FreeEnvironmentStringsW(estrings)
|
C.FreeEnvironmentStringsW(estrings)
|
||||||
} $else {
|
} $else {
|
||||||
/*
|
e := unsafe { PPChar(voidptr(C.environ)) }
|
||||||
// e := unsafe { &&char(C.environ) }
|
size_of_pchar := int(sizeof(PChar))
|
||||||
e := unsafe { &charptr(C.environ) }
|
for i := 0; true; i++ {
|
||||||
for i := 0; !isnil(unsafe { e[i] }); i++ {
|
z := voidptr(unsafe { &byte(voidptr(e)) + size_of_pchar * i })
|
||||||
x := &byte(e[i])
|
current_ptr := &PChar(z)
|
||||||
eline := unsafe { cstring_to_vstring(x) }
|
derefed := deref_ppchar(current_ptr)
|
||||||
|
if isnil(derefed) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
eline := unsafe { cstring_to_vstring(derefed) }
|
||||||
eq_index := eline.index_byte(`=`)
|
eq_index := eline.index_byte(`=`)
|
||||||
if eq_index > 0 {
|
if eq_index > 0 {
|
||||||
res[eline[0..eq_index]] = eline[eq_index + 1..]
|
res[eline[0..eq_index]] = eline[eq_index + 1..]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue