From db35fe50e94b2e2edd00d34c42c74754cfc5c74d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 12 Dec 2019 21:38:46 +0000 Subject: Little code tweaks, regarding the use of TCL_UTF_MAX or wchar_t. --- generic/tclIO.c | 4 ++-- generic/tclScan.c | 2 +- generic/tclStubInit.c | 2 +- generic/tclZipfs.c | 2 +- unix/tclUnixFile.c | 4 ++-- unix/tclUnixPort.h | 4 ++-- win/tclWinSerial.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index c752589..3ba577d 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -4712,8 +4712,8 @@ Tcl_GetsObj( * Skip the raw bytes that make up the '\n'. */ - char tmp[TCL_UTF_MAX]; int rawRead; + char tmp[TCL_UTF_MAX]; bufPtr = gs.bufPtr; Tcl_ExternalToUtf(NULL, gs.encoding, RemovePoint(bufPtr), @@ -6265,8 +6265,8 @@ ReadChars( */ if (code != TCL_OK) { - char buffer[TCL_UTF_MAX + 1]; int read, decoded, count; + char buffer[TCL_UTF_MAX + 1]; /* * Didn't get everything the buffer could offer diff --git a/generic/tclScan.c b/generic/tclScan.c index 5916137..dea8ffa 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -261,11 +261,11 @@ ValidateFormat( Tcl_UniChar ch = 0; int objIndex, xpgSize, nspace = numVars; int *nassign = TclStackAlloc(interp, nspace * sizeof(int)); - char buf[TCL_UTF_MAX + 1] = ""; Tcl_Obj *errorMsg; /* Place to build an error messages. Note that * these are messy operations because we do * not want to use the formatting engine; * we're inside there! */ + char buf[TCL_UTF_MAX + 1] = ""; /* * Initialize an array that records the number of times a variable is diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index a19992d..41a1c59 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -291,7 +291,7 @@ void *TclWinGetTclInstance() { void *hInstance = NULL; GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, - (const char *)&TclpIsAtty, &hInstance); + (const wchar_t *)&TclpIsAtty, &hInstance); return hInstance; } diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index f6b6711..393db5c 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -3178,7 +3178,7 @@ TclZipfs_TclLibrary(void) #ifdef _WIN32 HMODULE hModule; WCHAR wName[MAX_PATH + LIBRARY_SIZE]; - char dllName[(MAX_PATH + LIBRARY_SIZE) * TCL_UTF_MAX]; + char dllName[(MAX_PATH + LIBRARY_SIZE) * 3]; #endif /* _WIN32 */ /* diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index bf033d2..ca3bccf 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -42,8 +42,8 @@ TclpFindExecutable( Tcl_Encoding encoding; #ifdef __CYGWIN__ int length; - char buf[PATH_MAX * 2]; - char name[PATH_MAX * TCL_UTF_MAX + 1]; + wchar_t buf[PATH_MAX]; + char name[PATH_MAX * 3 + 1]; GetModuleFileNameW(NULL, buf, PATH_MAX); cygwin_conv_path(3, buf, name, PATH_MAX); length = strlen(name); diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h index c982585..db38fd3 100644 --- a/unix/tclUnixPort.h +++ b/unix/tclUnixPort.h @@ -96,8 +96,8 @@ typedef off_t Tcl_SeekOffset; # define SOCKET unsigned int # define WSAEWOULDBLOCK 10035 typedef unsigned short WCHAR; - __declspec(dllimport) extern __stdcall int GetModuleHandleExW(unsigned int, const char *, void *); - __declspec(dllimport) extern __stdcall int GetModuleFileNameW(void *, const char *, int); + __declspec(dllimport) extern __stdcall int GetModuleHandleExW(unsigned int, const void *, void *); + __declspec(dllimport) extern __stdcall int GetModuleFileNameW(void *, const void *, int); __declspec(dllimport) extern __stdcall int WideCharToMultiByte(int, int, const void *, int, char *, int, const char *, void *); __declspec(dllimport) extern __stdcall int MultiByteToWideChar(int, int, const char *, int, diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index 65af10f..e945055 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -2152,7 +2152,7 @@ SerialGetOptionProc( Tcl_DStringStartSublist(dsPtr); } if (len==0 || (len>1 && strncmp(optionName, "-xchar", len) == 0)) { - char buf[TCL_UTF_MAX]; + char buf[4]; valid = 1; if (!GetCommState(infoPtr->handle, &dcb)) { -- cgit v0.12