mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Merge pull request #1804 from wjlroe/consistent-os-get-env-across-unix
[os] Darwin,FreeBSD,OpenBSD: Rename os.getenv to os.get_env
This commit is contained in:
@@ -633,13 +633,18 @@ heap_free :: proc(ptr: rawptr) {
|
|||||||
_unix_free(ptr)
|
_unix_free(ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
getenv :: proc(name: string) -> (string, bool) {
|
lookup_env :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) {
|
||||||
path_str := strings.clone_to_cstring(name, context.temp_allocator)
|
path_str := strings.clone_to_cstring(key, context.temp_allocator)
|
||||||
cstr := _unix_getenv(path_str)
|
cstr := _unix_getenv(path_str)
|
||||||
if cstr == nil {
|
if cstr == nil {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
return string(cstr), true
|
return strings.clone(string(cstr), allocator), true
|
||||||
|
}
|
||||||
|
|
||||||
|
get_env :: proc(key: string, allocator := context.allocator) -> (value: string) {
|
||||||
|
value, _ = lookup_env(key, allocator)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
get_current_directory :: proc() -> string {
|
get_current_directory :: proc() -> string {
|
||||||
|
|||||||
@@ -618,13 +618,18 @@ heap_free :: proc(ptr: rawptr) {
|
|||||||
_unix_free(ptr)
|
_unix_free(ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
getenv :: proc(name: string) -> (string, bool) {
|
lookup_env :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) {
|
||||||
path_str := strings.clone_to_cstring(name, context.temp_allocator)
|
path_str := strings.clone_to_cstring(key, context.temp_allocator)
|
||||||
cstr := _unix_getenv(path_str)
|
cstr := _unix_getenv(path_str)
|
||||||
if cstr == nil {
|
if cstr == nil {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
return string(cstr), true
|
return strings.clone(string(cstr), allocator), true
|
||||||
|
}
|
||||||
|
|
||||||
|
get_env :: proc(key: string, allocator := context.allocator) -> (value: string) {
|
||||||
|
value, _ = lookup_env(key, allocator)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
get_current_directory :: proc() -> string {
|
get_current_directory :: proc() -> string {
|
||||||
|
|||||||
@@ -620,13 +620,18 @@ heap_free :: proc(ptr: rawptr) {
|
|||||||
_unix_free(ptr)
|
_unix_free(ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
getenv :: proc(name: string) -> (string, bool) {
|
lookup_env :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) {
|
||||||
path_str := strings.clone_to_cstring(name, context.temp_allocator)
|
path_str := strings.clone_to_cstring(key, context.temp_allocator)
|
||||||
cstr := _unix_getenv(path_str)
|
cstr := _unix_getenv(path_str)
|
||||||
if cstr == nil {
|
if cstr == nil {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
return string(cstr), true
|
return strings.clone(string(cstr), allocator), true
|
||||||
|
}
|
||||||
|
|
||||||
|
get_env :: proc(key: string, allocator := context.allocator) -> (value: string) {
|
||||||
|
value, _ = lookup_env(key, allocator)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
get_current_directory :: proc() -> string {
|
get_current_directory :: proc() -> string {
|
||||||
|
|||||||
Reference in New Issue
Block a user