Make getEnv case insensitive on Windows (#9722)
This commit is contained in:
parent
4bd9f32f33
commit
4efbde84ee
1 changed files with 6 additions and 1 deletions
|
|
@ -3,6 +3,8 @@
|
||||||
when not declared(os):
|
when not declared(os):
|
||||||
{.error: "This is an include file for os.nim!".}
|
{.error: "This is an include file for os.nim!".}
|
||||||
|
|
||||||
|
from parseutils import skipIgnoreCase
|
||||||
|
|
||||||
proc c_getenv(env: cstring): cstring {.
|
proc c_getenv(env: cstring): cstring {.
|
||||||
importc: "getenv", header: "<stdlib.h>".}
|
importc: "getenv", header: "<stdlib.h>".}
|
||||||
proc c_putenv(env: cstring): cint {.
|
proc c_putenv(env: cstring): cint {.
|
||||||
|
|
@ -91,7 +93,10 @@ proc findEnvVar(key: string): int =
|
||||||
getEnvVarsC()
|
getEnvVarsC()
|
||||||
var temp = key & '='
|
var temp = key & '='
|
||||||
for i in 0..high(environment):
|
for i in 0..high(environment):
|
||||||
if startsWith(environment[i], temp): return i
|
when defined(windows):
|
||||||
|
if skipIgnoreCase(environment[i], temp) == len(temp): return i
|
||||||
|
else:
|
||||||
|
if startsWith(environment[i], temp): return i
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
proc getEnv*(key: string, default = ""): TaintedString {.tags: [ReadEnvEffect].} =
|
proc getEnv*(key: string, default = ""): TaintedString {.tags: [ReadEnvEffect].} =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue