From ac77633a254c2a5bb52de4db50df963c652d9705 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 29 Jul 2019 08:47:02 +0000 Subject: typo --- tests/unixEmbed.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index c2dc073..7d26fbf 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -341,7 +341,7 @@ test unixEmbed-2.4 {EmbeddedEventProc procedure} -constraints { test unixEmbed-3.1 {ContainerEventProc procedure, detect creation} -constraints { - unix testembed notPortable + unix testembed nonPortable } -body { frame .f1 -container 1 -width 200 -height 50 pack .f1 -- cgit v0.12 From 1ab87b68045ba6b3538301fd0d976bf4fbdd5d46 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 30 Jul 2019 13:26:07 +0000 Subject: Two times Tcl_Free() -> ckfree() --- generic/ttk/ttkTreeview.c | 2 +- unix/tkUnixWm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index b1739b6..cda98a0 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -1066,7 +1066,7 @@ static void TreeviewCleanup(void *recordPtr) TreeviewFreeColumns(tv); if (tv->tree.displayColumns) - Tcl_Free((ClientData)tv->tree.displayColumns); + ckfree((ClientData)tv->tree.displayColumns); foreachHashEntry(&tv->tree.items, FreeItemCB); Tcl_DeleteHashTable(&tv->tree.items); diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 9ed9082..7b69713 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -2444,7 +2444,7 @@ WmIconphotoCmd( for (i = 3 + isDefault; i < objc; i++) { photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i])); if (photo == NULL) { - Tcl_Free((char *) iconPropertyData); + ckfree((char *) iconPropertyData); return TCL_ERROR; } Tk_PhotoGetSize(photo, &width, &height); -- cgit v0.12 From b50b9471ff522194c657fe4228da646eaa8e5698 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 30 Jul 2019 14:45:38 +0000 Subject: Use WCHAR in stead of TCHAR (almost) everywhere, since we now only support compiling Tcl in UNICODE mode anyway. --- win/tkWinButton.c | 8 ++++---- win/tkWinClipboard.c | 2 +- win/tkWinCursor.c | 2 +- win/tkWinDialog.c | 6 +++--- win/tkWinEmbed.c | 6 +++--- win/tkWinInit.c | 6 +++--- win/tkWinKey.c | 6 +++--- win/tkWinMenu.c | 14 +++++++------- win/tkWinPixmap.c | 6 +++--- win/tkWinScrlbr.c | 2 +- win/tkWinTest.c | 2 +- win/tkWinWm.c | 12 ++++++------ win/tkWinX.c | 8 ++++---- win/ttkWinMonitor.c | 4 ++-- 14 files changed, 42 insertions(+), 42 deletions(-) diff --git a/win/tkWinButton.c b/win/tkWinButton.c index e91857c..52b6e2a 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -131,7 +131,7 @@ InitBoxes(void) ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - hrsrc = FindResource(module, TEXT("buttons"), RT_BITMAP); + hrsrc = FindResource(module, L"buttons", RT_BITMAP); if (hrsrc == NULL) { Tcl_Panic("FindResource() failed for buttons bitmap resource, " "resources in tk_base.rc must be linked into Tk dll or static executable"); @@ -242,15 +242,15 @@ CreateProc( { Window window; HWND parent; - const TCHAR *class; + const WCHAR *class; WinButton *butPtr = (WinButton *)instanceData; parent = Tk_GetHWND(parentWin); if (butPtr->info.type == TYPE_LABEL) { - class = TEXT("STATIC"); + class = L"STATIC"; butPtr->style = SS_OWNERDRAW | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS; } else { - class = TEXT("BUTTON"); + class = L"BUTTON"; butPtr->style = BS_OWNERDRAW | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS; } butPtr->hwnd = CreateWindow(class, NULL, butPtr->style, diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index 19874fb..06200d4 100644 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -79,7 +79,7 @@ TkSelGetSelection( goto error; } data = GlobalLock(handle); - Tcl_WinTCharToUtf((TCHAR *)data, -1, &ds); + Tcl_WinTCharToUtf((WCHAR *)data, -1, &ds); GlobalUnlock(handle); } else if (IsClipboardFormatAvailable(CF_TEXT)) { /* diff --git a/win/tkWinCursor.c b/win/tkWinCursor.c index 622ba4d..6a9dc75 100644 --- a/win/tkWinCursor.c +++ b/win/tkWinCursor.c @@ -41,7 +41,7 @@ typedef struct { static struct CursorName { const char *name; - LPCTSTR id; + LPCWSTR id; } cursorNames[] = { {"starting", IDC_APPSTARTING}, {"arrow", IDC_ARROW}, diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index bbf49ca..26d11ed 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -790,7 +790,7 @@ Tk_ChooseColorObjCmd( chooseColor.Flags = CC_RGBINIT | CC_FULLOPEN | CC_ENABLEHOOK; chooseColor.lCustData = (LPARAM) NULL; chooseColor.lpfnHook = (LPOFNHOOKPROC) ColorDlgHookProc; - chooseColor.lpTemplateName = (LPTSTR) interp; + chooseColor.lpTemplateName = (LPWSTR) interp; for (i = 1; i < objc; i += 2) { int index; @@ -2491,7 +2491,7 @@ Tk_ChooseDirectoryObjCmd( if (ofnOpts.titleObj != NULL) { Tcl_WinUtfToTChar(Tcl_GetString(ofnOpts.titleObj), -1, &titleString); - bInfo.lpszTitle = (LPTSTR) Tcl_DStringValue(&titleString); + bInfo.lpszTitle = (LPWSTR) Tcl_DStringValue(&titleString); } else { bInfo.lpszTitle = L"Please choose a directory, then select OK."; } @@ -3151,7 +3151,7 @@ HookProc( Tcl_WinUtfToTChar(Tcl_GetString(phd->titleObj), -1, &title); if (Tcl_DStringLength(&title) > 0) { - SetWindowText(hwndDlg, (LPCTSTR) Tcl_DStringValue(&title)); + SetWindowText(hwndDlg, (LPCWSTR) Tcl_DStringValue(&title)); } Tcl_DStringFree(&title); } diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index 329fd6e..f33a275 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -303,10 +303,10 @@ TkpUseWindow( * order to avoid bug 1096074 in future. */ - TCHAR msg[256]; + WCHAR msg[256]; - wsprintf(msg, TEXT("Unable to get information of window \"%.40hs\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching."), string); - if (IDCANCEL == MessageBox(hwnd, msg, TEXT("Tk Warning"), + wsprintf(msg, L"Unable to get information of window \"%.40hs\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); + if (IDCANCEL == MessageBox(hwnd, msg, L"Tk Warning", MB_OKCANCEL | MB_ICONWARNING)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Operation has been canceled", -1)); diff --git a/win/tkWinInit.c b/win/tkWinInit.c index 977474c..690574e 100644 --- a/win/tkWinInit.c +++ b/win/tkWinInit.c @@ -178,14 +178,14 @@ Tcl_Obj* TkWin32ErrorObj( HRESULT hrError) { - LPTSTR lpBuffer = NULL, p = NULL; - TCHAR sBuffer[30]; + LPWSTR lpBuffer = NULL, p = NULL; + WCHAR sBuffer[30]; Tcl_Obj* errPtr = NULL; Tcl_DString ds; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, (DWORD)hrError, - LANG_NEUTRAL, (LPTSTR)&lpBuffer, 0, NULL); + LANG_NEUTRAL, (LPWSTR)&lpBuffer, 0, NULL); if (lpBuffer == NULL) { lpBuffer = sBuffer; diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 8db34af..c1f9891 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -186,7 +186,7 @@ KeycodeToKeysym( { BYTE keys[256]; int result, deadkey, shift; - TCHAR buf[4]; + WCHAR buf[4]; unsigned int scancode = MapVirtualKey(keycode, 0); /* @@ -572,7 +572,7 @@ TkpSetKeycodeAndState( } } if (keySym >= 0x20) { - result = VkKeyScan((TCHAR) keySym); + result = VkKeyScan((WCHAR) keySym); if (result != -1) { shift = result >> 8; if (shift & 1) @@ -625,7 +625,7 @@ XKeysymToKeycode( } } if (keysym >= 0x20) { - result = VkKeyScan((TCHAR) keysym); + result = VkKeyScan((WCHAR) keysym); if (result != -1) { return (KeyCode) (result & 0xff); } diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index ed2ce93..329c0af 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -19,8 +19,8 @@ * The class of the window for popup menus. */ -#define MENU_CLASS_NAME TEXT("MenuWindowClass") -#define EMBEDDED_MENU_CLASS_NAME TEXT("EmbeddedMenuWindowClass") +#define MENU_CLASS_NAME L"MenuWindowClass" +#define EMBEDDED_MENU_CLASS_NAME L"EmbeddedMenuWindowClass" /* * Used to align a windows bitmap inside a rectangle @@ -573,7 +573,7 @@ ReconfigureWindowsMenu( TkMenuEntry *mePtr; HMENU winMenuHdl = (HMENU) menuPtr->platformData; char *itemText = NULL; - const TCHAR *lpNewItem; + const WCHAR *lpNewItem; UINT flags; UINT itemID; int i, count, systemMenu = 0, base; @@ -610,10 +610,10 @@ ReconfigureWindowsMenu( if ((menuPtr->menuType == MENUBAR) || (menuPtr->menuFlags & MENU_SYSTEM_MENU)) { Tcl_WinUtfToTChar(itemText, -1, &translatedText); - lpNewItem = (const TCHAR *) Tcl_DStringValue(&translatedText); + lpNewItem = (const WCHAR *) Tcl_DStringValue(&translatedText); flags |= MF_STRING; } else { - lpNewItem = (LPCTSTR) mePtr; + lpNewItem = (LPCWSTR) mePtr; flags |= MF_OWNERDRAW; } @@ -3492,7 +3492,7 @@ TkpMenuThreadInit(void) ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - tsdPtr->menuHWND = CreateWindow(MENU_CLASS_NAME, TEXT("MenuWindow"), WS_POPUP, + tsdPtr->menuHWND = CreateWindow(MENU_CLASS_NAME, L"MenuWindow", WS_POPUP, 0, 0, 10, 10, NULL, NULL, Tk_GetHINSTANCE(), NULL); if (!tsdPtr->menuHWND) { @@ -3500,7 +3500,7 @@ TkpMenuThreadInit(void) } tsdPtr->embeddedMenuHWND = - CreateWindow(EMBEDDED_MENU_CLASS_NAME, TEXT("EmbeddedMenuWindow"), + CreateWindow(EMBEDDED_MENU_CLASS_NAME, L"EmbeddedMenuWindow", WS_POPUP, 0, 0, 10, 10, NULL, NULL, Tk_GetHINSTANCE(), NULL); if (!tsdPtr->embeddedMenuHWND) { diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c index aa1ebde..9850e26 100644 --- a/win/tkWinPixmap.c +++ b/win/tkWinPixmap.c @@ -104,9 +104,9 @@ Tk_GetPixmap( FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&lpMsgBuf, 0, NULL)) { - MessageBox(NULL, (LPTSTR) lpMsgBuf, - TEXT("Tk_GetPixmap: Error from CreateDIBSection"), + (LPWSTR)&lpMsgBuf, 0, NULL)) { + MessageBox(NULL, (LPWSTR) lpMsgBuf, + L"Tk_GetPixmap: Error from CreateDIBSection", MB_OK | MB_ICONINFORMATION); LocalFree(lpMsgBuf); } diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c index 43a33ee..1edb1d8 100644 --- a/win/tkWinScrlbr.c +++ b/win/tkWinScrlbr.c @@ -223,7 +223,7 @@ CreateProc( | SBS_HORZ; } - scrollPtr->hwnd = CreateWindow(TEXT("SCROLLBAR"), NULL, style, + scrollPtr->hwnd = CreateWindow(L"SCROLLBAR", NULL, style, Tk_X(tkwin), Tk_Y(tkwin), Tk_Width(tkwin), Tk_Height(tkwin), parent, NULL, Tk_GetHINSTANCE(), NULL); diff --git a/win/tkWinTest.c b/win/tkWinTest.c index e386605..b09fe1b 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -549,7 +549,7 @@ TestgetwindowinfoObjCmd( Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("id", 2), Tcl_NewWideIntObj(GetWindowLongPtr((HWND)(size_t)hwnd, GWL_ID))); - cch = GetWindowText((HWND)(size_t)hwnd, (LPTSTR)buf, cchBuf); + cch = GetWindowText((HWND)(size_t)hwnd, buf, cchBuf); Tcl_WinTCharToUtf(buf, cch * sizeof (WCHAR), &ds); textObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); diff --git a/win/tkWinWm.c b/win/tkWinWm.c index c0f60d8..e41e68d 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -883,7 +883,7 @@ InitWindowClass( class.lpszClassName = TK_WIN_TOPLEVEL_CLASS_NAME; class.lpfnWndProc = WmProc; if (titlebaricon == NULL) { - class.hIcon = LoadIcon(Tk_GetHINSTANCE(), TEXT("tk")); + class.hIcon = LoadIcon(Tk_GetHINSTANCE(), L"tk"); } else { class.hIcon = GetIcon(titlebaricon, ICON_BIG); if (class.hIcon == NULL) { @@ -1248,7 +1248,7 @@ ReadIconFromFile( } Tcl_WinUtfToTChar(file, -1, &ds2); Tcl_DStringFree(&ds); - res = (DWORD *)SHGetFileInfo((TCHAR *)Tcl_DStringValue(&ds2), 0, &sfiSM, + res = (DWORD *)SHGetFileInfo((WCHAR *)Tcl_DStringValue(&ds2), 0, &sfiSM, sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_ICON); if (res != 0) { @@ -1256,7 +1256,7 @@ ReadIconFromFile( unsigned size; Tcl_ResetResult(interp); - res = (DWORD *)SHGetFileInfo((TCHAR *)Tcl_DStringValue(&ds2), 0, &sfi, + res = (DWORD *)SHGetFileInfo((WCHAR *)Tcl_DStringValue(&ds2), 0, &sfi, sizeof(SHFILEINFO), SHGFI_ICON); /* @@ -2131,7 +2131,7 @@ UpdateWrapper( wmPtr->wrapper = CreateWindowEx(wmPtr->exStyle, TK_WIN_TOPLEVEL_CLASS_NAME, - (LPCTSTR) Tcl_DStringValue(&titleString), + (LPCWSTR) Tcl_DStringValue(&titleString), wmPtr->style, x, y, width, height, parentHWND, NULL, Tk_GetHINSTANCE(), NULL); Tcl_DStringFree(&titleString); @@ -5459,7 +5459,7 @@ WmTitleCmd( } if (objc == 3) { if (wrapper) { - TCHAR buf[256]; + WCHAR buf[256]; Tcl_DString titleString; int size = 256; @@ -5485,7 +5485,7 @@ WmTitleCmd( Tcl_DString titleString; Tcl_WinUtfToTChar(wmPtr->title, -1, &titleString); - SetWindowText(wrapper, (LPCTSTR) Tcl_DStringValue(&titleString)); + SetWindowText(wrapper, (LPCWSTR) Tcl_DStringValue(&titleString)); Tcl_DStringFree(&titleString); } } diff --git a/win/tkWinX.c b/win/tkWinX.c index 0cc7765..14075c4 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -127,7 +127,7 @@ TkGetServerInfo( OSVERSIONINFOW os; if (!buffer[0]) { - HANDLE handle = GetModuleHandle(TEXT("NTDLL")); + HANDLE handle = GetModuleHandle(L"NTDLL"); int(__stdcall *getversion)(void *) = (int(__stdcall *)(void *))GetProcAddress(handle, "RtlGetVersion"); os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); @@ -258,7 +258,7 @@ TkWinXInit( if (GetLocaleInfo(LANGIDFROMLCID(PTR2INT(GetKeyboardLayout(0))), LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, - (LPTSTR) &lpCP, sizeof(lpCP)/sizeof(TCHAR)) + (LPWSTR) &lpCP, sizeof(lpCP)/sizeof(WCHAR)) && TranslateCharsetInfo(INT2PTR(lpCP), &lpCs, TCI_SRCCODEPAGE)) { UpdateInputLanguage((int) lpCs.ciCharset); } @@ -346,8 +346,8 @@ TkWinGetPlatformTheme(void) if ((os.dwMajorVersion == 5 && os.dwMinorVersion == 1)) { HKEY hKey; - LPCTSTR szSubKey = TEXT("Control Panel\\Appearance"); - LPCTSTR szCurrent = TEXT("Current"); + LPCWSTR szSubKey = L"Control Panel\\Appearance"; + LPCWSTR szCurrent = L"Current"; DWORD dwSize = 200; char pBuffer[200]; diff --git a/win/ttkWinMonitor.c b/win/ttkWinMonitor.c index 5d9cf0a..e3608f3 100644 --- a/win/ttkWinMonitor.c +++ b/win/ttkWinMonitor.c @@ -72,8 +72,8 @@ CreateThemeMonitorWindow(HINSTANCE hinst, Tcl_Interp *interp) { WNDCLASSEX wc; HWND hwnd = NULL; - TCHAR title[32] = TEXT("TtkMonitorWindow"); - TCHAR name[32] = TEXT("TtkMonitorClass"); + WCHAR title[32] = L"TtkMonitorWindow"; + WCHAR name[32] = L"TtkMonitorClass"; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; -- cgit v0.12 From d9d7ac4b437138307673eb8eed3d6753d7c237f6 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 30 Jul 2019 20:59:11 +0000 Subject: A few end-of-line spacings --- doc/tk_mac.n | 2 +- library/demos/twind.tcl | 2 +- macosx/tkMacOSXBitmap.c | 2 +- macosx/tkMacOSXScrlbr.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/tk_mac.n b/doc/tk_mac.n index da960ff..6c50281 100644 --- a/doc/tk_mac.n +++ b/doc/tk_mac.n @@ -51,7 +51,7 @@ the command is absent, no action will be taken. The default Apple Event handler for AEDoScriptHandler. This command, if defined, executes a Tcl file when an AppleScript sends a .QW "do script" -command to Wish with a file path as a parameter. +command to Wish with a file path as a parameter. .TP \fB::tk::mac::DoScriptText\fR . diff --git a/library/demos/twind.tcl b/library/demos/twind.tcl index df879e3..45d1da8 100644 --- a/library/demos/twind.tcl +++ b/library/demos/twind.tcl @@ -315,7 +315,7 @@ proc changeBg {t c} { proc embDefBg t { set bg [lindex [$t configure -background] 3] - changeBg $t $bg + changeBg $t $bg } proc textMakePeer {parent} { diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c index e8cb211..615192b 100644 --- a/macosx/tkMacOSXBitmap.c +++ b/macosx/tkMacOSXBitmap.c @@ -134,7 +134,7 @@ PixmapFromImage( { TkMacOSXDrawingContext dc; Pixmap pixmap; - + pixmap = Tk_GetPixmap(display, None, size.width, size.height, 0); if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) { if (dc.context) { diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 0f92c70..a189646 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -216,7 +216,7 @@ static void drawMacScrollbar( /* * Do not display the thumb unless scrolling is possible. */ - + if (scrollPtr->firstFraction > 0.0 || scrollPtr->lastFraction < 1.0) { CGRect thumbBounds = {thumbOrigin, thumbSize}; path = CGPathCreateWithRoundedRect(thumbBounds, 4, 4, NULL); @@ -233,7 +233,7 @@ static void drawMacScrollbar( } } #endif - + void TkpDisplayScrollbar( ClientData clientData) /* Information about window. */ @@ -317,7 +317,7 @@ TkpDisplayScrollbar( /* * Switch back to NSView coordinates and draw a modern scrollbar. */ - + CGContextConcatCTM(dc.context, t); drawMacScrollbar(scrollPtr, msPtr, dc.context); #endif -- cgit v0.12 From 46f8ffc87ddcd58b713381c3d0c0fb8ad18035a1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 30 Jul 2019 21:00:31 +0000 Subject: Don't use L'?', the L doesn't do anything here --- win/tkWinDialog.c | 2 +- win/tkWinInit.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 26d11ed..c8e2432 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -1372,7 +1372,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, src = Tcl_GetString(optsPtr->extObj); wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->extObj->length, &ds); - if (wstr[0] == L'.') + if (wstr[0] == '.') ++wstr; hr = fdlgIf->lpVtbl->SetDefaultExtension(fdlgIf, wstr); Tcl_DStringFree(&ds); diff --git a/win/tkWinInit.c b/win/tkWinInit.c index 690574e..be3c340 100644 --- a/win/tkWinInit.c +++ b/win/tkWinInit.c @@ -137,21 +137,21 @@ TkpDisplayWarning( len = MultiByteToWideChar(CP_UTF8, 0, title, -1, titleString, TK_MAX_WARN_LEN); msgString = &titleString[len + 1]; - titleString[TK_MAX_WARN_LEN - 1] = L'\0'; + titleString[TK_MAX_WARN_LEN - 1] = '\0'; MultiByteToWideChar(CP_UTF8, 0, msg, -1, msgString, (TK_MAX_WARN_LEN - 1) - len); /* * Truncate MessageBox string if it is too long to not overflow the screen * and cause possible oversized window error. */ - if (titleString[TK_MAX_WARN_LEN - 1] != L'\0') { + if (titleString[TK_MAX_WARN_LEN - 1] != '\0') { memcpy(titleString + (TK_MAX_WARN_LEN - 5), L" ...", 5 * sizeof(WCHAR)); } if (IsDebuggerPresent()) { - titleString[len - 1] = L':'; - titleString[len] = L' '; + titleString[len - 1] = ':'; + titleString[len] = ' '; OutputDebugStringW(titleString); } else { - titleString[len - 1] = L'\0'; + titleString[len - 1] = '\0'; MessageBoxW(NULL, msgString, titleString, MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL | MB_SETFOREGROUND | MB_TOPMOST); -- cgit v0.12 From d1cee4ca466f149ff990f8bea8eaa7a50694e901 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 30 Jul 2019 21:38:18 +0000 Subject: Only free "patterns" once, not each time inside the loop. That might crash with long filters. --- win/tkWinDialog.c | 80 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 743720d..2701b82 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -2295,54 +2295,56 @@ static int MakeFilterVista( for (i = 0, filterPtr = flist.filters; filterPtr; filterPtr = filterPtr->next, ++i) { - const char *sep; - FileFilterClause *clausePtr; - int nbytes; + const char *sep; + FileFilterClause *clausePtr; + int nbytes; - /* Check if this entry should be shown as the default */ - if (initial && strcmp(initial, filterPtr->name) == 0) + /* Check if this entry should be shown as the default */ + if (initial && strcmp(initial, filterPtr->name) == 0) initialIndex = i+1; /* Windows filter indices are 1-based */ - /* First stash away the text description of the pattern */ + /* First stash away the text description of the pattern */ Tcl_WinUtfToTChar(filterPtr->name, -1, &ds); - nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */ - nbytes += sizeof(WCHAR); /* Terminating \0 */ - dlgFilterPtr[i].pszName = ckalloc(nbytes); - memmove((void *) dlgFilterPtr[i].pszName, Tcl_DStringValue(&ds), nbytes); - Tcl_DStringFree(&ds); + nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */ + nbytes += sizeof(WCHAR); /* Terminating \0 */ + dlgFilterPtr[i].pszName = ckalloc(nbytes); + memmove((void *) dlgFilterPtr[i].pszName, Tcl_DStringValue(&ds), nbytes); + Tcl_DStringFree(&ds); - /* - * Loop through and join patterns with a ";" Each "clause" - * corresponds to a single textual description (called typename) - * in the tk_getOpenFile docs. Each such typename may occur - * multiple times and all these form a single filter entry - * with one clause per occurence. Further each clause may specify - * multiple patterns. Hence the nested loop here. - */ - sep = ""; - for (clausePtr=filterPtr->clauses ; clausePtr; - clausePtr=clausePtr->next) { - GlobPattern *globPtr; - for (globPtr = clausePtr->patterns; globPtr; - globPtr = globPtr->next) { - Tcl_DStringAppend(&patterns, sep, -1); - Tcl_DStringAppend(&patterns, globPtr->pattern, -1); - sep = ";"; - } - } + /* + * Loop through and join patterns with a ";" Each "clause" + * corresponds to a single textual description (called typename) + * in the tk_getOpenFile docs. Each such typename may occur + * multiple times and all these form a single filter entry + * with one clause per occurence. Further each clause may specify + * multiple patterns. Hence the nested loop here. + */ + sep = ""; + for (clausePtr=filterPtr->clauses ; clausePtr; + clausePtr=clausePtr->next) { + GlobPattern *globPtr; + for (globPtr = clausePtr->patterns; globPtr; + globPtr = globPtr->next) { + Tcl_DStringAppend(&patterns, sep, -1); + Tcl_DStringAppend(&patterns, globPtr->pattern, -1); + sep = ";"; + } + } - /* Again we need a Unicode form of the string */ + /* Again we need a Unicode form of the string */ Tcl_WinUtfToTChar(Tcl_DStringValue(&patterns), -1, &ds); - nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */ - nbytes += sizeof(WCHAR); /* Terminating \0 */ - dlgFilterPtr[i].pszSpec = ckalloc(nbytes); - memmove((void *)dlgFilterPtr[i].pszSpec, Tcl_DStringValue(&ds), nbytes); - Tcl_DStringFree(&ds); - Tcl_DStringFree(&patterns); + nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */ + nbytes += sizeof(WCHAR); /* Terminating \0 */ + dlgFilterPtr[i].pszSpec = ckalloc(nbytes); + memmove((void *)dlgFilterPtr[i].pszSpec, Tcl_DStringValue(&ds), nbytes); + Tcl_DStringFree(&ds); + Tcl_DStringSetLength(&patterns, 0); } + Tcl_DStringFree(&patterns); - if (initialIndex == 0) - initialIndex = 1; /* If no default, show first entry */ + if (initialIndex == 0) { + initialIndex = 1; /* If no default, show first entry */ + } *initialIndexPtr = initialIndex; *dlgFilterPtrPtr = dlgFilterPtr; *countPtr = flist.numFilters; -- cgit v0.12