From 9d7eafebca8461def3b0ec64fd2996717dc7905a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 29 Jun 2019 13:57:37 +0000 Subject: Code cleanup, like TCHAR -> WCHAR and TEXT("xxx") -> L"xxx", since we always compile in UNICODE mode. --- win/tclWin32Dll.c | 4 ++-- win/tclWinChan.c | 2 +- win/tclWinConsole.c | 14 ++++++-------- win/tclWinError.c | 4 ++-- win/tclWinFCmd.c | 2 +- win/tclWinFile.c | 28 ++++++++++++++-------------- win/tclWinInt.h | 6 +++--- win/tclWinLoad.c | 2 +- win/tclWinNotify.c | 2 +- win/tclWinPanic.c | 4 ++-- 10 files changed, 33 insertions(+), 35 deletions(-) diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index 36205e1..9e5885c 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -290,7 +290,7 @@ TclWinDriveLetterForVolMountPoint( { MountPointMap *dlIter, *dlPtr2; WCHAR Target[55]; /* Target of mount at mount point */ - WCHAR drive[4] = TEXT("A:\\"); + WCHAR drive[4] = L"A:\\"; /* * Detect the volume mounted there. Unfortunately, there is no simple way @@ -368,7 +368,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/tclWinChan.c b/win/tclWinChan.c index dcd8528..3b6e4e4 100644 --- a/win/tclWinChan.c +++ b/win/tclWinChan.c @@ -1571,7 +1571,7 @@ NativeIsComPort( * The 4th character must be a digit 1..9 */ - if ((p[3] < L'1') || (p[3] > L'9')) { + if ((p[3] < '1') || (p[3] > '9')) { return 0; } return 1; diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c index 28969d6..3668ae3 100644 --- a/win/tclWinConsole.c +++ b/win/tclWinConsole.c @@ -202,8 +202,8 @@ static const Tcl_ChannelType consoleChannelType = { * * ReadConsoleBytes, WriteConsoleBytes -- * - * Wrapper for ReadConsole{A,W}, that takes and returns number of bytes - * instead of number of TCHARS. + * Wrapper for ReadConsoleW, that takes and returns number of bytes + * instead of number of WCHARS. * *---------------------------------------------------------------------- */ @@ -217,7 +217,6 @@ ReadConsoleBytes( { DWORD ntchars; BOOL result; - int tcharsize = sizeof(TCHAR); /* * If user types a Ctrl-Break or Ctrl-C, ReadConsole will return @@ -230,11 +229,11 @@ ReadConsoleBytes( * will run and take whatever action it deems appropriate. */ do { - result = ReadConsole(hConsole, lpBuffer, nbytes / tcharsize, &ntchars, + result = ReadConsole(hConsole, lpBuffer, nbytes / sizeof(WCHAR), &ntchars, NULL); } while (result && ntchars == 0 && GetLastError() == ERROR_OPERATION_ABORTED); if (nbytesread != NULL) { - *nbytesread = ntchars * tcharsize; + *nbytesread = ntchars * sizeof(WCHAR); } return result; } @@ -248,12 +247,11 @@ WriteConsoleBytes( { DWORD ntchars; BOOL result; - int tcharsize = sizeof(TCHAR); - result = WriteConsole(hConsole, lpBuffer, nbytes / tcharsize, &ntchars, + result = WriteConsole(hConsole, lpBuffer, nbytes / sizeof(WCHAR), &ntchars, NULL); if (nbyteswritten != NULL) { - *nbyteswritten = ntchars * tcharsize; + *nbyteswritten = ntchars * sizeof(WCHAR); } return result; } diff --git a/win/tclWinError.c b/win/tclWinError.c index bce81fa..18f290f 100644 --- a/win/tclWinError.c +++ b/win/tclWinError.c @@ -394,14 +394,14 @@ tclWinDebugPanic( char buf[TCL_MAX_WARN_LEN * 3]; vsnprintf(buf, sizeof(buf), format, argList); - msgString[TCL_MAX_WARN_LEN-1] = L'\0'; + msgString[TCL_MAX_WARN_LEN-1] = '\0'; MultiByteToWideChar(CP_UTF8, 0, buf, -1, msgString, TCL_MAX_WARN_LEN); /* * Truncate MessageBox string if it is too long to not overflow the buffer. */ - if (msgString[TCL_MAX_WARN_LEN-1] != L'\0') { + if (msgString[TCL_MAX_WARN_LEN-1] != '\0') { memcpy(msgString + (TCL_MAX_WARN_LEN - 5), L" ...", 5 * sizeof(WCHAR)); } OutputDebugStringW(msgString); diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c index 2531ba6..78489ca 100644 --- a/win/tclWinFCmd.c +++ b/win/tclWinFCmd.c @@ -455,7 +455,7 @@ DoRenameFile( return TCL_ERROR; } nativeTmp = (WCHAR *) tempBuf; - nativeRest[0] = L'\0'; + nativeRest[0] = '\0'; result = TCL_ERROR; nativePrefix = (WCHAR *) L"tclr"; diff --git a/win/tclWinFile.c b/win/tclWinFile.c index fa5f28e..1c4379a 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -395,11 +395,11 @@ WinSymLinkDirectory( */ for (loop = nativeTarget; *loop != 0; loop++) { - if (*loop == L'/') { - *loop = L'\\'; + if (*loop == '/') { + *loop = '\\'; } } - if ((nativeTarget[len-1] == L'\\') && (nativeTarget[len-2] != L':')) { + if ((nativeTarget[len-1] == '\\') && (nativeTarget[len-2] != ':')) { nativeTarget[len-1] = 0; } @@ -572,7 +572,7 @@ WinReadLinkDirectory( */ offset = 0; - if (reparseBuffer->MountPointReparseBuffer.PathBuffer[0] == L'\\') { + if (reparseBuffer->MountPointReparseBuffer.PathBuffer[0] == '\\') { /* * Check whether this is a mounted volume. */ @@ -586,7 +586,7 @@ WinReadLinkDirectory( * to fix here. It doesn't seem very well documented. */ - reparseBuffer->MountPointReparseBuffer.PathBuffer[1]=L'\\'; + reparseBuffer->MountPointReparseBuffer.PathBuffer[1] = '\\'; /* * Check if a corresponding drive letter exists, and use that @@ -814,7 +814,7 @@ tclWinDebugPanic( va_start(argList, format); vsnprintf(buf, sizeof(buf), format, argList); - msgString[TCL_MAX_WARN_LEN-1] = L'\0'; + msgString[TCL_MAX_WARN_LEN-1] = '\0'; MultiByteToWideChar(CP_UTF8, 0, buf, -1, msgString, TCL_MAX_WARN_LEN); /* @@ -822,7 +822,7 @@ tclWinDebugPanic( * and cause possible oversized window error. */ - if (msgString[TCL_MAX_WARN_LEN-1] != L'\0') { + if (msgString[TCL_MAX_WARN_LEN-1] != '\0') { memcpy(msgString + (TCL_MAX_WARN_LEN - 5), L" ...", 5 * sizeof(WCHAR)); } if (IsDebuggerPresent()) { @@ -1504,7 +1504,7 @@ TclpGetUserHome( DWORD i, size = MAX_PATH; wHomeDir = uiPtr->usri1_home_dir; - if ((wHomeDir != NULL) && (wHomeDir[0] != L'\0')) { + if ((wHomeDir != NULL) && (wHomeDir[0] != '\0')) { size = lstrlenW(wHomeDir); TclWCharToUtfDString(wHomeDir, size, bufferPtr); } else { @@ -2583,8 +2583,8 @@ TclpObjNormalizePath( for (i=0 ; i= L'a') { - wc -= (L'a' - L'A'); + if (wc >= 'a') { + wc -= ('a' - 'A'); ((WCHAR *) nativePath)[i] = wc; } } @@ -2674,8 +2674,8 @@ TclpObjNormalizePath( if (isDrive) { WCHAR drive = ((WCHAR *) nativePath)[0]; - if (drive >= L'a') { - drive -= (L'a' - L'A'); + if (drive >= 'a') { + drive -= ('a' - 'A'); ((WCHAR *) nativePath)[0] = drive; } Tcl_DStringAppend(&dsNorm, (const char *)nativePath, @@ -2772,8 +2772,8 @@ TclpObjNormalizePath( * We have to make the drive letter uppercase. */ - if (wpath[0] >= L'a') { - wpath[0] -= (L'a' - L'A'); + if (wpath[0] >= 'a') { + wpath[0] -= ('a' - 'A'); } Tcl_DStringAppend(&dsNorm, (const char *) wpath, wpathlen * sizeof(WCHAR)); diff --git a/win/tclWinInt.h b/win/tclWinInt.h index ba07d0e..07c1b9e 100644 --- a/win/tclWinInt.h +++ b/win/tclWinInt.h @@ -58,9 +58,9 @@ MODULE_SCOPE Tcl_Channel TclWinOpenSerialChannel(HANDLE handle, char *channelName, int permissions); MODULE_SCOPE HANDLE TclWinSerialOpen(HANDLE handle, const WCHAR *name, DWORD access); -MODULE_SCOPE int TclWinSymLinkCopyDirectory(const TCHAR *LinkOriginal, - const TCHAR *LinkCopy); -MODULE_SCOPE int TclWinSymLinkDelete(const TCHAR *LinkOriginal, +MODULE_SCOPE int TclWinSymLinkCopyDirectory(const WCHAR *LinkOriginal, + const WCHAR *LinkCopy); +MODULE_SCOPE int TclWinSymLinkDelete(const WCHAR *LinkOriginal, int linkOnly); MODULE_SCOPE int TclWinFileOwned(Tcl_Obj *); diff --git a/win/tclWinLoad.c b/win/tclWinLoad.c index 69263e9..dc673d2 100644 --- a/win/tclWinLoad.c +++ b/win/tclWinLoad.c @@ -64,7 +64,7 @@ TclpDlopen( int flags) { HINSTANCE hInstance = NULL; - const TCHAR *nativeName; + const WCHAR *nativeName; Tcl_LoadHandle handlePtr; DWORD firstError; diff --git a/win/tclWinNotify.c b/win/tclWinNotify.c index b34fc4f..89a1b66 100644 --- a/win/tclWinNotify.c +++ b/win/tclWinNotify.c @@ -49,7 +49,7 @@ static Tcl_ThreadDataKey dataKey; */ static int notifierCount = 0; -static const TCHAR className[] = TEXT("TclNotifier"); +static const WCHAR className[] = L"TclNotifier"; static int initialized = 0; static CRITICAL_SECTION notifierMutex; diff --git a/win/tclWinPanic.c b/win/tclWinPanic.c index 5c6e02d..fbd3e46 100644 --- a/win/tclWinPanic.c +++ b/win/tclWinPanic.c @@ -42,14 +42,14 @@ Tcl_ConsolePanic( va_start(argList, format); vsnprintf(buf+3, sizeof(buf)-3, format, argList); buf[sizeof(buf)-1] = 0; - msgString[TCL_MAX_WARN_LEN-1] = L'\0'; + msgString[TCL_MAX_WARN_LEN-1] = '\0'; MultiByteToWideChar(CP_UTF8, 0, buf+3, -1, msgString, TCL_MAX_WARN_LEN); /* * Truncate MessageBox string if it is too long to not overflow the buffer. */ - if (msgString[TCL_MAX_WARN_LEN-1] != L'\0') { + if (msgString[TCL_MAX_WARN_LEN-1] != '\0') { memcpy(msgString + (TCL_MAX_WARN_LEN - 5), L" ...", 5 * sizeof(WCHAR)); } -- cgit v0.12