Import Tcl 8.6.11
This commit is contained in:
@@ -83,16 +83,10 @@ typedef struct {
|
||||
TclWinProcs tclWinProcs;
|
||||
|
||||
/*
|
||||
* The following arrays contain the human readable strings for the Windows
|
||||
* platform and processor values.
|
||||
* The following arrays contain the human readable strings for the
|
||||
* processor values.
|
||||
*/
|
||||
|
||||
|
||||
#define NUMPLATFORMS 4
|
||||
static const char *const platforms[NUMPLATFORMS] = {
|
||||
"Win32s", "Windows 95", "Windows NT", "Windows CE"
|
||||
};
|
||||
|
||||
#define NUMPROCESSORS 11
|
||||
static const char *const processors[NUMPROCESSORS] = {
|
||||
"intel", "mips", "alpha", "ppc", "shx", "arm", "ia64", "alpha64", "msil",
|
||||
@@ -160,7 +154,7 @@ TclpInitPlatform(void)
|
||||
* invoked.
|
||||
*/
|
||||
|
||||
TclWinInit(GetModuleHandle(NULL));
|
||||
TclWinInit(GetModuleHandleW(NULL));
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -168,8 +162,11 @@ TclpInitPlatform(void)
|
||||
*/
|
||||
handle = GetModuleHandleW(L"KERNEL32");
|
||||
tclWinProcs.cancelSynchronousIo =
|
||||
(BOOL (WINAPI *)(HANDLE)) GetProcAddress(handle,
|
||||
(BOOL (WINAPI *)(HANDLE))(void *)GetProcAddress(handle,
|
||||
"CancelSynchronousIo");
|
||||
tclWinProcs.createSymbolicLink =
|
||||
(BOOLEAN (WINAPI *)(LPCWSTR, LPCWSTR, DWORD))(void *)GetProcAddress(handle,
|
||||
"CreateSymbolicLinkW");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -200,7 +197,7 @@ TclpInitLibraryPath(
|
||||
char installLib[LIBRARY_SIZE];
|
||||
const char *bytes;
|
||||
|
||||
pathPtr = Tcl_NewObj();
|
||||
TclNewObj(pathPtr);
|
||||
|
||||
/*
|
||||
* Initialize the substring used when locating the script library. The
|
||||
@@ -235,8 +232,8 @@ TclpInitLibraryPath(
|
||||
|
||||
*encodingPtr = NULL;
|
||||
bytes = Tcl_GetStringFromObj(pathPtr, lengthPtr);
|
||||
*valuePtr = ckalloc((*lengthPtr) + 1);
|
||||
memcpy(*valuePtr, bytes, (size_t)(*lengthPtr)+1);
|
||||
*valuePtr = (char *)ckalloc(*lengthPtr + 1);
|
||||
memcpy(*valuePtr, bytes, *lengthPtr + 1);
|
||||
Tcl_DecrRefCount(pathPtr);
|
||||
}
|
||||
|
||||
@@ -266,7 +263,7 @@ AppendEnvironment(
|
||||
{
|
||||
int pathc;
|
||||
WCHAR wBuf[MAX_PATH];
|
||||
char buf[MAX_PATH * TCL_UTF_MAX];
|
||||
char buf[MAX_PATH * 3];
|
||||
Tcl_Obj *objPtr;
|
||||
Tcl_DString ds;
|
||||
const char **pathv;
|
||||
@@ -279,7 +276,7 @@ AppendEnvironment(
|
||||
|
||||
for (shortlib = (char *) &lib[strlen(lib)-1]; shortlib>lib ; shortlib--) {
|
||||
if (*shortlib == '/') {
|
||||
if ((unsigned)(shortlib - lib) == strlen(lib) - 1) {
|
||||
if ((size_t)(shortlib - lib) == strlen(lib) - 1) {
|
||||
Tcl_Panic("last character in lib cannot be '/'");
|
||||
}
|
||||
shortlib++;
|
||||
@@ -359,7 +356,7 @@ InitializeDefaultLibraryDir(
|
||||
{
|
||||
HMODULE hModule = TclWinGetTclInstance();
|
||||
WCHAR wName[MAX_PATH + LIBRARY_SIZE];
|
||||
char name[(MAX_PATH + LIBRARY_SIZE) * TCL_UTF_MAX];
|
||||
char name[(MAX_PATH + LIBRARY_SIZE) * 3];
|
||||
char *end, *p;
|
||||
|
||||
if (GetModuleFileNameW(hModule, wName, MAX_PATH) == 0) {
|
||||
@@ -379,9 +376,9 @@ InitializeDefaultLibraryDir(
|
||||
TclWinNoBackslash(name);
|
||||
sprintf(end + 1, "lib/tcl%s", TCL_VERSION);
|
||||
*lengthPtr = strlen(name);
|
||||
*valuePtr = ckalloc(*lengthPtr + 1);
|
||||
*valuePtr = (char *)ckalloc(*lengthPtr + 1);
|
||||
*encodingPtr = NULL;
|
||||
memcpy(*valuePtr, name, (size_t) *lengthPtr + 1);
|
||||
memcpy(*valuePtr, name, *lengthPtr + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -430,9 +427,9 @@ InitializeSourceLibraryDir(
|
||||
TclWinNoBackslash(name);
|
||||
sprintf(end + 1, "../library");
|
||||
*lengthPtr = strlen(name);
|
||||
*valuePtr = ckalloc(*lengthPtr + 1);
|
||||
*valuePtr = (char *)ckalloc(*lengthPtr + 1);
|
||||
*encodingPtr = NULL;
|
||||
memcpy(*valuePtr, name, (size_t) *lengthPtr + 1);
|
||||
memcpy(*valuePtr, name, *lengthPtr + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -494,7 +491,6 @@ TclpSetInitialEncodings(void)
|
||||
{
|
||||
Tcl_DString encodingName;
|
||||
|
||||
TclpSetInterfaces();
|
||||
Tcl_SetSystemEncoding(NULL,
|
||||
Tcl_GetEncodingNameFromEnvironment(&encodingName));
|
||||
Tcl_DStringFree(&encodingName);
|
||||
@@ -503,17 +499,23 @@ TclpSetInitialEncodings(void)
|
||||
void TclWinSetInterfaces(
|
||||
int dummy) /* Not used. */
|
||||
{
|
||||
TclpSetInterfaces();
|
||||
(void)dummy;
|
||||
}
|
||||
|
||||
const char *
|
||||
Tcl_GetEncodingNameFromEnvironment(
|
||||
Tcl_DString *bufPtr)
|
||||
{
|
||||
UINT acp = GetACP();
|
||||
|
||||
Tcl_DStringInit(bufPtr);
|
||||
Tcl_DStringSetLength(bufPtr, 2+TCL_INTEGER_SPACE);
|
||||
wsprintfA(Tcl_DStringValue(bufPtr), "cp%d", GetACP());
|
||||
Tcl_DStringSetLength(bufPtr, strlen(Tcl_DStringValue(bufPtr)));
|
||||
if (acp == CP_UTF8) {
|
||||
Tcl_DStringAppend(bufPtr, "utf-8", 5);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -575,7 +577,7 @@ TclpSetVariables(
|
||||
if (!osInfoInitialized) {
|
||||
HMODULE handle = GetModuleHandleW(L"NTDLL");
|
||||
int(__stdcall *getversion)(void *) =
|
||||
(int(__stdcall *)(void *)) GetProcAddress(handle, "RtlGetVersion");
|
||||
(int(__stdcall *)(void *))(void *)GetProcAddress(handle, "RtlGetVersion");
|
||||
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
|
||||
if (!getversion || getversion(&osInfo)) {
|
||||
GetVersionExW(&osInfo);
|
||||
@@ -590,10 +592,8 @@ TclpSetVariables(
|
||||
|
||||
Tcl_SetVar2(interp, "tcl_platform", "platform", "windows",
|
||||
TCL_GLOBAL_ONLY);
|
||||
if (osInfo.dwPlatformId < NUMPLATFORMS) {
|
||||
Tcl_SetVar2(interp, "tcl_platform", "os",
|
||||
platforms[osInfo.dwPlatformId], TCL_GLOBAL_ONLY);
|
||||
}
|
||||
Tcl_SetVar2(interp, "tcl_platform", "os",
|
||||
"Windows NT", TCL_GLOBAL_ONLY);
|
||||
wsprintfA(buffer, "%d.%d", osInfo.dwMajorVersion, osInfo.dwMinorVersion);
|
||||
Tcl_SetVar2(interp, "tcl_platform", "osVersion", buffer, TCL_GLOBAL_ONLY);
|
||||
if (sys.oemId.wProcessorArchitecture < NUMPROCESSORS) {
|
||||
@@ -687,7 +687,8 @@ TclpFindVariable(
|
||||
* searches). */
|
||||
{
|
||||
int i, length, result = -1;
|
||||
register const char *env, *p1, *p2;
|
||||
const WCHAR *env;
|
||||
const char *p1, *p2;
|
||||
char *envUpper, *nameUpper;
|
||||
Tcl_DString envString;
|
||||
|
||||
@@ -696,19 +697,21 @@ TclpFindVariable(
|
||||
*/
|
||||
|
||||
length = strlen(name);
|
||||
nameUpper = ckalloc(length + 1);
|
||||
memcpy(nameUpper, name, (size_t) length+1);
|
||||
nameUpper = (char *)ckalloc(length + 1);
|
||||
memcpy(nameUpper, name, length+1);
|
||||
Tcl_UtfToUpper(nameUpper);
|
||||
|
||||
Tcl_DStringInit(&envString);
|
||||
for (i = 0, env = environ[i]; env != NULL; i++, env = environ[i]) {
|
||||
for (i = 0, env = _wenviron[i];
|
||||
env != NULL;
|
||||
i++, env = _wenviron[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.
|
||||
*/
|
||||
|
||||
envUpper = Tcl_ExternalToUtfDString(NULL, env, -1, &envString);
|
||||
envUpper = Tcl_WinTCharToUtf((TCHAR *)env, -1, &envString);
|
||||
p1 = strchr(envUpper, '=');
|
||||
if (p1 == NULL) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user