summaryrefslogtreecommitdiffstats
path: root/win/tclWinInit.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tclWinInit.c')
-rw-r--r--win/tclWinInit.c354
1 files changed, 225 insertions, 129 deletions
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 3764a79..4e860b2 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -3,8 +3,8 @@
*
* Contains the Windows-specific interpreter initialization functions.
*
- * Copyright © 1994-1997 Sun Microsystems, Inc.
- * Copyright © 1998-1999 Scriptics Corporation.
+ * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright (c) 1998-1999 by Scriptics Corporation.
* All rights reserved.
*
* See the file "license.terms" for information on usage and redistribution of
@@ -17,7 +17,7 @@
#include <lmcons.h>
/*
- * GetUserNameW() is found in advapi32.dll
+ * GetUserName() is found in advapi32.dll
*/
#ifdef _MSC_VER
# pragma comment(lib, "advapi32.lib")
@@ -36,14 +36,61 @@ typedef struct {
} OemId;
/*
- * The following arrays contain the human readable strings for the
- * processor values.
+ * The following macros are missing from some versions of winnt.h.
*/
-#define NUMPROCESSORS 15
-static const char *const processors[NUMPROCESSORS] = {
+#ifndef PROCESSOR_ARCHITECTURE_INTEL
+#define PROCESSOR_ARCHITECTURE_INTEL 0
+#endif
+#ifndef PROCESSOR_ARCHITECTURE_MIPS
+#define PROCESSOR_ARCHITECTURE_MIPS 1
+#endif
+#ifndef PROCESSOR_ARCHITECTURE_ALPHA
+#define PROCESSOR_ARCHITECTURE_ALPHA 2
+#endif
+#ifndef PROCESSOR_ARCHITECTURE_PPC
+#define PROCESSOR_ARCHITECTURE_PPC 3
+#endif
+#ifndef PROCESSOR_ARCHITECTURE_SHX
+#define PROCESSOR_ARCHITECTURE_SHX 4
+#endif
+#ifndef PROCESSOR_ARCHITECTURE_ARM
+#define PROCESSOR_ARCHITECTURE_ARM 5
+#endif
+#ifndef PROCESSOR_ARCHITECTURE_IA64
+#define PROCESSOR_ARCHITECTURE_IA64 6
+#endif
+#ifndef PROCESSOR_ARCHITECTURE_ALPHA64
+#define PROCESSOR_ARCHITECTURE_ALPHA64 7
+#endif
+#ifndef PROCESSOR_ARCHITECTURE_MSIL
+#define PROCESSOR_ARCHITECTURE_MSIL 8
+#endif
+#ifndef PROCESSOR_ARCHITECTURE_AMD64
+#define PROCESSOR_ARCHITECTURE_AMD64 9
+#endif
+#ifndef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
+#define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
+#endif
+#ifndef PROCESSOR_ARCHITECTURE_UNKNOWN
+#define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
+#endif
+
+/*
+ * The following arrays contain the human readable strings for the Windows
+ * platform and processor values.
+ */
+
+
+#define NUMPLATFORMS 4
+static char* platforms[NUMPLATFORMS] = {
+ "Win32s", "Windows 95", "Windows NT", "Windows CE"
+};
+
+#define NUMPROCESSORS 11
+static char* processors[NUMPROCESSORS] = {
"intel", "mips", "alpha", "ppc", "shx", "arm", "ia64", "alpha64", "msil",
- "amd64", "ia32_on_win64", "neutral", "arm64", "arm32_on_win64", "ia32_on_arm64"
+ "amd64", "ia32_on_win64"
};
/*
@@ -58,14 +105,15 @@ static TclInitProcessGlobalValueProc InitializeSourceLibraryDir;
static ProcessGlobalValue sourceLibraryDir =
{0, 0, NULL, NULL, InitializeSourceLibraryDir, NULL, NULL};
-static void AppendEnvironment(Tcl_Obj *listPtr, const char *lib);
+static void AppendEnvironment(Tcl_Obj *listPtr, CONST char *lib);
+static int ToUtf(CONST WCHAR *wSrc, char *dst);
/*
*---------------------------------------------------------------------------
*
* TclpInitPlatform --
*
- * Initialize all the platform-dependent things like signals,
+ * Initialize all the platform-dependant things like signals,
* floating-point error handling and sockets.
*
* Called at process initialization time.
@@ -87,11 +135,11 @@ TclpInitPlatform(void)
tclPlatform = TCL_PLATFORM_WINDOWS;
- /*
- * Initialize the winsock library. On Windows XP and higher this
- * can never fail.
- */
- WSAStartup(wVersionRequested, &wsaData);
+ /*
+ * Initialize the winsock library. On Windows XP and higher this
+ * can never fail.
+ */
+ WSAStartup(wVersionRequested, &wsaData);
#ifdef STATIC_BUILD
/*
@@ -100,7 +148,7 @@ TclpInitPlatform(void)
* invoked.
*/
- TclWinInit(GetModuleHandleW(NULL));
+ TclWinInit(GetModuleHandle(NULL));
#endif
}
@@ -124,16 +172,15 @@ TclpInitPlatform(void)
void
TclpInitLibraryPath(
char **valuePtr,
- TCL_HASH_TYPE *lengthPtr,
+ int *lengthPtr,
Tcl_Encoding *encodingPtr)
{
#define LIBRARY_SIZE 64
Tcl_Obj *pathPtr;
char installLib[LIBRARY_SIZE];
- const char *bytes;
- Tcl_Size length;
+ char *bytes;
- TclNewObj(pathPtr);
+ pathPtr = Tcl_NewObj();
/*
* Initialize the substring used when locating the script library. The
@@ -141,13 +188,13 @@ TclpInitLibraryPath(
* installed DLL.
*/
- snprintf(installLib, sizeof(installLib), "lib/tcl%s", TCL_VERSION);
+ sprintf(installLib, "lib/tcl%s", TCL_VERSION);
/*
* Look for the library relative to the TCL_LIBRARY env variable. If the
* last dirname in the TCL_LIBRARY path does not match the last dirname in
* the installLib variable, use the last dir name of installLib in
- * addition to the original TCL_LIBRARY path.
+ * addition to the orginal TCL_LIBRARY path.
*/
AppendEnvironment(pathPtr, installLib);
@@ -167,10 +214,9 @@ TclpInitLibraryPath(
TclGetProcessGlobalValue(&sourceLibraryDir));
*encodingPtr = NULL;
- bytes = TclGetStringFromObj(pathPtr, &length);
- *lengthPtr = length++;
- *valuePtr = (char *)ckalloc(length);
- memcpy(*valuePtr, bytes, length);
+ bytes = Tcl_GetStringFromObj(pathPtr, lengthPtr);
+ *valuePtr = ckalloc((unsigned int)(*lengthPtr)+1);
+ memcpy(*valuePtr, bytes, (size_t)(*lengthPtr)+1);
Tcl_DecrRefCount(pathPtr);
}
@@ -196,14 +242,14 @@ TclpInitLibraryPath(
static void
AppendEnvironment(
Tcl_Obj *pathPtr,
- const char *lib)
+ CONST char *lib)
{
- Tcl_Size pathc;
+ int pathc;
WCHAR wBuf[MAX_PATH];
- char buf[MAX_PATH * 3];
+ char buf[MAX_PATH * TCL_UTF_MAX];
Tcl_Obj *objPtr;
Tcl_DString ds;
- const char **pathv;
+ CONST char **pathv;
char *shortlib;
/*
@@ -213,7 +259,7 @@ AppendEnvironment(
for (shortlib = (char *) &lib[strlen(lib)-1]; shortlib>lib ; shortlib--) {
if (*shortlib == '/') {
- if ((size_t)(shortlib - lib) == strlen(lib) - 1) {
+ if ((unsigned)(shortlib - lib) == strlen(lib) - 1) {
Tcl_Panic("last character in lib cannot be '/'");
}
shortlib++;
@@ -225,26 +271,32 @@ AppendEnvironment(
}
/*
- * The "L" preceding the TCL_LIBRARY string is used to tell VC++ that
- * this is a Unicode string.
+ * The "L" preceeding the TCL_LIBRARY string is used to tell VC++ that
+ * this is a unicode string.
*/
- GetEnvironmentVariableW(L"TCL_LIBRARY", wBuf, MAX_PATH);
- WideCharToMultiByte(CP_UTF8, 0, wBuf, -1, buf, MAX_PATH * 3, NULL, NULL);
+ if (GetEnvironmentVariableW(L"TCL_LIBRARY", wBuf, MAX_PATH) == 0) {
+ buf[0] = '\0';
+ GetEnvironmentVariableA("TCL_LIBRARY", buf, MAX_PATH);
+ } else {
+ ToUtf(wBuf, buf);
+ }
if (buf[0] != '\0') {
- objPtr = Tcl_NewStringObj(buf, TCL_INDEX_NONE);
+ objPtr = Tcl_NewStringObj(buf, -1);
Tcl_ListObjAppendElement(NULL, pathPtr, objPtr);
TclWinNoBackslash(buf);
Tcl_SplitPath(buf, &pathc, &pathv);
/*
- * The lstrcmpiA() will work even if pathv[pathc-1] is random UTF-8
+ * The lstrcmpi() will work even if pathv[pathc-1] is random UTF-8
* chars because I know shortlib is ascii.
*/
if ((pathc > 0) && (lstrcmpiA(shortlib, pathv[pathc - 1]) != 0)) {
+ CONST char *str;
+
/*
* TCL_LIBRARY is set but refers to a different tcl installation
* than the current version. Try fiddling with the specified
@@ -254,13 +306,14 @@ AppendEnvironment(
pathv[pathc - 1] = shortlib;
Tcl_DStringInit(&ds);
- (void) Tcl_JoinPath(pathc, pathv, &ds);
- objPtr = Tcl_DStringToObj(&ds);
+ str = Tcl_JoinPath(pathc, pathv, &ds);
+ objPtr = Tcl_NewStringObj(str, Tcl_DStringLength(&ds));
+ Tcl_DStringFree(&ds);
} else {
- objPtr = Tcl_NewStringObj(buf, TCL_INDEX_NONE);
+ objPtr = Tcl_NewStringObj(buf, -1);
}
Tcl_ListObjAppendElement(NULL, pathPtr, objPtr);
- ckfree(pathv);
+ ckfree((char *) pathv);
}
}
@@ -284,16 +337,19 @@ AppendEnvironment(
static void
InitializeDefaultLibraryDir(
char **valuePtr,
- TCL_HASH_TYPE *lengthPtr,
+ int *lengthPtr,
Tcl_Encoding *encodingPtr)
{
- HMODULE hModule = (HMODULE)TclWinGetTclInstance();
+ HMODULE hModule = TclWinGetTclInstance();
WCHAR wName[MAX_PATH + LIBRARY_SIZE];
- char name[(MAX_PATH + LIBRARY_SIZE) * 3];
+ char name[(MAX_PATH + LIBRARY_SIZE) * TCL_UTF_MAX];
char *end, *p;
- GetModuleFileNameW(hModule, wName, sizeof(wName)/sizeof(WCHAR));
- WideCharToMultiByte(CP_UTF8, 0, wName, -1, name, sizeof(name), NULL, NULL);
+ if (GetModuleFileNameW(hModule, wName, MAX_PATH) == 0) {
+ GetModuleFileNameA(hModule, name, MAX_PATH);
+ } else {
+ ToUtf(wName, name);
+ }
end = strrchr(name, '\\');
*end = '\0';
@@ -304,11 +360,11 @@ InitializeDefaultLibraryDir(
*end = '\\';
TclWinNoBackslash(name);
- snprintf(end + 1, LIBRARY_SIZE, "lib/tcl%s", TCL_VERSION);
+ sprintf(end + 1, "lib/tcl%s", TCL_VERSION);
*lengthPtr = strlen(name);
- *valuePtr = (char *)ckalloc(*lengthPtr + 1);
+ *valuePtr = ckalloc(*lengthPtr + 1);
*encodingPtr = NULL;
- memcpy(*valuePtr, name, *lengthPtr + 1);
+ memcpy(*valuePtr, name, (size_t) *lengthPtr + 1);
}
/*
@@ -332,16 +388,19 @@ InitializeDefaultLibraryDir(
static void
InitializeSourceLibraryDir(
char **valuePtr,
- TCL_HASH_TYPE *lengthPtr,
+ int *lengthPtr,
Tcl_Encoding *encodingPtr)
{
- HMODULE hModule = (HMODULE)TclWinGetTclInstance();
+ HMODULE hModule = TclWinGetTclInstance();
WCHAR wName[MAX_PATH + LIBRARY_SIZE];
- char name[(MAX_PATH + LIBRARY_SIZE) * 3];
+ char name[(MAX_PATH + LIBRARY_SIZE) * TCL_UTF_MAX];
char *end, *p;
- GetModuleFileNameW(hModule, wName, sizeof(wName)/sizeof(WCHAR));
- WideCharToMultiByte(CP_UTF8, 0, wName, -1, name, sizeof(name), NULL, NULL);
+ if (GetModuleFileNameW(hModule, wName, MAX_PATH) == 0) {
+ GetModuleFileNameA(hModule, name, MAX_PATH);
+ } else {
+ ToUtf(wName, name);
+ }
end = strrchr(name, '\\');
*end = '\0';
@@ -352,11 +411,68 @@ InitializeSourceLibraryDir(
*end = '\\';
TclWinNoBackslash(name);
- snprintf(end + 1, LIBRARY_SIZE, "../library");
+ sprintf(end + 1, "../library");
*lengthPtr = strlen(name);
- *valuePtr = (char *)ckalloc(*lengthPtr + 1);
+ *valuePtr = ckalloc((unsigned int) *lengthPtr + 1);
*encodingPtr = NULL;
- memcpy(*valuePtr, name, *lengthPtr + 1);
+ memcpy(*valuePtr, name, (size_t) *lengthPtr + 1);
+}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * ToUtf --
+ *
+ * Convert a char string to a UTF string.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+static int
+ToUtf(
+ CONST WCHAR *wSrc,
+ char *dst)
+{
+ char *start;
+
+ start = dst;
+ while (*wSrc != '\0') {
+ dst += Tcl_UniCharToUtf(*wSrc, dst);
+ wSrc++;
+ }
+ *dst = '\0';
+ return (int) (dst - start);
+}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TclWinEncodingsCleanup --
+ *
+ * Reset information to its original state in finalization to allow for
+ * reinitialization to be possible. This must not be called until after
+ * the filesystem has been finalised, or exit crashes may occur when
+ * using virtual filesystems.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Static information reset to startup state.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+void
+TclWinEncodingsCleanup(void)
+{
+ TclWinResetInterfaceEncodings();
}
/*
@@ -388,49 +504,34 @@ TclpSetInitialEncodings(void)
{
Tcl_DString encodingName;
+ TclpSetInterfaces();
Tcl_SetSystemEncoding(NULL,
Tcl_GetEncodingNameFromEnvironment(&encodingName));
Tcl_DStringFree(&encodingName);
}
-const char *
+void
+TclpSetInterfaces(void)
+{
+ int platformId, useWide;
+
+ platformId = TclWinGetPlatformId();
+ useWide = ((platformId == VER_PLATFORM_WIN32_NT)
+ || (platformId == VER_PLATFORM_WIN32_CE));
+ TclWinSetInterfaces(useWide);
+}
+
+CONST char *
Tcl_GetEncodingNameFromEnvironment(
Tcl_DString *bufPtr)
{
- UINT acp = GetACP();
-
Tcl_DStringInit(bufPtr);
- if (acp == CP_UTF8) {
- Tcl_DStringAppend(bufPtr, "utf-8", 5);
- } else {
- Tcl_DStringSetLength(bufPtr, 2+TCL_INTEGER_SPACE);
- snprintf(Tcl_DStringValue(bufPtr), 2+TCL_INTEGER_SPACE, "cp%d", GetACP());
- Tcl_DStringSetLength(bufPtr, strlen(Tcl_DStringValue(bufPtr)));
- }
+ Tcl_DStringSetLength(bufPtr, 2+TCL_INTEGER_SPACE);
+ wsprintfA(Tcl_DStringValue(bufPtr), "cp%d", GetACP());
+ Tcl_DStringSetLength(bufPtr, strlen(Tcl_DStringValue(bufPtr)));
return Tcl_DStringValue(bufPtr);
}
-const char *
-TclpGetUserName(
- Tcl_DString *bufferPtr) /* Uninitialized or free DString filled with
- * the name of user. */
-{
- Tcl_DStringInit(bufferPtr);
-
- if (TclGetEnv("USERNAME", bufferPtr) == NULL) {
- WCHAR szUserName[UNLEN+1];
- DWORD cchUserNameLen = UNLEN;
-
- if (!GetUserNameW(szUserName, &cchUserNameLen)) {
- return NULL;
- }
- cchUserNameLen--;
- Tcl_DStringInit(bufferPtr);
- Tcl_WCharToUtfDString(szUserName, cchUserNameLen, bufferPtr);
- }
- return Tcl_DStringValue(bufferPtr);
-}
-
/*
*---------------------------------------------------------------------------
*
@@ -452,7 +553,7 @@ void
TclpSetVariables(
Tcl_Interp *interp) /* Interp to initialize. */
{
- const char *ptr;
+ CONST char *ptr;
char buffer[TCL_INTEGER_SPACE * 2];
union {
SYSTEM_INFO info;
@@ -461,18 +562,23 @@ TclpSetVariables(
static OSVERSIONINFOW osInfo;
static int osInfoInitialized = 0;
Tcl_DString ds;
+ WCHAR szUserName[UNLEN+1];
+ DWORD cchUserNameLen = UNLEN;
Tcl_SetVar2Ex(interp, "tclDefaultLibrary", NULL,
TclGetProcessGlobalValue(&defaultLibraryDir), TCL_GLOBAL_ONLY);
if (!osInfoInitialized) {
- HMODULE handle = GetModuleHandleW(L"NTDLL");
+ HANDLE handle = LoadLibraryW(L"NTDLL");
int(__stdcall *getversion)(void *) =
- (int(__stdcall *)(void *))(void *)GetProcAddress(handle, "RtlGetVersion");
+ (int(__stdcall *)(void *)) GetProcAddress(handle, "RtlGetVersion");
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
if (!getversion || getversion(&osInfo)) {
GetVersionExW(&osInfo);
}
+ if (handle) {
+ FreeLibrary(handle);
+ }
osInfoInitialized = 1;
}
GetSystemInfo(&sys.info);
@@ -483,12 +589,11 @@ TclpSetVariables(
Tcl_SetVar2(interp, "tcl_platform", "platform", "windows",
TCL_GLOBAL_ONLY);
- Tcl_SetVar2(interp, "tcl_platform", "os",
- "Windows NT", TCL_GLOBAL_ONLY);
- if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 22000) {
- osInfo.dwMajorVersion = 11;
+ if (osInfo.dwPlatformId < NUMPLATFORMS) {
+ Tcl_SetVar2(interp, "tcl_platform", "os",
+ platforms[osInfo.dwPlatformId], TCL_GLOBAL_ONLY);
}
- snprintf(buffer, sizeof(buffer), "%ld.%ld", osInfo.dwMajorVersion, osInfo.dwMinorVersion);
+ wsprintfA(buffer, "%d.%d", osInfo.dwMajorVersion, osInfo.dwMinorVersion);
Tcl_SetVar2(interp, "tcl_platform", "osVersion", buffer, TCL_GLOBAL_ONLY);
if (sys.oemId.wProcessorArchitecture < NUMPROCESSORS) {
Tcl_SetVar2(interp, "tcl_platform", "machine",
@@ -496,8 +601,7 @@ TclpSetVariables(
TCL_GLOBAL_ONLY);
}
-#if !defined(NDEBUG) && !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
-
+#ifndef NDEBUG
/*
* The existence of the "debug" element of the tcl_platform array
* indicates that this particular Tcl shell has been compiled with debug
@@ -520,24 +624,17 @@ TclpSetVariables(
if (ptr == NULL) {
ptr = Tcl_GetVar2(interp, "env", "HOMEDRIVE", TCL_GLOBAL_ONLY);
if (ptr != NULL) {
- Tcl_DStringAppend(&ds, ptr, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&ds, ptr, -1);
}
ptr = Tcl_GetVar2(interp, "env", "HOMEPATH", TCL_GLOBAL_ONLY);
if (ptr != NULL) {
- Tcl_DStringAppend(&ds, ptr, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&ds, ptr, -1);
}
if (Tcl_DStringLength(&ds) > 0) {
Tcl_SetVar2(interp, "env", "HOME", Tcl_DStringValue(&ds),
TCL_GLOBAL_ONLY);
} else {
- /* None of HOME, HOMEDRIVE, HOMEPATH exists. Try USERPROFILE */
- ptr = Tcl_GetVar2(interp, "env", "USERPROFILE", TCL_GLOBAL_ONLY);
- if (ptr != NULL && ptr[0]) {
- Tcl_SetVar2(interp, "env", "HOME", ptr, TCL_GLOBAL_ONLY);
- } else {
- /* Last resort */
- Tcl_SetVar2(interp, "env", "HOME", "c:\\", TCL_GLOBAL_ONLY);
- }
+ Tcl_SetVar2(interp, "env", "HOME", "c:\\", TCL_GLOBAL_ONLY);
}
}
@@ -547,16 +644,17 @@ TclpSetVariables(
* Note: cchUserNameLen is number of characters including nul terminator.
*/
- ptr = TclpGetUserName(&ds);
- Tcl_SetVar2(interp, "tcl_platform", "user", ptr ? ptr : "",
+ Tcl_DStringInit(&ds);
+ if (TclGetEnv("USERNAME", &ds) == NULL) {
+ if (tclWinProcs->getUserName((LPTSTR)szUserName, &cchUserNameLen) != 0) {
+ int cbUserNameLen = cchUserNameLen - 1;
+ if (tclWinProcs->useWide) cbUserNameLen *= sizeof(WCHAR);
+ Tcl_WinTCharToUtf((LPTSTR)szUserName, cbUserNameLen, &ds);
+ }
+ }
+ Tcl_SetVar2(interp, "tcl_platform", "user", Tcl_DStringValue(&ds),
TCL_GLOBAL_ONLY);
Tcl_DStringFree(&ds);
-
- /*
- * Define what the platform PATH separator is. [TIP #315]
- */
-
- Tcl_SetVar2(interp, "tcl_platform","pathSeparator", ";", TCL_GLOBAL_ONLY);
}
/*
@@ -565,7 +663,7 @@ TclpSetVariables(
* TclpFindVariable --
*
* Locate the entry in environ for a given name. On Unix this routine is
- * case sensitive, on Windows this matches mixed case.
+ * case sensitive, on Windows this matches mioxed case.
*
* Results:
* The return value is the index in environ of an entry with the name
@@ -579,18 +677,17 @@ TclpSetVariables(
*----------------------------------------------------------------------
*/
-Tcl_Size
+int
TclpFindVariable(
- const char *name, /* Name of desired environment variable
+ CONST char *name, /* Name of desired environment variable
* (UTF-8). */
- Tcl_Size *lengthPtr) /* Used to return length of name (for
+ int *lengthPtr) /* Used to return length of name (for
* successful searches) or number of non-NULL
* entries in environ (for unsuccessful
* searches). */
{
- Tcl_Size i, length, result = TCL_INDEX_NONE;
- const WCHAR *env;
- const char *p1, *p2;
+ int i, length, result = -1;
+ register CONST char *env, *p1, *p2;
char *envUpper, *nameUpper;
Tcl_DString envString;
@@ -599,25 +696,24 @@ TclpFindVariable(
*/
length = strlen(name);
- nameUpper = (char *)ckalloc(length + 1);
- memcpy(nameUpper, name, length+1);
+ nameUpper = (char *) ckalloc((unsigned) length+1);
+ memcpy(nameUpper, name, (size_t) length+1);
Tcl_UtfToUpper(nameUpper);
Tcl_DStringInit(&envString);
- for (i = 0, env = _wenviron[i]; env != NULL; i++, env = _wenviron[i]) {
+ for (i = 0, env = environ[i]; env != NULL; i++, env = environ[i]) {
/*
* Chop the env string off after the equal sign, then Convert the name
* to all upper case, so we do not have to convert all the characters
* after the equal sign.
*/
- Tcl_DStringInit(&envString);
- envUpper = Tcl_WCharToUtfDString(env, TCL_INDEX_NONE, &envString);
+ envUpper = Tcl_ExternalToUtfDString(NULL, env, -1, &envString);
p1 = strchr(envUpper, '=');
if (p1 == NULL) {
continue;
}
- length = p1 - envUpper;
+ length = (int) (p1 - envUpper);
Tcl_DStringSetLength(&envString, length+1);
Tcl_UtfToUpper(envUpper);