From 63ec99cd74c727ff07213127dd09d2d48e7736b1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 3 Apr 2020 08:36:50 +0000 Subject: Make sure that "Windows NT" is the only supported Windows platform. On Windows CE, no chance that Tcl 8.6 will ever run .... Windows XP is the minimum now. --- unix/tclUnixInit.c | 11 ++--------- win/tclWin32Dll.c | 29 +++++++++-------------------- win/tclWinInit.c | 16 ++++------------ 3 files changed, 15 insertions(+), 41 deletions(-) diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index 406c2b0..b189fee 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -39,11 +39,6 @@ DLLIMPORT extern __stdcall void FreeLibrary(void *); DLLIMPORT extern __stdcall void *GetProcAddress(void *, const char *); DLLIMPORT extern __stdcall void GetSystemInfo(void *); -#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", @@ -891,10 +886,8 @@ TclpSetVariables( GetSystemInfo(&sysInfo); - 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); sprintf(buffer, "%d.%d", osInfo.dwMajorVersion, osInfo.dwMinorVersion); Tcl_SetVar2(interp, "tcl_platform", "osVersion", buffer, TCL_GLOBAL_ONLY); if (sysInfo.wProcessorArchitecture < NUMPROCESSORS) { diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index c33787d..9061dd0 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -23,7 +23,6 @@ */ static HINSTANCE hInstance; /* HINSTANCE of this DLL. */ -static int platformId; /* Running under NT, or 95/98? */ /* * VC++ 5.x has no 'cpuid' assembler instruction, so we must emulate it @@ -186,18 +185,14 @@ TclWinInit( hInstance = hInst; os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); GetVersionExW(&os); - platformId = os.dwPlatformId; /* - * We no longer support Win32s or Win9x, so just in case someone manages - * to get a runtime there, make sure they know that. + * We no longer support Win32s or Win9x or Windows CE, so just in case + * someone manages to get a runtime there, make sure they know that. */ - if (platformId == VER_PLATFORM_WIN32s) { - Tcl_Panic("Win32s is not a supported platform"); - } - if (platformId == VER_PLATFORM_WIN32_WINDOWS) { - Tcl_Panic("Windows 9x is not a supported platform"); + if (os.dwPlatformId != VER_PLATFORM_WIN32_NT) { + Tcl_Panic("Windows NT is the only supported platform"); } } @@ -210,11 +205,8 @@ TclWinInit( * conditional code. * * Results: - * The return value is one of: - * VER_PLATFORM_WIN32s Win32s on Windows 3.1 (not supported) - * VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95, 98, ME (not supported) + * The return value is always: * VER_PLATFORM_WIN32_NT Win32 on Windows NT, 2000, XP - * VER_PLATFORM_WIN32_CE Win32 on Windows CE * * Side effects: * None. @@ -225,7 +217,7 @@ TclWinInit( int TclWinGetPlatformId(void) { - return platformId; + return VER_PLATFORM_WIN32_NT; } /* @@ -264,11 +256,8 @@ TclWinNoBackslash( * * TclWinEncodingsCleanup -- * - * Called during finalization to free up any encodings we use. - * - * We also clean up any memory allocated in our mount point map which is - * used to follow certain kinds of symlinks. That code should never be - * used once encodings are taken down. + * Called during finalization to clean up any memory allocated in our + * mount point map which is used to follow certain kinds of symlinks. * * Results: * None. @@ -425,7 +414,7 @@ TclWinDriveLetterForVolMountPoint( * We couldn't find it, so we must iterate over the letters. */ - for (drive[0] = L'A'; drive[0] <= L'Z'; drive[0]++) { + for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++) { /* * Try to read the volume mount point and see where it points. */ diff --git a/win/tclWinInit.c b/win/tclWinInit.c index 2e4694a..4b3b6d4 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -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", @@ -595,10 +589,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) { -- cgit v0.12 From 3e7df06557bc26dbbf2b7e7319eed92b3648f9d7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 3 Apr 2020 09:13:27 +0000 Subject: Simplify implementation of TclUtfToUCS4: The #undefined Tcl_UtfToUniChar() already does everything for use here (Unlike in Tcl 8.6, with has to live without TIP #542) --- generic/tclInt.h | 6 +++++- generic/tclUtf.c | 35 ++++------------------------------- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/generic/tclInt.h b/generic/tclInt.h index a50bf7d..16e1aa8 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3251,7 +3251,11 @@ MODULE_SCOPE void TclRegisterCommandTypeName( MODULE_SCOPE int TclUtfCmp(const char *cs, const char *ct); MODULE_SCOPE int TclUtfCasecmp(const char *cs, const char *ct); MODULE_SCOPE int TclUtfCount(int ch); -MODULE_SCOPE int TclUtfToUCS4(const char *src, int *ucs4Ptr); +#if TCL_UTF_MAX > 3 +# define TclUtfToUCS4 Tcl_UtfToUniChar +#else + MODULE_SCOPE int TclUtfToUCS4(const char *src, int *ucs4Ptr); +#endif MODULE_SCOPE Tcl_Obj * TclpNativeToNormalized(ClientData clientData); MODULE_SCOPE Tcl_Obj * TclpFilesystemPathType(Tcl_Obj *pathPtr); MODULE_SCOPE int TclpDlopen(Tcl_Interp *interp, Tcl_Obj *pathPtr, diff --git a/generic/tclUtf.c b/generic/tclUtf.c index e65f44d..47855dd 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -2443,44 +2443,17 @@ TclUniCharMatch( *--------------------------------------------------------------------------- */ +#if TCL_UTF_MAX <= 3 int TclUtfToUCS4( const char *src, /* The UTF-8 string. */ int *ucs4Ptr) /* Filled with the UCS4 codepoint represented * by the UTF-8 string. */ { - int len, fullchar; - Tcl_UniChar ch = 0; - - len = TclUtfToUniChar(src, &ch); - fullchar = ch; - -#if TCL_UTF_MAX <= 3 - /* Limited interfaces -- must use and decode surrogates */ - - if ((ch >= 0xD800) && len < 3) { -/****** - ****** Note the #undef TCL_UtfToUniChar gets in our way here. - ****** - len += Tcl_UtfToUniChar(src + len, &ch); - ****** - ****** We have to do the subtitution ourselves. - ******/ - - len += Tcl_UtfToChar16(src + len, &ch); - -/****** - ****** We might also solve this by moving this routine higher in the file. - ****** Or there might be a more sensible foundation in this branch. - ******/ - - fullchar = (((fullchar & 0x3FF) << 10) | (ch & 0x3FF)) + 0x10000; - } -#endif - - *ucs4Ptr = fullchar; - return len; + /* Make use of the #undef Tcl_UtfToUniChar above, which already handles UCS4. */ + return Tcl_UtfToUniChar(src, &ch); } +#endif /* * Local Variables: -- cgit v0.12