Skip to content

Commit

Permalink
sclang: (Windows) fix String:-getenv to return variables set with -se…
Browse files Browse the repository at this point in the history
…tenv

Use Windows API's GetEnvironmentVariable() instead of getenv(),
as the latter seems to only look up system environment,
not dynamic process environment.
(cherry picked from commit 861914a)
  • Loading branch information
jleben committed Nov 24, 2012
1 parent 539b2b2 commit c21bb3b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lang/LangPrimSource/PyrStringPrim.cpp
Expand Up @@ -603,7 +603,16 @@ int prString_Getenv(struct VMGlobals* g, int /* numArgsPushed */)
err = slotStrVal(arg, key, 256);
if (err) return err;

#ifdef _WIN32
char buf[1024];
DWORD size = GetEnvironmentVariable(key, buf, 1024);
if (size == 0 || size > 1024)
value = 0;
else
value = buf;
#else
value = getenv(key);
#endif

if (value) {
PyrString* pyrString = newPyrString(g->gc, value, 0, true);
Expand Down

0 comments on commit c21bb3b

Please sign in to comment.