Use GetEnvironmentVariable instead of getenv in DebugClient.cc.

This lets libwinpty.dll read the WINPTYDBG environment variable that the
unix adapter sets using SetEnvironmentVariable.  If DebugClient.cc calls
getenv, then it seems to read a copy of the Win32 environment that the
MSVCRT initializes at startup.
This commit is contained in:
Ryan Prichard 2012-03-31 00:49:09 -07:00
parent 0d673836f2
commit 68e32a2bde

View File

@ -23,7 +23,7 @@
#include <stdio.h>
#include <string.h>
const char *volatile tracingConfig;
char *tracingConfig;
static void sendToDebugServer(const char *message)
{
@ -52,10 +52,13 @@ static long long unixTimeMillis()
static const char *getTracingConfig()
{
if (tracingConfig == NULL) {
const char *newTracingConfig = getenv("WINPTYDBG");
if (newTracingConfig == NULL)
newTracingConfig = "";
tracingConfig = newTracingConfig;
const int bufSize = 256;
char buf[bufSize];
DWORD actualSize = GetEnvironmentVariableA("WINPTYDBG", buf, bufSize);
if (actualSize == 0 || actualSize >= (DWORD)bufSize)
buf[0] = '\0';
tracingConfig = new char[strlen(buf) + 1];
strcpy(tracingConfig, buf);
}
return tracingConfig;
}