got dotenv parsing working
This commit is contained in:
@@ -38,8 +38,9 @@ parse :: proc(src: string, allocator := context.allocator) -> map[string]string
|
||||
}
|
||||
|
||||
// real process env vars win over the file
|
||||
if override, found := os.lookup_env(key, context.temp_allocator); found {
|
||||
value = override
|
||||
if override, found := os.lookup_env(key, allocator); found {
|
||||
result[strings.clone(key, allocator)] = override
|
||||
continue
|
||||
}
|
||||
|
||||
// clone so the map outlives the source buffer (e.g. a freed file read)
|
||||
@@ -63,10 +64,11 @@ parse_file :: proc(filename: string, allocator := context.allocator) -> (map[str
|
||||
|
||||
// destroy frees the cloned keys/values and the map itself. Use it to release
|
||||
// a map returned by parse/parse_file (plain delete does not free the strings).
|
||||
destroy :: proc(env: map[string]string) {
|
||||
// Any allocator passed to parse/parse_file must be passed here too.
|
||||
destroy :: proc(env: map[string]string, allocator := context.allocator) {
|
||||
for key, value in env {
|
||||
delete(key)
|
||||
delete(value)
|
||||
delete(key, allocator)
|
||||
delete(value, allocator)
|
||||
}
|
||||
delete(env)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user