diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-24 07:56:41 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-24 07:56:41 (GMT) |
commit | bc56730d2abae5198c3667a55729e01684f3cb29 (patch) | |
tree | a67f18bf70f2081877ab48b4aecd142c54848262 /win | |
parent | abbe37191732849b4d22072a8572f29205025457 (diff) | |
download | tk-bc56730d2abae5198c3667a55729e01684f3cb29.zip tk-bc56730d2abae5198c3667a55729e01684f3cb29.tar.gz tk-bc56730d2abae5198c3667a55729e01684f3cb29.tar.bz2 |
Replace all instances of Tcl_WinTCharToUtf()/Tcl_WinUtfToTChar() with Tcl_UniCharToUtfDString()/Tcl_UtfToUniCharDString(), if possible (only for -DTCL_UTF_MAX=3, which is the default and only supported option)
Backported, as far as possible, from 8.7. This helps moving away from Tcl_WinTCharToUtf()/Tcl_WinUtfToTChar(), even though it only becomes deprecated in 8.7.
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinClipboard.c | 28 | ||||
-rw-r--r-- | win/tkWinDialog.c | 190 | ||||
-rw-r--r-- | win/tkWinFont.c | 83 | ||||
-rw-r--r-- | win/tkWinInit.c | 15 | ||||
-rw-r--r-- | win/tkWinMenu.c | 143 | ||||
-rw-r--r-- | win/tkWinSend.c | 39 | ||||
-rw-r--r-- | win/tkWinSendCom.c | 67 | ||||
-rw-r--r-- | win/tkWinTest.c | 65 | ||||
-rw-r--r-- | win/tkWinWm.c | 266 | ||||
-rw-r--r-- | win/ttkWinXPTheme.c | 81 |
10 files changed, 565 insertions, 412 deletions
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index 8886f2a..bcea1c1 100644 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -78,8 +78,9 @@ TkSelGetSelection( CloseClipboard(); goto error; } - data = GlobalLock(handle); - Tcl_WinTCharToUtf((LPCTSTR)data, -1, &ds); + data = (char *)GlobalLock(handle); + Tcl_DStringInit(&ds); + Tcl_WCharToUtfDString((WCHAR *)data, wcslen((WCHAR *)data), &ds); GlobalUnlock(handle); } else if (IsClipboardFormatAvailable(CF_TEXT)) { /* @@ -100,7 +101,7 @@ TkSelGetSelection( Tcl_DStringInit(&ds); Tcl_DStringAppend(&ds, "cp######", -1); - data = GlobalLock(handle); + data = (char *)GlobalLock(handle); /* * Even though the documentation claims that GetLocaleInfo expects @@ -130,7 +131,7 @@ TkSelGetSelection( CloseClipboard(); goto error; } - data = GlobalLock(handle); + data = (char *)GlobalLock(handle); Tcl_ExternalToUtfDString(encoding, data, -1, &ds); GlobalUnlock(handle); if (encoding) { @@ -157,7 +158,8 @@ TkSelGetSelection( Tcl_DStringAppend(&ds, "\n", 1); } len = wcslen(fname); - Tcl_WinTCharToUtf((LPCTSTR)fname, len * sizeof(WCHAR), &dsTmp); + Tcl_DStringInit(&dsTmp); + Tcl_WCharToUtfDString(fname, len, &dsTmp); Tcl_DStringAppend(&ds, Tcl_DStringValue(&dsTmp), Tcl_DStringLength(&dsTmp)); Tcl_DStringFree(&dsTmp); @@ -232,6 +234,8 @@ XSetSelectionOwner( { HWND hwnd = owner ? TkWinGetHWND(owner) : NULL; Tk_Window tkwin; + (void)display; + (void)time; /* * This is a gross hack because the Tk_InternAtom interface is broken. It @@ -281,6 +285,7 @@ TkWinClipboardRender( char *buffer, *p, *rawText, *endPtr; int length; Tcl_DString ds; + (void)format; for (targetPtr = dispPtr->clipTargetPtr; targetPtr != NULL; targetPtr = targetPtr->nextPtr) { @@ -312,7 +317,7 @@ TkWinClipboardRender( * Copy the data and change EOL characters. */ - buffer = rawText = ckalloc(length + 1); + buffer = rawText = (char *)ckalloc(length + 1); if (targetPtr != NULL) { for (cbPtr = targetPtr->firstBufferPtr; cbPtr != NULL; cbPtr = cbPtr->nextPtr) { @@ -328,7 +333,7 @@ TkWinClipboardRender( *buffer = '\0'; Tcl_DStringInit(&ds); - Tcl_WinUtfToTChar(rawText, -1, &ds); + Tcl_UtfToWCharDString(rawText, -1, &ds); ckfree(rawText); handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, Tcl_DStringLength(&ds) + 2); @@ -336,7 +341,7 @@ TkWinClipboardRender( Tcl_DStringFree(&ds); return; } - buffer = GlobalLock(handle); + buffer = (char *)GlobalLock(handle); memcpy(buffer, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds) + 2); GlobalUnlock(handle); @@ -367,6 +372,8 @@ TkSelUpdateClipboard( TkClipboardTarget *targetPtr) { HWND hwnd = TkWinGetHWND(winPtr->window); + (void)targetPtr; + UpdateClipboard(hwnd); } @@ -419,7 +426,7 @@ UpdateClipboard( void TkSelEventProc( Tk_Window tkwin, /* Window for which event was targeted. */ - register XEvent *eventPtr) /* X event: either SelectionClear, + XEvent *eventPtr) /* X event: either SelectionClear, * SelectionRequest, or SelectionNotify. */ { if (eventPtr->type == SelectionClear) { @@ -446,8 +453,9 @@ TkSelEventProc( void TkSelPropProc( - register XEvent *eventPtr) /* X PropertyChange event. */ + XEvent *eventPtr) /* X PropertyChange event. */ { + (void)eventPtr; } /* diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index ab2f179..3702efa 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -423,7 +423,7 @@ typedef struct IFileSaveDialogVtbl { ULONG ( STDMETHODCALLTYPE *Release )( IFileSaveDialog *); HRESULT ( STDMETHODCALLTYPE *Show )( IFileSaveDialog *, HWND); - HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog * this, + HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog *, UINT, const TCLCOMDLG_FILTERSPEC *); HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )( IFileSaveDialog *, UINT); @@ -589,8 +589,7 @@ static UINT APIENTRY OFNHookProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK MsgBoxCBTProc(int nCode, WPARAM wParam, LPARAM lParam); static void SetTkDialog(ClientData clientData); -static const char *ConvertExternalFilename(WCHAR *filename, - Tcl_DString *dsPtr); +static const char *ConvertExternalFilename(LPCWSTR, Tcl_DString *); static void LoadShellProcs(void); @@ -630,7 +629,7 @@ struct ShellProcPointers { * ShellProcs is populated. *------------------------------------------------------------------------- */ -static void LoadShellProcs() +static void LoadShellProcs(void) { static HMODULE shell32_handle = NULL; @@ -720,7 +719,7 @@ void TkWinDialogDebug( int debug) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); tsdPtr->debugFlag = debug; @@ -752,7 +751,7 @@ Tk_ChooseColorObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window tkwin = clientData, parent; + Tk_Window tkwin = (Tk_Window)clientData, parent; HWND hWnd; int i, oldMode, winCode, result; CHOOSECOLORW chooseColor; @@ -906,10 +905,11 @@ ColorDlgHookProc( WPARAM wParam, /* First message parameter. */ LPARAM lParam) /* Second message parameter. */ { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); const char *title; CHOOSECOLOR *ccPtr; + (void)wParam; if (WM_INITDIALOG == uMsg) { @@ -923,7 +923,8 @@ ColorDlgHookProc( if ((title != NULL) && (title[0] != '\0')) { Tcl_DString ds; - SetWindowTextW(hDlg, (LPCWSTR)Tcl_WinUtfToTChar(title,-1,&ds)); + Tcl_DStringInit(&ds); + SetWindowTextW(hDlg, Tcl_UtfToWCharDString(title, -1, &ds)); Tcl_DStringFree(&ds); } if (tsdPtr->debugFlag) { @@ -1086,7 +1087,7 @@ ParseOFNOptions( ZeroMemory(optsPtr, sizeof(*optsPtr)); // optsPtr->forceXPStyle = 1; - optsPtr->tkwin = clientData; + optsPtr->tkwin = (Tk_Window)clientData; optsPtr->confirmOverwrite = 1; /* By default we ask for confirmation */ Tcl_DStringInit(&optsPtr->utfDirString); optsPtr->file[0] = 0; @@ -1147,7 +1148,7 @@ ParseOFNOptions( Tcl_DStringFree(&ds); break; case FILE_PARENT: - optsPtr->tkwin = Tk_NameToWindow(interp, string, clientData); + optsPtr->tkwin = Tk_NameToWindow(interp, string, (Tk_Window)clientData); if (optsPtr->tkwin == NULL) goto error_return; break; @@ -1202,11 +1203,11 @@ error_return: /* interp should already hold error */ * If new dialogs are available, COM is also initialized. *---------------------------------------------------------------------- */ -static int VistaFileDialogsAvailable() +static int VistaFileDialogsAvailable(void) { HRESULT hr; IFileDialog *fdlgPtr = NULL; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->newFileDialogsState == FDLG_STATE_INIT) { @@ -1268,7 +1269,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, IShellItem *dirIf = NULL; LPWSTR wstr; Tcl_Obj *resultObj = NULL; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); int oldMode; @@ -1372,8 +1373,9 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, const char *src; src = Tcl_GetString(optsPtr->extObj); - wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->extObj->length, &ds); - if (wstr[0] == L'.') + Tcl_DStringInit(&ds); + wstr = Tcl_UtfToWCharDString(src, optsPtr->extObj->length, &ds); + if (wstr[0] == '.') ++wstr; hr = fdlgIf->lpVtbl->SetDefaultExtension(fdlgIf, wstr); Tcl_DStringFree(&ds); @@ -1386,7 +1388,8 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, const char *src; src = Tcl_GetString(optsPtr->titleObj); - wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->titleObj->length, &ds); + Tcl_DStringInit(&ds); + wstr = Tcl_UtfToWCharDString(src, optsPtr->titleObj->length, &ds); hr = fdlgIf->lpVtbl->SetTitle(fdlgIf, wstr); Tcl_DStringFree(&ds); if (FAILED(hr)) @@ -1408,7 +1411,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, if (normPath) { LPCWSTR nativePath; Tcl_IncrRefCount(normPath); - nativePath = Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/ + nativePath = (LPCWSTR)Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/ if (nativePath) { hr = ShellProcs.SHCreateItemFromParsingName( nativePath, NULL, @@ -1512,7 +1515,8 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, Tcl_DString ftds; Tcl_Obj *ftobj; - Tcl_WinTCharToUtf((LPCTSTR)filterPtr[ftix-1].pszName, -1, &ftds); + Tcl_DStringInit(&ftds); + Tcl_WCharToUtfDString(filterPtr[ftix-1].pszName, wcslen(filterPtr[ftix-1].pszName), &ftds); ftobj = Tcl_NewStringObj(Tcl_DStringValue(&ftds), Tcl_DStringLength(&ftds)); Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL, @@ -1574,7 +1578,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper Tcl_DString utfFilterString, ds; Tcl_DString extString, filterString, dirString, titleString; const char *str; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); ZeroMemory(&ofnData, sizeof(OFNData)); @@ -1619,24 +1623,26 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper */ ofnData.dynFileBufferSize = 512; - ofnData.dynFileBuffer = ckalloc(512 * sizeof(WCHAR)); + ofnData.dynFileBuffer = (WCHAR *)ckalloc(512 * sizeof(WCHAR)); } if (optsPtr->extObj != NULL) { - str = Tcl_GetString(optsPtr->extObj); - if (str[0] == '.') - ++str; - Tcl_WinUtfToTChar(str, -1, &extString); - ofn.lpstrDefExt = (WCHAR *) Tcl_DStringValue(&extString); + str = Tcl_GetString(optsPtr->extObj); + if (str[0] == '.') { + ++str; + } + Tcl_DStringInit(&extString); + ofn.lpstrDefExt = Tcl_UtfToWCharDString(str, -1, &extString); } - Tcl_WinUtfToTChar(Tcl_DStringValue(&utfFilterString), + Tcl_DStringInit(&filterString); + ofn.lpstrFilter = Tcl_UtfToWCharDString(Tcl_DStringValue(&utfFilterString), Tcl_DStringLength(&utfFilterString), &filterString); - ofn.lpstrFilter = (WCHAR *) Tcl_DStringValue(&filterString); ofn.nFilterIndex = filterIndex; if (Tcl_DStringValue(&optsPtr->utfDirString)[0] != '\0') { - Tcl_WinUtfToTChar(Tcl_DStringValue(&optsPtr->utfDirString), + Tcl_DStringInit(&dirString); + Tcl_UtfToWCharDString(Tcl_DStringValue(&optsPtr->utfDirString), Tcl_DStringLength(&optsPtr->utfDirString), &dirString); } else { /* @@ -1652,7 +1658,8 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper Tcl_DStringValue(&optsPtr->utfDirString), &cwd) == NULL)) { Tcl_ResetResult(interp); } else { - Tcl_WinUtfToTChar(Tcl_DStringValue(&cwd), + Tcl_DStringInit(&dirString); + Tcl_UtfToWCharDString(Tcl_DStringValue(&cwd), Tcl_DStringLength(&cwd), &dirString); } Tcl_DStringFree(&cwd); @@ -1660,8 +1667,8 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper ofn.lpstrInitialDir = (WCHAR *) Tcl_DStringValue(&dirString); if (optsPtr->titleObj != NULL) { - Tcl_WinUtfToTChar(Tcl_GetString(optsPtr->titleObj), -1, &titleString); - ofn.lpstrTitle = (WCHAR *) Tcl_DStringValue(&titleString); + Tcl_DStringInit(&titleString); + ofn.lpstrTitle = Tcl_UtfToWCharDString(Tcl_GetString(optsPtr->titleObj), -1, &titleString); } /* @@ -1914,10 +1921,11 @@ OFNHookProc( WPARAM wParam, /* Message parameter */ LPARAM lParam) /* Message parameter */ { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); OPENFILENAME *ofnPtr; OFNData *ofnData; + (void)wParam; if (uMsg == WM_INITDIALOG) { TkWinSetUserData(hdlg, lParam); @@ -1962,7 +1970,7 @@ OFNHookProc( if ((selsize > 1) && (dirsize > 0)) { if (ofnData->dynFileBufferSize < buffersize) { - buffer = ckrealloc(buffer, buffersize * sizeof(WCHAR)); + buffer = (WCHAR *)ckrealloc(buffer, buffersize * sizeof(WCHAR)); ofnData->dynFileBufferSize = buffersize; ofnData->dynFileBuffer = buffer; } @@ -2008,7 +2016,7 @@ OFNHookProc( if (TCL_PATH_ABSOLUTE == Tcl_GetPathType(Tcl_DStringValue(&tmpfile))) { /* re-get the full path to the start of the buffer */ - buffer = (WCHAR *) ofnData->dynFileBuffer; + buffer = ofnData->dynFileBuffer; SendMessageW(hdlg, CDM_GETSPEC, selsize, (LPARAM) buffer); } else { *(buffer-1) = '\\'; @@ -2094,7 +2102,7 @@ MakeFilter( */ const char *defaultFilter = "All Files (*.*)"; - p = filterStr = ckalloc(30); + p = filterStr = (char *)ckalloc(30); strcpy(p, defaultFilter); p+= strlen(defaultFilter); @@ -2108,13 +2116,12 @@ MakeFilter( *p = '\0'; } else { - size_t len; + int len; if (valuePtr == NULL) { len = 0; } else { - (void) Tcl_GetString(valuePtr); - len = valuePtr->length; + (void) Tcl_GetStringFromObj(valuePtr, &len); } /* @@ -2131,7 +2138,7 @@ MakeFilter( * twice the size of the string to format the filter */ - filterStr = ckalloc(len * 3); + filterStr = (char *)ckalloc(len * 3); for (filterPtr = flist.filters, p = filterStr; filterPtr; filterPtr = filterPtr->next) { @@ -2284,7 +2291,7 @@ static int MakeFilterVista( Tcl_DStringInit(&ds); Tcl_DStringInit(&patterns); - dlgFilterPtr = ckalloc(flist.numFilters * sizeof(*dlgFilterPtr)); + dlgFilterPtr = (TCLCOMDLG_FILTERSPEC *)ckalloc(flist.numFilters * sizeof(*dlgFilterPtr)); for (i = 0, filterPtr = flist.filters; filterPtr; @@ -2298,10 +2305,11 @@ static int MakeFilterVista( initialIndex = i+1; /* Windows filter indices are 1-based */ /* First stash away the text description of the pattern */ - Tcl_WinUtfToTChar(filterPtr->name, -1, &ds); + Tcl_DStringInit(&ds); + Tcl_UtfToWCharDString(filterPtr->name, -1, &ds); nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */ nbytes += sizeof(WCHAR); /* Terminating \0 */ - dlgFilterPtr[i].pszName = ckalloc(nbytes); + dlgFilterPtr[i].pszName = (LPCWSTR)ckalloc(nbytes); memmove((void *) dlgFilterPtr[i].pszName, Tcl_DStringValue(&ds), nbytes); Tcl_DStringFree(&ds); @@ -2326,10 +2334,11 @@ static int MakeFilterVista( } /* Again we need a Unicode form of the string */ - Tcl_WinUtfToTChar(Tcl_DStringValue(&patterns), -1, &ds); + Tcl_DStringInit(&ds); + Tcl_UtfToWCharDString(Tcl_DStringValue(&patterns), -1, &ds); nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */ nbytes += sizeof(WCHAR); /* Terminating \0 */ - dlgFilterPtr[i].pszSpec = ckalloc(nbytes); + dlgFilterPtr[i].pszSpec = (LPCWSTR)ckalloc(nbytes); memmove((void *)dlgFilterPtr[i].pszSpec, Tcl_DStringValue(&ds), nbytes); Tcl_DStringFree(&ds); Tcl_DStringSetLength(&patterns, 0); @@ -2425,7 +2434,7 @@ Tk_ChooseDirectoryObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - WCHAR path[MAX_PATH]; + WCHAR path[MAX_PATH]; int oldMode, result; LPCITEMIDLIST pidl; /* Returned by browser */ BROWSEINFOW bInfo; /* Used by browser */ @@ -2462,14 +2471,15 @@ Tk_ChooseDirectoryObjCmd( if (utfDir[0] != '\0') { LPCWSTR uniStr; - Tcl_WinUtfToTChar(Tcl_DStringValue(&ofnOpts.utfDirString), -1, + Tcl_DStringInit(&tempString); + Tcl_UtfToWCharDString(Tcl_DStringValue(&ofnOpts.utfDirString), -1, &tempString); - uniStr = (WCHAR *) Tcl_DStringValue(&tempString); + uniStr = (WCHAR *) Tcl_DStringValue(&tempString); - /* Convert possible relative path to full path to keep dialog happy. */ + /* Convert possible relative path to full path to keep dialog happy. */ - GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL); - wcsncpy(cdCBData.initDir, saveDir, MAX_PATH); + GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL); + wcsncpy(cdCBData.initDir, saveDir, MAX_PATH); } /* XXX - rest of this (original) code has no error checks at all. */ @@ -2494,8 +2504,8 @@ Tk_ChooseDirectoryObjCmd( bInfo.lParam = (LPARAM) &cdCBData; if (ofnOpts.titleObj != NULL) { - bInfo.lpszTitle = (LPCWSTR)Tcl_WinUtfToTChar( - Tcl_GetString(ofnOpts.titleObj), -1, &titleString); + Tcl_DStringInit(&titleString); + bInfo.lpszTitle = Tcl_UtfToWCharDString(Tcl_GetString(ofnOpts.titleObj), -1, &titleString); } else { bInfo.lpszTitle = L"Please choose a directory, then select OK."; } @@ -2619,7 +2629,7 @@ ChooseDirectoryValidateProc( Tcl_DString tempString; Tcl_DString initDirString; WCHAR string[MAX_PATH]; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->debugFlag) { @@ -2638,7 +2648,8 @@ ChooseDirectoryValidateProc( * like ~ are converted correctly. */ - Tcl_WinTCharToUtf((LPCTSTR) lParam, -1, &initDirString); + Tcl_DStringInit(&initDirString); + Tcl_WCharToUtfDString((WCHAR *) lParam, wcslen((WCHAR *) lParam), &initDirString); if (Tcl_TranslateFileName(chooseDirSharedData->interp, Tcl_DStringValue(&initDirString), &tempString) == NULL) { /* @@ -2649,12 +2660,11 @@ ChooseDirectoryValidateProc( chooseDirSharedData->retDir[0] = '\0'; return 1; } - Tcl_DStringFree(&initDirString); - Tcl_WinUtfToTChar(Tcl_DStringValue(&tempString), -1, &initDirString); - Tcl_DStringFree(&tempString); - wcsncpy(string, (WCHAR *) Tcl_DStringValue(&initDirString), + Tcl_DStringSetLength(&initDirString, 0); + wcsncpy(string, Tcl_UtfToWCharDString(Tcl_DStringValue(&tempString), -1, &initDirString), MAX_PATH); Tcl_DStringFree(&initDirString); + Tcl_DStringFree(&tempString); if (SetCurrentDirectoryW(string) == 0) { @@ -2735,8 +2745,8 @@ ChooseDirectoryValidateProc( ULONG ulCount, ulAttr; if (SUCCEEDED(psfFolder->lpVtbl->ParseDisplayName( - psfFolder, hwnd, NULL, (WCHAR *) - initDir, &ulCount,&pidlMain,&ulAttr)) + psfFolder, hwnd, NULL, initDir, + &ulCount,&pidlMain,&ulAttr)) && (pidlMain != NULL)) { SendMessageW(hwnd, BFFM_SETSELECTIONW, FALSE, (LPARAM) pidlMain); @@ -2782,7 +2792,7 @@ Tk_MessageBoxObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window tkwin = clientData, parent; + Tk_Window tkwin = (Tk_Window)clientData, parent; HWND hWnd; Tcl_Obj *messageObj, *titleObj, *detailObj, *tmpObj; int defaultBtn, icon, type; @@ -2796,7 +2806,7 @@ Tk_MessageBoxObjCmd( MSG_DEFAULT, MSG_DETAIL, MSG_ICON, MSG_MESSAGE, MSG_PARENT, MSG_TITLE, MSG_TYPE }; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); Tcl_DString titleBuf, tmpBuf; LPCWSTR titlePtr, tmpPtr; @@ -2930,10 +2940,12 @@ Tk_MessageBoxObjCmd( tsdPtr->hMsgBoxHook = SetWindowsHookExW(WH_CBT, MsgBoxCBTProc, NULL, GetCurrentThreadId()); src = Tcl_GetString(tmpObj); - tmpPtr = (LPCWSTR)Tcl_WinUtfToTChar(src, tmpObj->length, &tmpBuf); + Tcl_DStringInit(&tmpBuf); + tmpPtr = Tcl_UtfToWCharDString(src, tmpObj->length, &tmpBuf); if (titleObj != NULL) { src = Tcl_GetString(titleObj); - titlePtr = (LPCWSTR)Tcl_WinUtfToTChar(src, titleObj->length, &titleBuf); + Tcl_DStringInit(&titleBuf); + titlePtr = Tcl_UtfToWCharDString(src, titleObj->length, &titleBuf); } else { titlePtr = L""; Tcl_DStringInit(&titleBuf); @@ -2964,7 +2976,7 @@ MsgBoxCBTProc( WPARAM wParam, LPARAM lParam) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (nCode == HCBT_CREATEWND) { @@ -3011,7 +3023,7 @@ static void SetTkDialog( ClientData clientData) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); char buf[32]; @@ -3025,12 +3037,13 @@ SetTkDialog( static const char * ConvertExternalFilename( - WCHAR *filename, + LPCWSTR filename, Tcl_DString *dsPtr) { char *p; - Tcl_WinTCharToUtf((LPCTSTR)filename, -1, dsPtr); + Tcl_DStringInit(dsPtr); + Tcl_WCharToUtfDString(filename, wcslen(filename), dsPtr); for (p = Tcl_DStringValue(dsPtr); *p != '\0'; p++) { /* * Change the pathname to the Tcl "normalized" pathname, where back @@ -3067,7 +3080,8 @@ GetFontObj( int pt = 0; resObj = Tcl_NewListObj(0, NULL); - Tcl_WinTCharToUtf((LPCTSTR)plf->lfFaceName, -1, &ds); + Tcl_DStringInit(&ds); + Tcl_WCharToUtfDString(plf->lfFaceName, wcslen(plf->lfFaceName), &ds); Tcl_ListObjAppendElement(NULL, resObj, Tcl_NewStringObj(Tcl_DStringValue(&ds), -1)); Tcl_DStringFree(&ds); @@ -3102,7 +3116,7 @@ ApplyLogfont( Tcl_Obj **objv, **tmpv; Tcl_ListObjGetElements(NULL, cmdObj, &objc, &objv); - tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2)); + tmpv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc + 2)); memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc); tmpv[objc] = GetFontObj(hdc, logfontPtr); TkBackgroundEvalObjv(interp, objc+1, tmpv, TCL_EVAL_GLOBAL); @@ -3140,7 +3154,7 @@ HookProc( CHOOSEFONT *pcf = (CHOOSEFONT *) lParam; HWND hwndCtrl; static HookData *phd = NULL; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (WM_INITDIALOG == msg && lParam != 0) { @@ -3153,7 +3167,8 @@ HookProc( if (phd->titleObj != NULL) { Tcl_DString title; - Tcl_WinUtfToTChar(Tcl_GetString(phd->titleObj), -1, &title); + Tcl_DStringInit(&title); + Tcl_UtfToWCharDString(Tcl_GetString(phd->titleObj), -1, &title); if (Tcl_DStringLength(&title) > 0) { SetWindowTextW(hwndDlg, (LPCWSTR) Tcl_DStringValue(&title)); } @@ -3282,14 +3297,14 @@ FontchooserConfigureCmd( int objc, Tcl_Obj *const objv[]) { - Tk_Window tkwin = clientData; + Tk_Window tkwin = (Tk_Window)clientData; HookData *hdPtr = NULL; int i, r = TCL_OK; static const char *const optionStrings[] = { "-parent", "-title", "-font", "-command", "-visible", NULL }; - hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); + hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); /* * With no arguments we return all the options in a dict. @@ -3426,14 +3441,16 @@ FontchooserShowCmd( Tcl_Obj *const objv[]) { Tcl_DString ds; - Tk_Window tkwin = clientData, parent; + Tk_Window tkwin = (Tk_Window)clientData, parent; CHOOSEFONTW cf; LOGFONTW lf; HDC hdc; HookData *hdPtr; int r = TCL_OK, oldMode = 0; + (void)objc; + (void)objv; - hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); + hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); parent = tkwin; if (hdPtr->parentObj) { @@ -3470,8 +3487,8 @@ FontchooserShowCmd( } fontPtr = (TkFont *) f; cf.Flags |= CF_INITTOLOGFONTSTRUCT; - Tcl_WinUtfToTChar(fontPtr->fa.family, -1, &ds); - wcsncpy(lf.lfFaceName, (WCHAR *)Tcl_DStringValue(&ds), + Tcl_DStringInit(&ds); + wcsncpy(lf.lfFaceName, Tcl_UtfToWCharDString(fontPtr->fa.family, -1, &ds), LF_FACESIZE-1); Tcl_DStringFree(&ds); lf.lfFaceName[LF_FACESIZE-1] = 0; @@ -3534,12 +3551,15 @@ FontchooserShowCmd( static int FontchooserHideCmd( - ClientData clientData, /* Main window */ + ClientData dummy, /* Main window */ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { - HookData *hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); + HookData *hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); + (void)dummy; + (void)objc; + (void)objv; if (hdPtr->hwnd && IsWindow(hdPtr->hwnd)) { EndDialog(hdPtr->hwnd, 0); @@ -3559,9 +3579,10 @@ FontchooserHideCmd( */ static void -DeleteHookData(ClientData clientData, Tcl_Interp *interp) +DeleteHookData(ClientData clientData, Tcl_Interp *dummy) { - HookData *hdPtr = clientData; + HookData *hdPtr = (HookData *)clientData; + (void)dummy; if (hdPtr->parentObj) { Tcl_DecrRefCount(hdPtr->parentObj); @@ -3598,9 +3619,10 @@ const TkEnsemble tkFontchooserEnsemble[] = { }; int -TkInitFontchooser(Tcl_Interp *interp, ClientData clientData) +TkInitFontchooser(Tcl_Interp *interp, ClientData dummy) { - HookData *hdPtr = ckalloc(sizeof(HookData)); + HookData *hdPtr = (HookData *)ckalloc(sizeof(HookData)); + (void)dummy; memset(hdPtr, 0, sizeof(HookData)); Tcl_SetAssocData(interp, "::tk::fontchooser", DeleteHookData, hdPtr); diff --git a/win/tkWinFont.c b/win/tkWinFont.c index aae34a7..c430d48 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -300,8 +300,8 @@ TkpGetNativeFont( } tkwin = (Tk_Window) ((TkWindow *) tkwin)->mainPtr->winPtr; - fontPtr = ckalloc(sizeof(WinFont)); - InitFont(tkwin, GetStockObject(object), 0, fontPtr); + fontPtr = (WinFont *)ckalloc(sizeof(WinFont)); + InitFont(tkwin, (HFONT)GetStockObject(object), 0, fontPtr); return (TkFont *) fontPtr; } @@ -558,7 +558,7 @@ TkpGetFontFromAttributes( hFont = GetScreenFont(faPtr, faceName, (int)(TkFontGetPixels(tkwin, faPtr->size) + 0.5), 0.0); if (tkFontPtr == NULL) { - fontPtr = ckalloc(sizeof(WinFont)); + fontPtr = (WinFont *)ckalloc(sizeof(WinFont)); } else { fontPtr = (WinFont *) tkFontPtr; ReleaseFont(fontPtr); @@ -658,10 +658,12 @@ WinFontFamilyEnumProc( int fontType, /* Type of font (not used). */ LPARAM lParam) /* Result object to hold result. */ { + WCHAR *faceName = lfPtr->elfLogFont.lfFaceName; Tcl_Obj *resultObj = (Tcl_Obj *) lParam; Tcl_DString faceString; - Tcl_WinTCharToUtf((LPCTSTR)lfPtr->elfLogFont.lfFaceName, -1, &faceString); + Tcl_DStringInit(&faceString); + Tcl_WCharToUtfDString(faceName, wcslen(faceName), &faceString); Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( Tcl_DStringValue(&faceString), Tcl_DStringLength(&faceString))); Tcl_DStringFree(&faceString); @@ -750,7 +752,7 @@ TkpGetFontAttrsForChar( * Get the font attributes. */ - oldfont = SelectObject(hdc, thisSubFontPtr->hFont0); + oldfont = (HFONT)SelectObject(hdc, thisSubFontPtr->hFont0); GetTextMetricsW(hdc, &tm); SelectObject(hdc, oldfont); ReleaseDC(fontPtr->hwnd, hdc); @@ -828,7 +830,7 @@ Tk_MeasureChars( hdc = GetDC(fontPtr->hwnd); lastSubFontPtr = &fontPtr->subFontArray[0]; - oldFont = SelectObject(hdc, lastSubFontPtr->hFont0); + oldFont = (HFONT)SelectObject(hdc, lastSubFontPtr->hFont0); /* * A three step process: @@ -1037,6 +1039,7 @@ TkpMeasureCharsInContext( * terminating character. */ { (void) numBytes; /*unused*/ + return Tk_MeasureChars(tkfont, source + rangeStart, rangeLength, maxLength, flags, lengthPtr); } @@ -1117,7 +1120,7 @@ Tk_DrawChars( stipple = CreatePatternBrush(twdPtr->bitmap.handle); SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL); - oldBrush = SelectObject(dc, stipple); + oldBrush = (HBRUSH)SelectObject(dc, stipple); SetTextAlign(dcMem, TA_LEFT | TA_BASELINE); SetTextColor(dcMem, gc->foreground); @@ -1132,7 +1135,7 @@ Tk_DrawChars( GetTextMetricsW(dcMem, &tm); size.cx -= tm.tmOverhang; bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy); - oldBitmap = SelectObject(dcMem, bitmap); + oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap); /* * The following code is tricky because fonts are rendered in multiple @@ -1186,7 +1189,7 @@ Tk_DrawChars( GetTextMetricsW(dcMem, &tm); size.cx -= tm.tmOverhang; bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy); - oldBitmap = SelectObject(dcMem, bitmap); + oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap); MultiFontTextOut(dcMem, fontPtr, source, numBytes, 0, tm.tmAscent, 0.0); @@ -1265,7 +1268,7 @@ TkDrawAngledChars( stipple = CreatePatternBrush(twdPtr->bitmap.handle); SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL); - oldBrush = SelectObject(dc, stipple); + oldBrush = (HBRUSH)SelectObject(dc, stipple); SetTextAlign(dcMem, TA_LEFT | TA_BASELINE); SetTextColor(dcMem, gc->foreground); @@ -1280,7 +1283,7 @@ TkDrawAngledChars( GetTextMetricsW(dcMem, &tm); size.cx -= tm.tmOverhang; bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy); - oldBitmap = SelectObject(dcMem, bitmap); + oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap); /* * The following code is tricky because fonts are rendered in multiple @@ -1334,7 +1337,7 @@ TkDrawAngledChars( GetTextMetricsW(dcMem, &tm); size.cx -= tm.tmOverhang; bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy); - oldBitmap = SelectObject(dcMem, bitmap); + oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap); MultiFontTextOut(dcMem, fontPtr, source, numBytes, 0, tm.tmAscent, angle); @@ -1392,7 +1395,6 @@ TkpDrawCharsInContext( * drawing. */ { int widthUntilStart; - (void) numBytes; /*unused*/ Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart); @@ -1498,9 +1500,9 @@ SelectFont( double angle) { if (angle == 0.0) { - return SelectObject(hdc, subFontPtr->hFont0); + return (HFONT)SelectObject(hdc, subFontPtr->hFont0); } else if (angle == subFontPtr->angle) { - return SelectObject(hdc, subFontPtr->hFontAngled); + return (HFONT)SelectObject(hdc, subFontPtr->hFontAngled); } else { if (subFontPtr->hFontAngled) { DeleteObject(subFontPtr->hFontAngled); @@ -1508,10 +1510,10 @@ SelectFont( subFontPtr->hFontAngled = GetScreenFont(&fontPtr->font.fa, subFontPtr->familyPtr->faceName, fontPtr->pixelSize, angle); if (subFontPtr->hFontAngled == NULL) { - return SelectObject(hdc, subFontPtr->hFont0); + return (HFONT)SelectObject(hdc, subFontPtr->hFont0); } subFontPtr->angle = angle; - return SelectObject(hdc, subFontPtr->hFontAngled); + return (HFONT)SelectObject(hdc, subFontPtr->hFontAngled); } } @@ -1563,12 +1565,13 @@ InitFont( window = Tk_WindowId(tkwin); hwnd = (window == None) ? NULL : TkWinGetHWND(window); hdc = GetDC(hwnd); - oldFont = SelectObject(hdc, hFont); + oldFont = (HFONT)SelectObject(hdc, hFont); GetTextMetricsW(hdc, &tm); GetTextFaceW(hdc, LF_FACESIZE, buf); - Tcl_WinTCharToUtf((LPCTSTR)buf, -1, &faceString); + Tcl_DStringInit(&faceString); + Tcl_WCharToUtfDString(buf, wcslen(buf), &faceString); fontPtr->font.fid = (Font) fontPtr; fontPtr->hwnd = hwnd; @@ -1740,15 +1743,16 @@ AllocFontFamily( Tcl_DString faceString; Tcl_Encoding encoding; WCHAR buf[LF_FACESIZE]; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - hFont = SelectObject(hdc, hFont); + hFont = (HFONT)SelectObject(hdc, hFont); GetTextFaceW(hdc, LF_FACESIZE, buf); - Tcl_WinTCharToUtf((LPCTSTR)buf, -1, &faceString); + Tcl_DStringInit(&faceString); + Tcl_WCharToUtfDString(buf, wcslen(buf), &faceString); faceName = Tk_GetUid(Tcl_DStringValue(&faceString)); Tcl_DStringFree(&faceString); - hFont = SelectObject(hdc, hFont); + hFont = (HFONT)SelectObject(hdc, hFont); familyPtr = tsdPtr->fontFamilyList; for ( ; familyPtr != NULL; familyPtr = familyPtr->nextPtr) { @@ -1758,7 +1762,7 @@ AllocFontFamily( } } - familyPtr = ckalloc(sizeof(FontFamily)); + familyPtr = (FontFamily *)ckalloc(sizeof(FontFamily)); memset(familyPtr, 0, sizeof(FontFamily)); familyPtr->nextPtr = tsdPtr->fontFamilyList; tsdPtr->fontFamilyList = familyPtr; @@ -1844,7 +1848,7 @@ FreeFontFamily( { int i; FontFamily **familyPtrPtr; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (familyPtr == NULL) { @@ -2048,7 +2052,10 @@ WinFontCanUseProc( fontPtr = canUsePtr->fontPtr; nameTriedPtr = canUsePtr->nameTriedPtr; - fallbackName = Tcl_WinTCharToUtf((LPCTSTR)lfPtr->elfLogFont.lfFaceName, -1, &faceString); + fallbackName = (char *) lfPtr->elfLogFont.lfFaceName; + Tcl_DStringInit(&faceString); + Tcl_WCharToUtfDString((WCHAR *)fallbackName, wcslen((WCHAR *)fallbackName), &faceString); + fallbackName = Tcl_DStringValue(&faceString); if (SeenName(fallbackName, nameTriedPtr) == 0) { subFontPtr = CanUseFallback(hdc, fontPtr, fallbackName, ch, @@ -2177,7 +2184,7 @@ FontMapLoadPage( USHORT *startCount, *endCount; char buf[16], src[4]; - subFontPtr->fontMap[row] = ckalloc(FONTMAP_BITSPERPAGE / 8); + subFontPtr->fontMap[row] = (char *)ckalloc(FONTMAP_BITSPERPAGE / 8); memset(subFontPtr->fontMap[row], 0, FONTMAP_BITSPERPAGE / 8); familyPtr = subFontPtr->familyPtr; @@ -2408,7 +2415,7 @@ CanUseFallback( if (fontPtr->numSubFonts >= SUBFONT_SPACE) { SubFont *newPtr; - newPtr = ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1)); + newPtr = (SubFont *)ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1)); memcpy(newPtr, fontPtr->subFontArray, fontPtr->numSubFonts * sizeof(SubFont)); if (fontPtr->subFontArray != fontPtr->staticSubFonts) { @@ -2456,7 +2463,6 @@ GetScreenFont( double angle) /* What is the desired orientation of the * font. */ { - Tcl_DString ds; HFONT hFont; LOGFONTW lf; @@ -2475,9 +2481,7 @@ GetScreenFont( lf.lfQuality = DEFAULT_QUALITY; lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - Tcl_WinUtfToTChar(faceName, -1, &ds); - wcsncpy(lf.lfFaceName, (WCHAR *)Tcl_DStringValue(&ds), LF_FACESIZE-1); - Tcl_DStringFree(&ds); + MultiByteToWideChar(CP_UTF8, 0, faceName, -1, lf.lfFaceName, LF_FACESIZE); lf.lfFaceName[LF_FACESIZE-1] = 0; hFont = CreateFontIndirectW(&lf); return hFont; @@ -2526,7 +2530,8 @@ FamilyExists( return 0; } - Tcl_WinUtfToTChar(faceName, -1, &faceString); + Tcl_DStringInit(&faceString); + Tcl_UtfToWCharDString(faceName, -1, &faceString); /* * If the family exists, WinFontExistProc() will be called and @@ -2535,7 +2540,7 @@ FamilyExists( * non-zero value. */ - result = EnumFontFamiliesW(hdc, (WCHAR*) Tcl_DStringValue(&faceString), + result = EnumFontFamiliesW(hdc, (WCHAR *)Tcl_DStringValue(&faceString), (FONTENUMPROCW) WinFontExistProc, 0); Tcl_DStringFree(&faceString); return (result == 0); @@ -2723,7 +2728,7 @@ LoadFontRanges( endCount = NULL; *symbolPtr = 0; - hFont = SelectObject(hdc, hFont); + hFont = (HFONT)SelectObject(hdc, hFont); i = 0; s = (char *) &i; @@ -2778,8 +2783,8 @@ LoadFontRanges( segCount = subTable.segment.segCountX2 / 2; cbData = segCount * sizeof(USHORT); - startCount = ckalloc(cbData); - endCount = ckalloc(cbData); + startCount = (USHORT *)ckalloc(cbData); + endCount = (USHORT *)ckalloc(cbData); offset = encTable.offset + sizeof(subTable.segment); GetFontData(hdc, cmapKey, (DWORD) offset, endCount, cbData); @@ -2822,8 +2827,8 @@ LoadFontRanges( segCount = 1; cbData = segCount * sizeof(USHORT); - startCount = ckalloc(cbData); - endCount = ckalloc(cbData); + startCount = (USHORT *)ckalloc(cbData); + endCount = (USHORT *)ckalloc(cbData); startCount[0] = 0x0000; endCount[0] = 0x00ff; } diff --git a/win/tkWinInit.c b/win/tkWinInit.c index a1ab098..854d62f 100644 --- a/win/tkWinInit.c +++ b/win/tkWinInit.c @@ -35,6 +35,7 @@ int TkpInit( Tcl_Interp *interp) { + (void)interp; /* * This is necessary for static initialization, and is ok otherwise * because TkWinXInit flips a static bit to do its work just once. @@ -137,21 +138,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); @@ -196,7 +197,8 @@ TkWin32ErrorObj( *p = '\0'; } - Tcl_WinTCharToUtf((LPCTSTR)lpBuffer, -1, &ds); + Tcl_DStringInit(&ds); + Tcl_WCharToUtfDString(lpBuffer, wcslen(lpBuffer), &ds); errPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); @@ -206,7 +208,6 @@ TkWin32ErrorObj( return errPtr; } - /* * Local Variables: diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 6e856c7..d2d39cc 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -233,13 +233,13 @@ GetNewID( TkMenuEntry *mePtr, /* The menu we are working with. */ WORD *menuIDPtr) /* The resulting id. */ { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); WORD curID = tsdPtr->lastCommandID; while (1) { Tcl_HashEntry *commandEntryPtr; - int new; + int isNew; /* * Try the next ID number, taking care to wrap rather than stray @@ -255,8 +255,8 @@ GetNewID( } commandEntryPtr = Tcl_CreateHashEntry(&tsdPtr->commandTable, - INT2PTR(curID), &new); - if (new) { + INT2PTR(curID), &isNew); + if (isNew) { Tcl_SetHashValue(commandEntryPtr, mePtr); *menuIDPtr = curID; tsdPtr->lastCommandID = curID; @@ -285,7 +285,7 @@ static void FreeID( WORD commandID) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* @@ -328,7 +328,7 @@ TkpNewMenu( HMENU winMenuHdl; Tcl_HashEntry *hashEntryPtr; int newEntry; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); winMenuHdl = CreatePopupMenu(); @@ -374,7 +374,7 @@ TkpDestroyMenu( { HMENU winMenuHdl = (HMENU) menuPtr->platformData; const char *searchName; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (menuPtr->menuFlags & MENU_RECONFIGURE_PENDING) { @@ -388,7 +388,7 @@ TkpDestroyMenu( if (menuPtr->menuFlags & MENU_SYSTEM_MENU) { TkMenuEntry *searchEntryPtr; Tcl_HashTable *tablePtr = TkGetMenuHashTable(menuPtr->interp); - char *menuName = Tcl_GetHashKey(tablePtr, + char *menuName = (char *)Tcl_GetHashKey(tablePtr, menuPtr->menuRefPtr->hashEntryPtr); /* @@ -420,7 +420,7 @@ TkpDestroyMenu( if (tsdPtr->menuHWND != NULL) { Tcl_HashEntry *hashEntryPtr = - Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) winMenuHdl); + Tcl_FindHashEntry(&tsdPtr->winMenuTable, winMenuHdl); if (hashEntryPtr != NULL) { Tcl_DeleteHashEntry(hashEntryPtr); @@ -492,16 +492,16 @@ GetEntryText( char *itemText; if (mePtr->type == TEAROFF_ENTRY) { - itemText = ckalloc(sizeof("(Tear-off)")); + itemText = (char *)ckalloc(sizeof("(Tear-off)")); strcpy(itemText, "(Tear-off)"); } else if (mePtr->imagePtr != NULL) { - itemText = ckalloc(sizeof("(Image)")); + itemText = (char *)ckalloc(sizeof("(Image)")); strcpy(itemText, "(Image)"); } else if (mePtr->bitmapPtr != NULL) { - itemText = ckalloc(sizeof("(Pixmap)")); + itemText = (char *)ckalloc(sizeof("(Pixmap)")); strcpy(itemText, "(Pixmap)"); } else if (mePtr->labelPtr == NULL || mePtr->labelLength == 0) { - itemText = ckalloc(sizeof("( )")); + itemText = (char *)ckalloc(sizeof("( )")); strcpy(itemText, "( )"); } else { int i; @@ -541,7 +541,7 @@ GetEntryText( } } - itemText = ckalloc(Tcl_DStringLength(&itemString) + 1); + itemText = (char *)ckalloc(Tcl_DStringLength(&itemString) + 1); strcpy(itemText, Tcl_DStringValue(&itemString)); Tcl_DStringFree(&itemString); } @@ -569,7 +569,7 @@ static void ReconfigureWindowsMenu( ClientData clientData) /* The menu we are rebuilding */ { - TkMenu *menuPtr = clientData; + TkMenu *menuPtr = (TkMenu *)clientData; TkMenuEntry *mePtr; HMENU winMenuHdl = (HMENU) menuPtr->platformData; char *itemText = NULL; @@ -609,7 +609,8 @@ ReconfigureWindowsMenu( itemText = GetEntryText(menuPtr, mePtr); if ((menuPtr->menuType == MENUBAR) || (menuPtr->menuFlags & MENU_SYSTEM_MENU)) { - Tcl_WinUtfToTChar(itemText, -1, &translatedText); + Tcl_DStringInit(&translatedText); + Tcl_UtfToWCharDString(itemText, -1, &translatedText); lpNewItem = (LPCWSTR) Tcl_DStringValue(&translatedText); flags |= MF_STRING; } else { @@ -728,7 +729,7 @@ ReconfigureWindowsMenu( if ((menuPtr->menuType == MENUBAR) && (menuPtr->parentTopLevelPtr != NULL)) { - HANDLE bar = TkWinGetWrapperWindow(menuPtr->parentTopLevelPtr); + HWND bar = TkWinGetWrapperWindow(menuPtr->parentTopLevelPtr); if (bar) { DrawMenuBar(bar); @@ -759,7 +760,7 @@ ReconfigureWindowsMenu( int TkpPostMenu( - Tcl_Interp *interp, + Tcl_Interp *dummy, TkMenu *menuPtr, int x, int y, int index) { @@ -769,8 +770,9 @@ TkpPostMenu( POINT point; Tk_Window parentWindow = Tk_Parent(menuPtr->tkwin); int oldServiceMode = Tcl_GetServiceMode(); - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + (void)dummy; tsdPtr->inPostMenu++; CallPendingReconfigureImmediately(menuPtr); @@ -869,13 +871,14 @@ TkpPostMenu( int TkpPostTearoffMenu( - Tcl_Interp *interp, /* The interpreter of the menu */ + Tcl_Interp *dummy, /* The interpreter of the menu */ TkMenu *menuPtr, /* The menu we are posting */ int x, int y, int index) /* The root X,Y coordinates where we are * posting */ { int vRootX, vRootY, vRootWidth, vRootHeight; int result; + (void)dummy; if (index >= menuPtr->numEntries) { index = menuPtr->numEntries - 1; @@ -1064,7 +1067,7 @@ TkWinEmbeddedMenuProc( { static int nIdles = 0; LRESULT lResult = 1; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); switch(message) { @@ -1140,15 +1143,16 @@ TkWinHandleMenuEvent( int returnResult = 0; TkMenu *menuPtr; TkMenuEntry *mePtr; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + (void)phwnd; switch (*pMessage) { case WM_UNINITMENUPOPUP: hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, - (char *) *pwParam); + *pwParam); if (hashEntryPtr != NULL) { - menuPtr = Tcl_GetHashValue(hashEntryPtr); + menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr); if ((menuPtr->menuRefPtr != NULL) && (menuPtr->menuRefPtr->parentEntryPtr != NULL)) { TkPostSubmenu(menuPtr->interp, @@ -1160,10 +1164,10 @@ TkWinHandleMenuEvent( case WM_INITMENU: TkMenuInit(); hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, - (char *) *pwParam); + *pwParam); if (hashEntryPtr != NULL) { tsdPtr->oldServiceMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); - menuPtr = Tcl_GetHashValue(hashEntryPtr); + menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr); tsdPtr->modalMenuPtr = menuPtr; CallPendingReconfigureImmediately(menuPtr); RecursivelyClearActiveMenu(menuPtr); @@ -1199,7 +1203,7 @@ TkWinHandleMenuEvent( if (hashEntryPtr == NULL) { break; } - mePtr = Tcl_GetHashValue(hashEntryPtr); + mePtr = (TkMenuEntry *)Tcl_GetHashValue(hashEntryPtr); if (mePtr != NULL) { TkMenuReferences *menuRefPtr; TkMenuEntry *parentEntryPtr; @@ -1245,16 +1249,16 @@ TkWinHandleMenuEvent( case WM_MENUCHAR: { hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, - (char *) *plParam); + *plParam); if (hashEntryPtr != NULL) { int i, len, underline; Tcl_Obj *labelPtr; - LPCWSTR wlabel; + WCHAR *wlabel; int menuChar; Tcl_DString ds; *plResult = 0; - menuPtr = Tcl_GetHashValue(hashEntryPtr); + menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr); /* * Assume we have something directly convertable to Tcl_UniChar. * True at least for wide systems. @@ -1272,8 +1276,9 @@ TkWinHandleMenuEvent( const char *src = Tcl_GetStringFromObj(labelPtr, &len); Tcl_DStringFree(&ds); - wlabel = (LPCWSTR) Tcl_WinUtfToTChar(src, len, &ds); - if ((underline < len) && (menuChar == + Tcl_DStringInit(&ds); + wlabel = Tcl_UtfToWCharDString(src, len, &ds); + if ((underline + 1 < len + 1) && (menuChar == Tcl_UniCharToUpper(wlabel[underline]))) { *plResult = (2 << 16) | i; returnResult = 1; @@ -1325,7 +1330,7 @@ TkWinHandleMenuEvent( } mePtr = (TkMenuEntry *) itemPtr->itemData; menuPtr = mePtr->menuPtr; - twdPtr = ckalloc(sizeof(TkWinDrawable)); + twdPtr = (TkWinDrawable *)ckalloc(sizeof(TkWinDrawable)); twdPtr->type = TWD_WINDC; twdPtr->winDC.hdc = itemPtr->hDC; @@ -1389,9 +1394,9 @@ TkWinHandleMenuEvent( menuPtr = NULL; if (*plParam != 0) { hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, - (char *) *plParam); + *plParam); if (hashEntryPtr != NULL) { - menuPtr = Tcl_GetHashValue(hashEntryPtr); + menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr); } } @@ -1416,7 +1421,7 @@ TkWinHandleMenuEvent( hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->commandTable, INT2PTR(entryIndex)); if (hashEntryPtr != NULL) { - mePtr = Tcl_GetHashValue(hashEntryPtr); + mePtr = (TkMenuEntry *)Tcl_GetHashValue(hashEntryPtr); } } } @@ -1505,7 +1510,7 @@ TkpSetWindowMenuBar( TkMenu *menuPtr) /* The menu we are inserting */ { HMENU winMenuHdl; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (menuPtr != NULL) { @@ -1514,7 +1519,7 @@ TkpSetWindowMenuBar( winMenuHdl = (HMENU) menuPtr->platformData; hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, - (char *) winMenuHdl); + winMenuHdl); Tcl_DeleteHashEntry(hashEntryPtr); DestroyMenu(winMenuHdl); winMenuHdl = CreateMenu(); @@ -1553,6 +1558,10 @@ TkpSetMainMenubar( const char *menuName) /* The name of the menu to put in front. If * NULL, use the default menu bar. */ { + (void)interp; + (void)tkwin; + (void)menuName; + /* * Nothing to do. */ @@ -1583,6 +1592,10 @@ GetMenuIndicatorGeometry( int *widthPtr, /* The resulting width */ int *heightPtr) /* The resulting height */ { + (void)menuPtr; + (void)tkfont; + (void)fmPtr; + *heightPtr = indicatorDimensions[0]; if (mePtr->hideMargin) { *widthPtr = 0; @@ -1666,6 +1679,9 @@ GetTearoffEntryGeometry( int *widthPtr, /* The resulting width */ int *heightPtr) /* The resulting height */ { + (void)mePtr; + (void)tkfont; + if (menuPtr->menuType != MASTER_MENU) { *heightPtr = 0; } else { @@ -1699,6 +1715,10 @@ GetMenuSeparatorGeometry( int *widthPtr, /* The resulting width */ int *heightPtr) /* The resulting height */ { + (void)menuPtr; + (void)mePtr; + (void)tkfont; + *widthPtr = 0; *heightPtr = fmPtr->linespace - (2 * fmPtr->descent); } @@ -1812,6 +1832,11 @@ DrawMenuEntryIndicator( int width, int height) { + (void)tkfont; + (void)fmPtr; + (void)width; + (void)height; + if ((mePtr->type == CHECK_BUTTON_ENTRY) || (mePtr->type == RADIO_BUTTON_ENTRY)) { if (mePtr->indicatorOn && (mePtr->entryFlags & ENTRY_SELECTED)) { @@ -1892,6 +1917,9 @@ DrawMenuEntryAccelerator( int baseline; int leftEdge = x + mePtr->indicatorSpace + mePtr->labelWidth; const char *accel; + (void)activeBorder; + (void)width; + (void)height; if (menuPtr->menuType == MENUBAR) { return; @@ -1965,6 +1993,8 @@ DrawMenuEntryArrow( COLORREF oldFgColor; COLORREF oldBgColor; RECT rect; + (void)gc; + (void)activeBorder; if (!drawArrow || (mePtr->type != CASCADE_ENTRY)) { return; @@ -2035,6 +2065,10 @@ DrawMenuSeparator( { XPoint points[2]; Tk_3DBorder border; + (void)mePtr; + (void)gc; + (void)tkfont; + (void)fmPtr; points[0].x = x; points[0].y = y + height / 2; @@ -2074,6 +2108,9 @@ DrawMenuUnderline( int width, /* Width of entry */ int height) /* Height of entry */ { + (void)fmPtr; + (void)width; + if ((mePtr->underline >= 0) && (mePtr->labelPtr != NULL)) { int len; @@ -2113,7 +2150,7 @@ DrawMenuUnderline( static int TkWinMenuKeyObjCmd( - ClientData clientData, /* Unused. */ + ClientData dummy, /* Unused. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -2125,6 +2162,7 @@ TkWinMenuKeyObjCmd( TkWindow *winPtr; KeySym keySym; int i; + (void)dummy; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "window keySym"); @@ -2257,8 +2295,7 @@ TkpInitializeMenuBindings( */ (void) Tcl_CreateObjCommand(interp, "tk::WinMenuKey", - TkWinMenuKeyObjCmd, - (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL); + TkWinMenuKeyObjCmd, Tk_MainWindow(interp), NULL); (void) Tk_CreateBinding(interp, bindingTable, (ClientData) uid, "<Alt_L>", "tk::WinMenuKey %W %N", 0); @@ -2537,6 +2574,10 @@ DrawTearoffEntry( XPoint points[2]; int segmentWidth, maxX; Tk_3DBorder border; + (void)mePtr; + (void)gc; + (void)tkfont; + (void)fmPtr; if (menuPtr->menuType != MASTER_MENU) { return; @@ -2580,7 +2621,7 @@ DrawTearoffEntry( int TkpConfigureMenuEntry( - register TkMenuEntry *mePtr)/* Information about menu entry; may or may + TkMenuEntry *mePtr)/* Information about menu entry; may or may * not already have values for some fields. */ { ScheduleMenuReconfigure(mePtr->menuPtr); @@ -2644,7 +2685,7 @@ TkpDrawMenuEntry( menuDc = TkWinGetDrawableDC(menuPtr->display, menuDrawable, &dcState); memDc = CreateCompatibleDC(menuDc); - oldBitmap = SelectObject(memDc, + oldBitmap = (HBITMAP)SelectObject(memDc, CreateCompatibleBitmap(menuDc, width, height) ); memWinDraw.type = TWD_WINDC; @@ -3187,8 +3228,9 @@ HWND Tk_GetMenuHWND( Tk_Window tkwin) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + (void)tkwin; TkMenuInit(); return tsdPtr->embeddedMenuHWND; @@ -3212,8 +3254,10 @@ Tk_GetMenuHWND( static void MenuExitHandler( - ClientData clientData) /* Not used */ + ClientData dummy) /* Not used */ { + (void)dummy; + UnregisterClassW(MENU_CLASS_NAME, Tk_GetHINSTANCE()); UnregisterClassW(EMBEDDED_MENU_CLASS_NAME, Tk_GetHINSTANCE()); } @@ -3237,10 +3281,11 @@ MenuExitHandler( static void MenuThreadExitHandler( - ClientData clientData) /* Not used */ + ClientData dummy) /* Not used */ { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + (void)dummy; DestroyWindow(tsdPtr->menuHWND); DestroyWindow(tsdPtr->embeddedMenuHWND); @@ -3277,6 +3322,8 @@ TkWinGetMenuSystemDefault( const char *className) /* The name of the option class. */ { Tcl_Obj *valuePtr = NULL; + (void)tkwin; + (void)className; if ((strcmp(dbName, "activeBorderWidth") == 0) || (strcmp(dbName, "borderWidth") == 0)) { @@ -3480,7 +3527,7 @@ TkpMenuInit(void) void TkpMenuThreadInit(void) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); tsdPtr->menuHWND = CreateWindowW(MENU_CLASS_NAME, L"MenuWindow", WS_POPUP, diff --git a/win/tkWinSend.c b/win/tkWinSend.c index 8fa1eaf..d1d6777 100644 --- a/win/tkWinSend.c +++ b/win/tkWinSend.c @@ -121,6 +121,8 @@ Tk_SetAppName( * be globally unique. */ { #ifndef TK_SEND_ENABLED_ON_WINDOWS + (void)tkwin; + /* * Temporarily disabled for bug #858822 */ @@ -163,7 +165,7 @@ Tk_SetAppName( if (riPtr == NULL) { LPUNKNOWN *objPtr; - riPtr = ckalloc(sizeof(RegisteredInterp)); + riPtr = (RegisteredInterp *)ckalloc(sizeof(RegisteredInterp)); memset(riPtr, 0, sizeof(RegisteredInterp)); riPtr->interp = interp; @@ -213,6 +215,8 @@ TkGetInterpNames( * lookup. */ { #ifndef TK_SEND_ENABLED_ON_WINDOWS + (void)interp; + (void)tkwin; /* * Temporarily disabled for bug #858822 */ @@ -254,7 +258,8 @@ TkGetInterpNames( if (*p) { Tcl_DString ds; - Tcl_WinTCharToUtf((LPCTSTR)(p + 1), -1, &ds); + Tcl_DStringInit(&ds); + Tcl_WCharToUtfDString(p + 1, wcslen(p + 1), &ds); result = Tcl_ListObjAppendElement(interp, objList, Tcl_NewStringObj(Tcl_DStringValue(&ds), @@ -619,7 +624,8 @@ BuildMoniker( LPMONIKER pmkItem = NULL; Tcl_DString dString; - Tcl_WinUtfToTChar(name, -1, &dString); + Tcl_DStringInit(&dString); + Tcl_UtfToWCharDString(name, -1, &dString); hr = CreateFileMoniker((LPOLESTR)Tcl_DStringValue(&dString), &pmkItem); Tcl_DStringFree(&dString); if (SUCCEEDED(hr)) { @@ -733,7 +739,7 @@ Send( * object. */ Tcl_Interp *interp, /* The local interpreter. */ int async, /* Flag for the calling style. */ - ClientData clientData, /* The RegisteredInterp structure for this + ClientData dummy, /* The RegisteredInterp structure for this * interp. */ int objc, /* Number of arguments to be sent. */ Tcl_Obj *const objv[]) /* The arguments to be sent. */ @@ -747,6 +753,7 @@ Send( DISPID dispid; Tcl_DString ds; const char *src; + (void)dummy; cmd = Tcl_ConcatObj(objc, objv); @@ -761,8 +768,8 @@ Send( vCmd.vt = VT_BSTR; src = Tcl_GetString(cmd); - Tcl_WinUtfToTChar(src, cmd->length, &ds); - vCmd.bstrVal = SysAllocString((WCHAR *) Tcl_DStringValue(&ds)); + Tcl_DStringInit(&ds); + vCmd.bstrVal = SysAllocString(Tcl_UtfToWCharDString(src, cmd->length, &ds)); Tcl_DStringFree(&ds); dp.cArgs = 1; @@ -784,8 +791,8 @@ Send( ehr = VariantChangeType(&vResult, &vResult, 0, VT_BSTR); if (SUCCEEDED(ehr)) { - Tcl_WinTCharToUtf((LPCTSTR)vResult.bstrVal, SysStringLen(vResult.bstrVal) * - sizeof (WCHAR), &ds); + Tcl_DStringInit(&ds); + Tcl_WCharToUtfDString(vResult.bstrVal, SysStringLen(vResult.bstrVal), &ds); Tcl_DStringResult(interp, &ds); } @@ -797,8 +804,9 @@ Send( if (hr == DISP_E_EXCEPTION && ei.bstrSource != NULL) { Tcl_Obj *opError, *opErrorCode, *opErrorInfo; - Tcl_WinTCharToUtf((LPCTSTR)ei.bstrSource, SysStringLen(ei.bstrSource) * - sizeof (WCHAR), &ds); + + Tcl_DStringInit(&ds); + Tcl_WCharToUtfDString(ei.bstrSource, SysStringLen(ei.bstrSource), &ds); opError = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); @@ -869,14 +877,14 @@ TkWinSend_SetExcepInfo( /* TODO: Handle failure to append */ src = Tcl_GetString(opError); - Tcl_WinUtfToTChar(src, opError->length, &ds); + Tcl_DStringInit(&ds); pExcepInfo->bstrDescription = - SysAllocString((WCHAR *) Tcl_DStringValue(&ds)); + SysAllocString(Tcl_UtfToWCharDString(src, opError->length, &ds)); Tcl_DStringFree(&ds); src = Tcl_GetString(opErrorCode); - Tcl_WinUtfToTChar(src, opErrorCode->length, &ds); + Tcl_DStringInit(&ds); pExcepInfo->bstrSource = - SysAllocString((WCHAR *) Tcl_DStringValue(&ds)); + SysAllocString(Tcl_UtfToWCharDString(src, opErrorCode->length, &ds)); Tcl_DStringFree(&ds); Tcl_DecrRefCount(opErrorCode); pExcepInfo->scode = E_FAIL; @@ -923,7 +931,7 @@ TkWinSend_QueueCommand( TRACE("SendQueueCommand()\n"); - evPtr = ckalloc(sizeof(SendEvent)); + evPtr = (SendEvent *)ckalloc(sizeof(SendEvent)); evPtr->header.proc = SendEventProc; evPtr->header.nextPtr = NULL; evPtr->interp = interp; @@ -965,6 +973,7 @@ SendEventProc( int flags) { SendEvent *evPtr = (SendEvent *)eventPtr; + (void)flags; TRACE("SendEventProc\n"); diff --git a/win/tkWinSendCom.c b/win/tkWinSendCom.c index 3f4f387..536c6c1 100644 --- a/win/tkWinSendCom.c +++ b/win/tkWinSendCom.c @@ -166,17 +166,17 @@ WinSendCom_QueryInterface( void **ppvObject) { HRESULT hr = E_NOINTERFACE; - TkWinSendCom *this = (TkWinSendCom *) This; + TkWinSendCom *sendCom = (TkWinSendCom *) This; *ppvObject = NULL; if (memcmp(riid, &IID_IUnknown, sizeof(IID)) == 0 || memcmp(riid, &IID_IDispatch, sizeof(IID)) == 0) { - *ppvObject = (void **) this; - this->lpVtbl->AddRef(This); + *ppvObject = (void **) sendCom; + sendCom->lpVtbl->AddRef(This); hr = S_OK; } else if (memcmp(riid, &IID_ISupportErrorInfo, sizeof(IID)) == 0) { - *ppvObject = (void **) (this + 1); - this->lpVtbl2->AddRef((ISupportErrorInfo *) (this + 1)); + *ppvObject = (void **) (sendCom + 1); + sendCom->lpVtbl2->AddRef((ISupportErrorInfo *) (sendCom + 1)); hr = S_OK; } return hr; @@ -186,9 +186,9 @@ static STDMETHODIMP_(ULONG) WinSendCom_AddRef( IDispatch *This) { - TkWinSendCom *this = (TkWinSendCom*)This; + TkWinSendCom *sendCom = (TkWinSendCom*)This; - return InterlockedIncrement(&this->refcount); + return InterlockedIncrement(&sendCom->refcount); } static STDMETHODIMP_(ULONG) @@ -196,9 +196,9 @@ WinSendCom_Release( IDispatch *This) { long r = 0; - TkWinSendCom *this = (TkWinSendCom*)This; + TkWinSendCom *sendCom = (TkWinSendCom*)This; - if ((r = InterlockedDecrement(&this->refcount)) == 0) { + if ((r = InterlockedDecrement(&sendCom->refcount)) == 0) { TkWinSendCom_Destroy(This); } return r; @@ -210,6 +210,7 @@ WinSendCom_GetTypeInfoCount( UINT *pctinfo) { HRESULT hr = E_POINTER; + (void)This; if (pctinfo != NULL) { *pctinfo = 0; @@ -226,6 +227,9 @@ WinSendCom_GetTypeInfo( ITypeInfo **ppTI) { HRESULT hr = E_POINTER; + (void)This; + (void)iTInfo; + (void)lcid; if (ppTI) { *ppTI = NULL; @@ -244,6 +248,10 @@ WinSendCom_GetIDsOfNames( DISPID *rgDispId) { HRESULT hr = E_POINTER; + (void)This; + (void)riid; + (void)cNames; + (void)lcid; if (rgDispId) { hr = DISP_E_UNKNOWNNAME; @@ -269,7 +277,9 @@ WinSendCom_Invoke( UINT *puArgErr) { HRESULT hr = DISP_E_MEMBERNOTFOUND; - TkWinSendCom *this = (TkWinSendCom*)This; + TkWinSendCom *sendCom = (TkWinSendCom*)This; + (void)riid; + (void)lcid; switch (dispidMember) { case TKWINSENDCOM_DISPID_SEND: @@ -277,7 +287,7 @@ WinSendCom_Invoke( if (pDispParams->cArgs != 1) { hr = DISP_E_BADPARAMCOUNT; } else { - hr = Send(this, pDispParams->rgvarg[0], pvarResult, + hr = Send(sendCom, pDispParams->rgvarg[0], pvarResult, pExcepInfo, puArgErr); } } @@ -288,7 +298,7 @@ WinSendCom_Invoke( if (pDispParams->cArgs != 1) { hr = DISP_E_BADPARAMCOUNT; } else { - hr = Async(this, pDispParams->rgvarg[0], pExcepInfo, puArgErr); + hr = Async(sendCom, pDispParams->rgvarg[0], pExcepInfo, puArgErr); } } break; @@ -313,27 +323,27 @@ ISupportErrorInfo_QueryInterface( REFIID riid, void **ppvObject) { - TkWinSendCom *this = (TkWinSendCom *)(This - 1); + TkWinSendCom *sendCom = (TkWinSendCom *)(This - 1); - return this->lpVtbl->QueryInterface((IDispatch *) this, riid, ppvObject); + return sendCom->lpVtbl->QueryInterface((IDispatch *) sendCom, riid, ppvObject); } static STDMETHODIMP_(ULONG) ISupportErrorInfo_AddRef( ISupportErrorInfo *This) { - TkWinSendCom *this = (TkWinSendCom *)(This - 1); + TkWinSendCom *sendCom = (TkWinSendCom *)(This - 1); - return InterlockedIncrement(&this->refcount); + return InterlockedIncrement(&sendCom->refcount); } static STDMETHODIMP_(ULONG) ISupportErrorInfo_Release( ISupportErrorInfo *This) { - TkWinSendCom *this = (TkWinSendCom *)(This - 1); + TkWinSendCom *sendCom = (TkWinSendCom *)(This - 1); - return this->lpVtbl->Release((IDispatch *) this); + return sendCom->lpVtbl->Release((IDispatch *) sendCom); } static STDMETHODIMP @@ -341,7 +351,10 @@ ISupportErrorInfo_InterfaceSupportsErrorInfo( ISupportErrorInfo *This, REFIID riid) { - /*TkWinSendCom *this = (TkWinSendCom*)(This - 1);*/ + (void)This; + (void)riid; + + /*TkWinSendCom *sendCom = (TkWinSendCom*)(This - 1);*/ return S_OK; /* or S_FALSE */ } @@ -371,6 +384,7 @@ Async( HRESULT hr = S_OK; VARIANT vCmd; Tcl_DString ds; + (void)puArgErr; VariantInit(&vCmd); @@ -385,8 +399,8 @@ Async( if (SUCCEEDED(hr) && obj->interp) { Tcl_Obj *scriptPtr; - Tcl_WinTCharToUtf((LPCTSTR)vCmd.bstrVal, SysStringLen(vCmd.bstrVal) * - sizeof (WCHAR), &ds); + Tcl_DStringInit(&ds); + Tcl_WCharToUtfDString(vCmd.bstrVal, SysStringLen(vCmd.bstrVal), &ds); scriptPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); @@ -427,9 +441,10 @@ Send( HRESULT hr = S_OK; int result = TCL_OK; VARIANT v; - register Tcl_Interp *interp = obj->interp; + Tcl_Interp *interp = obj->interp; Tcl_Obj *scriptPtr; Tcl_DString ds; + (void)puArgErr; if (interp == NULL) { return S_OK; @@ -440,8 +455,8 @@ Send( return hr; } - Tcl_WinTCharToUtf((LPCTSTR)v.bstrVal, SysStringLen(v.bstrVal) * - sizeof(WCHAR), &ds); + Tcl_DStringInit(&ds); + Tcl_WCharToUtfDString(v.bstrVal, SysStringLen(v.bstrVal), &ds); scriptPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); Tcl_Preserve(interp); @@ -457,8 +472,8 @@ Send( pvResult->vt = VT_BSTR; obj = Tcl_GetObjResult(interp); src = Tcl_GetString(obj); - Tcl_WinUtfToTChar(src, obj->length, &ds); - pvResult->bstrVal = SysAllocString((WCHAR *) Tcl_DStringValue(&ds)); + Tcl_DStringInit(&ds); + pvResult->bstrVal = SysAllocString(Tcl_UtfToWCharDString(src, obj->length, &ds)); Tcl_DStringFree(&ds); } if (result == TCL_ERROR) { diff --git a/win/tkWinTest.c b/win/tkWinTest.c index 6911334..a202ba5 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -67,15 +67,15 @@ TkplatformtestInit( */ Tcl_CreateObjCommand(interp, "testclipboard", TestclipboardObjCmd, - (ClientData) Tk_MainWindow(interp), NULL); + Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testwinevent", TestwineventObjCmd, - (ClientData) Tk_MainWindow(interp), NULL); + Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testfindwindow", TestfindwindowObjCmd, - (ClientData) Tk_MainWindow(interp), NULL); + Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testgetwindowinfo", TestgetwindowinfoObjCmd, - (ClientData) Tk_MainWindow(interp), NULL); + Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testwinlocale", TestwinlocaleObjCmd, - (ClientData) Tk_MainWindow(interp), NULL); + Tk_MainWindow(interp), NULL); return TCL_OK; } @@ -177,7 +177,8 @@ AppendSystemError( } else { char *msgPtr; - Tcl_WinTCharToUtf((LPCTSTR)wMsgPtr, -1, &ds); + Tcl_DStringInit(&ds); + Tcl_WCharToUtfDString(wMsgPtr, wcslen(wMsgPtr), &ds); LocalFree(wMsgPtr); msgPtr = Tcl_DStringValue(&ds); @@ -230,6 +231,8 @@ SetSelectionResult( Tcl_Interp *interp, const char *selection) { + (void)dummy; + Tcl_AppendResult(interp, selection, NULL); return TCL_OK; } @@ -241,7 +244,7 @@ TestclipboardObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument values. */ { - Tk_Window tkwin = (Tk_Window) clientData; + Tk_Window tkwin = (Tk_Window)clientData; if (objc != 1) { Tcl_WrongNumArgs(interp, 1, objv, NULL); @@ -270,7 +273,7 @@ TestclipboardObjCmd( static int TestwineventObjCmd( - ClientData clientData, /* Main window for application. */ + ClientData dummy, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ @@ -293,6 +296,7 @@ TestwineventObjCmd( {WM_COMMAND, "WM_COMMAND"}, {-1, NULL} }; + (void)dummy; if ((objc == 3) && (strcmp(Tcl_GetString(objv[1]), "debug") == 0)) { int b; @@ -375,20 +379,20 @@ TestwineventObjCmd( case WM_SETTEXT: { Tcl_DString ds; - control = TestFindControl(hwnd, id); - if (control == NULL) { - Tcl_SetObjResult(interp, - Tcl_ObjPrintf("Could not find control with id %d", id)); - return TCL_ERROR; - } + control = TestFindControl(hwnd, id); + if (control == NULL) { + Tcl_SetObjResult(interp, + Tcl_ObjPrintf("Could not find control with id %d", id)); + return TCL_ERROR; + } Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[4]), -1, &ds); - result = SendMessageA(control, WM_SETTEXT, 0, - (LPARAM) Tcl_DStringValue(&ds)); + result = SendMessageA(control, WM_SETTEXT, 0, + (LPARAM) Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); if (result == 0) { - Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to send text to dialog: ", -1)); - AppendSystemError(interp, GetLastError()); - return TCL_ERROR; + Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to send text to dialog: ", -1)); + AppendSystemError(interp, GetLastError()); + return TCL_ERROR; } break; } @@ -427,7 +431,7 @@ TestwineventObjCmd( static int TestfindwindowObjCmd( - ClientData clientData, /* Main window for application. */ + ClientData dummy, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument values. */ @@ -437,6 +441,7 @@ TestfindwindowObjCmd( HWND hwnd = NULL; int r = TCL_OK; DWORD myPid; + (void)dummy; Tcl_DStringInit(&classString); Tcl_DStringInit(&titleString); @@ -446,9 +451,11 @@ TestfindwindowObjCmd( return TCL_ERROR; } - title = (LPCWSTR)Tcl_WinUtfToTChar(Tcl_GetString(objv[1]), -1, &titleString); + Tcl_DStringInit(&titleString); + title = Tcl_UtfToWCharDString(Tcl_GetString(objv[1]), -1, &titleString); if (objc == 3) { - windowClass = (LPCWSTR)Tcl_WinUtfToTChar(Tcl_GetString(objv[2]), -1, &classString); + Tcl_DStringInit(&classString); + windowClass = Tcl_UtfToWCharDString(Tcl_GetString(objv[2]), -1, &classString); } if (title[0] == 0) title = NULL; @@ -497,7 +504,7 @@ EnumChildrenProc( static int TestgetwindowinfoObjCmd( - ClientData clientData, + ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) @@ -508,6 +515,7 @@ TestgetwindowinfoObjCmd( WCHAR buf[512]; int cch, cchBuf = 256; Tcl_DString ds; + (void)dummy; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "hwnd"); @@ -523,8 +531,8 @@ TestgetwindowinfoObjCmd( AppendSystemError(interp, GetLastError()); return TCL_ERROR; } else { - Tcl_DString ds; - Tcl_WinTCharToUtf((LPCTSTR)buf, -1, &ds); + Tcl_DStringInit(&ds); + Tcl_WCharToUtfDString(buf, wcslen(buf), &ds); classObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); } @@ -535,7 +543,8 @@ TestgetwindowinfoObjCmd( Tcl_NewWideIntObj(GetWindowLongPtrW(INT2PTR(hwnd), GWL_ID))); cch = GetWindowTextW(INT2PTR(hwnd), buf, cchBuf); - Tcl_WinTCharToUtf((LPCTSTR)buf, cch * sizeof (WCHAR), &ds); + Tcl_DStringInit(&ds); + Tcl_WCharToUtfDString(buf, cch, &ds); textObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); @@ -553,11 +562,13 @@ TestgetwindowinfoObjCmd( static int TestwinlocaleObjCmd( - ClientData clientData, /* Main window for application. */ + ClientData dummy, /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument values. */ { + (void)dummy; + if (objc != 1) { Tcl_WrongNumArgs(interp, 1, objv, NULL); return TCL_ERROR; diff --git a/win/tkWinWm.c b/win/tkWinWm.c index bddbe05..9307503 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -66,7 +66,7 @@ typedef struct ProtocolHandler { } ProtocolHandler; #define HANDLER_SIZE(cmdLength) \ - ((unsigned) ((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength)) + ((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength) /* * Helper type passed via lParam to TkWmStackorderToplevelEnumProc @@ -856,7 +856,7 @@ static int InitWindowClass( WinIconPtr titlebaricon) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { @@ -1117,7 +1117,7 @@ TkWinGetIcon( { WmInfo *wmPtr; HICON icon; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->iconPtr != NULL) { @@ -1241,10 +1241,10 @@ ReadIconFromFile( if (file == NULL) { return NULL; } - Tcl_WinUtfToTChar(file, -1, &ds2); - Tcl_DStringFree(&ds); - res = (DWORD *)SHGetFileInfoW((WCHAR *)Tcl_DStringValue(&ds2), 0, &sfiSM, + Tcl_DStringInit(&ds2); + res = (DWORD *)SHGetFileInfoW(Tcl_UtfToWCharDString(file, -1, &ds2), 0, &sfiSM, sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_ICON); + Tcl_DStringFree(&ds); if (res != 0) { SHFILEINFOW sfi; @@ -1260,7 +1260,7 @@ ReadIconFromFile( size = sizeof(BlockOfIconImages) + ((res != 0) ? sizeof(ICONIMAGE) : 0); - lpIR = ckalloc(size); + lpIR = (BlockOfIconImagesPtr)ckalloc(size); if (lpIR == NULL) { if (res != 0) { DestroyIcon(sfi.hIcon); @@ -1291,7 +1291,7 @@ ReadIconFromFile( Tcl_DStringFree(&ds2); } if (lpIR != NULL) { - titlebaricon = ckalloc(sizeof(WinIconInstance)); + titlebaricon = (WinIconPtr)ckalloc(sizeof(WinIconInstance)); titlebaricon->iconBlock = lpIR; titlebaricon->refCount = 1; } @@ -1367,7 +1367,7 @@ GetIconFromPixmap( return NULL; } - lpIR = ckalloc(sizeof(BlockOfIconImages)); + lpIR = (BlockOfIconImagesPtr)ckalloc(sizeof(BlockOfIconImages)); if (lpIR == NULL) { DestroyIcon(hIcon); return NULL; @@ -1388,7 +1388,7 @@ GetIconFromPixmap( lpIR->IconImages[0].lpXOR = 0; lpIR->IconImages[0].lpAND = 0; - titlebaricon = ckalloc(sizeof(WinIconInstance)); + titlebaricon = (WinIconPtr)ckalloc(sizeof(WinIconInstance)); titlebaricon->iconBlock = lpIR; titlebaricon->refCount = 1; return titlebaricon; @@ -1593,7 +1593,7 @@ ReadIconOrCursorFromFile( * Allocate memory for the resource structure */ - lpIR = ckalloc(sizeof(BlockOfIconImages)); + lpIR = (BlockOfIconImagesPtr)ckalloc(sizeof(BlockOfIconImages)); /* * Read in the header @@ -1611,14 +1611,14 @@ ReadIconOrCursorFromFile( * Adjust the size of the struct to account for the images. */ - lpIR = ckrealloc(lpIR, sizeof(BlockOfIconImages) + lpIR = (BlockOfIconImagesPtr)ckrealloc(lpIR, sizeof(BlockOfIconImages) + (lpIR->nNumImages - 1) * sizeof(ICONIMAGE)); /* * Allocate enough memory for the icon directory entries. */ - lpIDE = ckalloc(lpIR->nNumImages * sizeof(ICONDIRENTRY)); + lpIDE = (LPICONDIRENTRY)ckalloc(lpIR->nNumImages * sizeof(ICONDIRENTRY)); /* * Read in the icon directory entries. @@ -1653,7 +1653,7 @@ ReadIconOrCursorFromFile( * Allocate memory for the resource. */ - lpIR->IconImages[i].lpBits = ckalloc(lpIDE[i].dwBytesInRes); + lpIR->IconImages[i].lpBits = (LPBYTE)ckalloc(lpIDE[i].dwBytesInRes); lpIR->IconImages[i].dwNumBytes = lpIDE[i].dwBytesInRes; /* @@ -1732,7 +1732,7 @@ static TkWindow * GetTopLevel( HWND hwnd) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* @@ -1769,7 +1769,7 @@ SetLimits( HWND hwnd, MINMAXINFO *info) { - register WmInfo *wmPtr; + WmInfo *wmPtr; int maxWidth, maxHeight; int minWidth, minHeight; int base; @@ -1874,7 +1874,7 @@ TkWinWmCleanup( } initialized = 0; - tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + tsdPtr = (ThreadSpecificData *)Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { return; @@ -1905,7 +1905,7 @@ void TkWmNewWindow( TkWindow *winPtr) /* Newly-created top-level window. */ { - register WmInfo *wmPtr = ckalloc(sizeof(WmInfo)); + WmInfo *wmPtr = (WmInfo *)ckalloc(sizeof(WmInfo)); /* * Initialize full structure, then set what isn't NULL @@ -1990,7 +1990,7 @@ static void UpdateWrapper( TkWindow *winPtr) /* Top-level window to redecorate. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; HWND parentHWND, oldWrapper = wmPtr->wrapper; HWND child, nextHWND, focusHWND; int x, y, width, height, state; @@ -1999,7 +1999,7 @@ UpdateWrapper( HICON hBigIcon = NULL; Tcl_DString titleString; int *childStateInfo = NULL; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr->window == None) { @@ -2121,7 +2121,8 @@ UpdateWrapper( */ tsdPtr->createWindow = winPtr; - Tcl_WinUtfToTChar(((wmPtr->title != NULL) ? + Tcl_DStringInit(&titleString); + Tcl_UtfToWCharDString(((wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid), -1, &titleString); wmPtr->wrapper = CreateWindowExW(wmPtr->exStyle, @@ -2208,7 +2209,7 @@ UpdateWrapper( WmInfo *wmPtr2; - childStateInfo = ckalloc(wmPtr->numTransients * sizeof(int)); + childStateInfo = (int *)ckalloc(wmPtr->numTransients * sizeof(int)); state = 0; for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL; wmPtr2 = wmPtr2->nextPtr) { @@ -2354,8 +2355,8 @@ TkWmMapWindow( TkWindow *winPtr) /* Top-level window that's about to be * mapped. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; - ThreadSpecificData *tsdPtr = + WmInfo *wmPtr = winPtr->wmInfoPtr; + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { @@ -2580,7 +2581,7 @@ void TkWmDeadWindow( TkWindow *winPtr) /* Top-level window that's being deleted. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; WmInfo *wmPtr2; if (wmPtr == NULL) { @@ -2594,7 +2595,7 @@ TkWmDeadWindow( if (winPtr->dispPtr->firstWmPtr == wmPtr) { winPtr->dispPtr->firstWmPtr = wmPtr->nextPtr; } else { - register WmInfo *prevPtr; + WmInfo *prevPtr; for (prevPtr = winPtr->dispPtr->firstWmPtr; ; prevPtr = prevPtr->nextPtr) { @@ -2741,6 +2742,8 @@ void TkWmSetClass( TkWindow *winPtr) /* Newly-created top-level window. */ { + (void)winPtr; + /* Do nothing */ return; } @@ -2762,7 +2765,6 @@ TkWmSetClass( *---------------------------------------------------------------------- */ - /* ARGSUSED */ int Tk_WmObjCmd( ClientData clientData, /* Main window associated with interpreter. */ @@ -2770,7 +2772,7 @@ Tk_WmObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - Tk_Window tkwin = clientData; + Tk_Window tkwin = (Tk_Window)clientData; static const char *const optionStrings[] = { "aspect", "attributes", "client", "colormapwindows", "command", "deiconify", "focusmodel", "forget", "frame", @@ -2796,7 +2798,7 @@ Tk_WmObjCmd( WMOPT_WITHDRAW }; int index; - size_t length; + int length; const char *argv1; TkWindow *winPtr, **winPtrPtr = &winPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; @@ -2807,8 +2809,7 @@ Tk_WmObjCmd( return TCL_ERROR; } - argv1 = Tcl_GetString(objv[1]); - length = objv[1]->length; + argv1 = Tcl_GetStringFromObj(objv[1], &length); if ((argv1[0] == 't') && !strncmp(argv1, "tracing", length) && (length >= 3)) { int wmTracing; @@ -2951,8 +2952,9 @@ WmAspectCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int numer1, denom1, numer2, denom2; + (void)tkwin; if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, @@ -3021,11 +3023,11 @@ WmAttributesCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; LONG style, exStyle, styleBit, *stylePtr = NULL; const char *string; int i, boolean; - size_t length; + int length; int config_fullscreen = 0, updatewrapper = 0; int fullscreen_attr_changed = 0, fullscreen_attr = 0; @@ -3072,8 +3074,7 @@ WmAttributesCmd( return TCL_OK; } for (i = 3; i < objc; i += 2) { - string = Tcl_GetString(objv[i]); - length = objv[i]->length; + string = Tcl_GetStringFromObj(objv[i], &length); if ((length < 2) || (string[0] != '-')) { goto configArgs; } @@ -3141,9 +3142,8 @@ WmAttributesCmd( } wmPtr->alpha = dval; } else { /* -transparentcolor */ - const char *crefstr = Tcl_GetString(objv[i+1]); + const char *crefstr = Tcl_GetStringFromObj(objv[i+1], &length); - length = objv[i+1]->length; if (length == 0) { /* reset to no transparent color */ if (wmPtr->crefObj) { @@ -3319,9 +3319,10 @@ WmClientCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; const char *argv3; - size_t length; + int length; + (void)tkwin; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name?"); @@ -3334,8 +3335,7 @@ WmClientCmd( } return TCL_OK; } - argv3 = Tcl_GetString(objv[3]); - length = objv[3]->length; + argv3 = Tcl_GetStringFromObj(objv[3], &length); if (argv3[0] == 0) { if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); @@ -3350,7 +3350,7 @@ WmClientCmd( if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); } - wmPtr->clientMachine = ckalloc(length + 1); + wmPtr->clientMachine = (char *)ckalloc(length + 1); memcpy(wmPtr->clientMachine, argv3, length + 1); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { XTextProperty textProp; @@ -3390,7 +3390,7 @@ WmColormapwindowsCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; TkWindow **cmapList, *winPtr2, **winPtr2Ptr = &winPtr2; int i, windowObjc, gotToplevel; Tcl_Obj **windowObjv, *resultObj; @@ -3417,7 +3417,7 @@ WmColormapwindowsCmd( != TCL_OK) { return TCL_ERROR; } - cmapList = ckalloc((windowObjc + 1) * sizeof(TkWindow*)); + cmapList = (TkWindow**)ckalloc((windowObjc + 1) * sizeof(TkWindow*)); gotToplevel = 0; for (i = 0; i < windowObjc; i++) { if (TkGetWindowFromObj(interp, tkwin, windowObjv[i], @@ -3484,10 +3484,11 @@ WmCommandCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; const char *argv3; int cmdArgc; const char **cmdArgv; + (void)tkwin; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?value?"); @@ -3553,7 +3554,8 @@ WmDeiconifyCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; + (void)tkwin; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -3605,7 +3607,7 @@ WmFocusmodelCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; static const char *const optionStrings[] = { "active", "passive", NULL }; @@ -3613,6 +3615,7 @@ WmFocusmodelCmd( OPT_ACTIVE, OPT_PASSIVE }; int index; + (void)tkwin; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?"); @@ -3657,11 +3660,15 @@ static int WmForgetCmd( Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ - Tcl_Interp *interp, /* Current interpreter. */ + Tcl_Interp *dummy, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register Tk_Window frameWin = (Tk_Window) winPtr; + Tk_Window frameWin = (Tk_Window) winPtr; + (void)tkwin; + (void)dummy; + (void)objc; + (void)objv; if (Tk_IsTopLevel(frameWin)) { Tk_UnmapWindow(frameWin); @@ -3709,9 +3716,10 @@ WmFrameCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; HWND hwnd; char buf[TCL_INTEGER_SPACE]; + (void)tkwin; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -3754,10 +3762,11 @@ WmGeometryCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; char xSign, ySign; int width, height; const char *argv3; + (void)tkwin; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?"); @@ -3822,8 +3831,9 @@ WmGridCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int reqWidth, reqHeight, widthInc, heightInc; + (void)tkwin; if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, @@ -3920,10 +3930,10 @@ WmGroupCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; Tk_Window tkwin2; const char *argv3; - size_t length; + int length; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); @@ -3935,8 +3945,7 @@ WmGroupCmd( } return TCL_OK; } - argv3 = Tcl_GetString(objv[3]); - length = objv[3]->length; + argv3 = Tcl_GetStringFromObj(objv[3], &length); if (*argv3 == '\0') { wmPtr->hints.flags &= ~WindowGroupHint; if (wmPtr->leaderName != NULL) { @@ -3953,7 +3962,7 @@ WmGroupCmd( } wmPtr->hints.window_group = Tk_WindowId(tkwin2); wmPtr->hints.flags |= WindowGroupHint; - wmPtr->leaderName = ckalloc(length + 1); + wmPtr->leaderName = (char *)ckalloc(length + 1); memcpy(wmPtr->leaderName, argv3, length + 1); } return TCL_OK; @@ -3984,9 +3993,10 @@ WmIconbitmapCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; TkWindow *useWinPtr = winPtr; /* window to apply to (NULL if -default) */ const char *string; + (void)tkwin; if ((objc < 3) || (objc > 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?-default? ?image?"); @@ -4120,7 +4130,9 @@ WmIconifyCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; + (void)tkwin; + if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; @@ -4185,7 +4197,7 @@ WmIconmaskCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; Pixmap pixmap; const char *argv3; @@ -4243,9 +4255,10 @@ WmIconnameCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; const char *argv3; - size_t length; + int length; + (void)tkwin; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?"); @@ -4259,9 +4272,8 @@ WmIconnameCmd( if (wmPtr->iconName != NULL) { ckfree(wmPtr->iconName); } - argv3 = Tcl_GetString(objv[3]); - length = objv[3]->length; - wmPtr->iconName = ckalloc(length + 1); + argv3 = Tcl_GetStringFromObj(objv[3], &length); + wmPtr->iconName = (char *)ckalloc(length + 1); memcpy(wmPtr->iconName, argv3, length + 1); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName); @@ -4307,6 +4319,7 @@ WmIconphotoCmd( unsigned size; BITMAPINFO bmInfo; ICONINFO iconInfo; + (void)tkwin; if (objc < 4) { Tcl_WrongNumArgs(interp, 2, objv, @@ -4344,7 +4357,7 @@ WmIconphotoCmd( */ size = sizeof(BlockOfIconImages) + (sizeof(ICONIMAGE) * (objc-startObj-1)); - lpIR = attemptckalloc(size); + lpIR = (BlockOfIconImagesPtr)attemptckalloc(size); if (lpIR == NULL) { return TCL_ERROR; } @@ -4449,7 +4462,7 @@ WmIconphotoCmd( lpIR->IconImages[i-startObj].hIcon = hIcon; } - titlebaricon = ckalloc(sizeof(WinIconInstance)); + titlebaricon = (WinIconPtr)ckalloc(sizeof(WinIconInstance)); titlebaricon->iconBlock = lpIR; titlebaricon->refCount = 1; if (WinSetIcon(interp, titlebaricon, (Tk_Window) useWinPtr) != TCL_OK) { @@ -4488,8 +4501,9 @@ WmIconpositionCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int x, y; + (void)tkwin; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?"); @@ -4544,7 +4558,7 @@ WmIconwindowCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; Tk_Window tkwin2; WmInfo *wmPtr2; XSetWindowAttributes atts; @@ -4654,8 +4668,11 @@ WmManageCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register Tk_Window frameWin = (Tk_Window) winPtr; - register WmInfo *wmPtr = winPtr->wmInfoPtr; + Tk_Window frameWin = (Tk_Window) winPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; + (void)tkwin; + (void)objc; + (void)objv; if (!Tk_IsTopLevel(frameWin)) { if (!Tk_IsManageable(frameWin)) { @@ -4708,8 +4725,9 @@ WmMaxsizeCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int width, height; + (void)tkwin; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); @@ -4759,8 +4777,9 @@ WmMinsizeCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int width, height; + (void)tkwin; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); @@ -4810,9 +4829,10 @@ WmOverrideredirectCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int boolean, curValue; XSetWindowAttributes atts; + (void)tkwin; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); @@ -4882,7 +4902,7 @@ WmPositionfromCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; static const char *const optionStrings[] = { "program", "user", NULL }; @@ -4890,6 +4910,7 @@ WmPositionfromCmd( OPT_PROGRAM, OPT_USER }; int index; + (void)tkwin; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?"); @@ -4950,12 +4971,13 @@ WmProtocolCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; - register ProtocolHandler *protPtr, *prevPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; + ProtocolHandler *protPtr, *prevPtr; Atom protocol; const char *cmd; - size_t cmdLength; + int cmdLength; Tcl_Obj *resultObj; + (void)tkwin; if ((objc < 3) || (objc > 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?"); @@ -5009,10 +5031,9 @@ WmProtocolCmd( break; } } - cmd = Tcl_GetString(objv[4]); - cmdLength = objv[4]->length; + cmd = Tcl_GetStringFromObj(objv[4], &cmdLength); if (cmdLength > 0) { - protPtr = ckalloc(HANDLER_SIZE(cmdLength)); + protPtr = (ProtocolHandler *)ckalloc(HANDLER_SIZE(cmdLength)); protPtr->protocol = protocol; protPtr->nextPtr = wmPtr->protPtr; wmPtr->protPtr = protPtr; @@ -5047,8 +5068,9 @@ WmResizableCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int width, height; + (void)tkwin; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); @@ -5109,7 +5131,7 @@ WmSizefromCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; static const char *const optionStrings[] = { "program", "user", NULL }; @@ -5117,6 +5139,7 @@ WmSizefromCmd( OPT_PROGRAM, OPT_USER }; int index; + (void)tkwin; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?"); @@ -5306,7 +5329,7 @@ WmStateCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; static const char *const optionStrings[] = { "normal", "iconic", "withdrawn", "zoomed", NULL }; @@ -5314,6 +5337,7 @@ WmStateCmd( OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN, OPT_ZOOMED }; int index; + (void)tkwin; if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?state?"); @@ -5446,10 +5470,11 @@ WmTitleCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; const char *argv3; - size_t length; + int length; HWND wrapper; + (void)tkwin; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?"); @@ -5468,7 +5493,8 @@ WmTitleCmd( int size = 256; GetWindowTextW(wrapper, buf, size); - Tcl_WinTCharToUtf((LPCTSTR)buf, -1, &titleString); + Tcl_DStringInit(&titleString); + Tcl_WCharToUtfDString(buf, wcslen(buf), &titleString); Tcl_SetObjResult(interp, Tcl_NewStringObj( Tcl_DStringValue(&titleString), Tcl_DStringLength(&titleString))); @@ -5481,15 +5507,15 @@ WmTitleCmd( if (wmPtr->title != NULL) { ckfree(wmPtr->title); } - argv3 = Tcl_GetString(objv[3]); - length = objv[3]->length; - wmPtr->title = ckalloc(length + 1); + argv3 = Tcl_GetStringFromObj(objv[3], &length); + wmPtr->title = (char *)ckalloc(length + 1); memcpy(wmPtr->title, argv3, length + 1); if (!(wmPtr->flags & WM_NEVER_MAPPED) && wmPtr->wrapper != NULL) { Tcl_DString titleString; - Tcl_WinUtfToTChar(wmPtr->title, -1, &titleString); + Tcl_DStringInit(&titleString); + Tcl_UtfToWCharDString(wmPtr->title, -1, &titleString); SetWindowTextW(wrapper, (LPCWSTR) Tcl_DStringValue(&titleString)); Tcl_DStringFree(&titleString); } @@ -5522,7 +5548,7 @@ WmTransientCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; TkWindow *masterPtr = wmPtr->masterPtr, **masterPtrPtr = &masterPtr, *w; WmInfo *wmPtr2; @@ -5650,7 +5676,8 @@ WmWithdrawCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; + (void)tkwin; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -5695,13 +5722,12 @@ WmUpdateGeom( } } - /*ARGSUSED*/ static void WmWaitVisibilityOrMapProc( ClientData clientData, /* Pointer to window. */ XEvent *eventPtr) /* Information about event. */ { - TkWindow *winPtr = clientData; + TkWindow *winPtr = (TkWindow *)clientData; TkWindow *masterPtr = winPtr->wmInfoPtr->masterPtr; if (masterPtr == NULL) @@ -5762,7 +5788,7 @@ Tk_SetGrid( * of one grid unit. */ { TkWindow *winPtr = (TkWindow *) tkwin; - register WmInfo *wmPtr; + WmInfo *wmPtr; /* * Ensure widthInc and heightInc are greater than 0 @@ -5859,7 +5885,7 @@ Tk_UnsetGrid( * controlling gridding. */ { TkWindow *winPtr = (TkWindow *) tkwin; - register WmInfo *wmPtr; + WmInfo *wmPtr; /* * Find the top-level window for tkwin, plus the window manager @@ -5918,7 +5944,7 @@ TopLevelEventProc( ClientData clientData, /* Window for which event occurred. */ XEvent *eventPtr) /* Event that just happened. */ { - register TkWindow *winPtr = clientData; + TkWindow *winPtr = (TkWindow *)clientData; if (eventPtr->type == DestroyNotify) { Tk_ErrorHandler handler; @@ -5958,7 +5984,6 @@ TopLevelEventProc( *---------------------------------------------------------------------- */ - /* ARGSUSED */ static void TopLevelReqProc( ClientData dummy, /* Not used. */ @@ -5966,6 +5991,7 @@ TopLevelReqProc( { TkWindow *winPtr = (TkWindow *) tkwin; WmInfo *wmPtr; + (void)dummy; wmPtr = winPtr->wmInfoPtr; if (wmPtr) { @@ -6009,8 +6035,8 @@ UpdateGeometryInfo( int width, height; /* Size of client area. */ int min, max; RECT rect; - register TkWindow *winPtr = clientData; - register WmInfo *wmPtr = winPtr->wmInfoPtr; + TkWindow *winPtr = (TkWindow *)clientData; + WmInfo *wmPtr = winPtr->wmInfoPtr; wmPtr->flags &= ~WM_UPDATE_PENDING; @@ -6290,10 +6316,10 @@ ParseGeometry( TkWindow *winPtr) /* Pointer to top-level window whose geometry * is to be changed. */ { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; int x, y, width, height, flags; char *end; - register const char *p = string; + const char *p = string; /* * The leading "=" is optional. @@ -6422,7 +6448,7 @@ Tk_GetRootCoords( int *xPtr, /* Where to store x-displacement of (0,0). */ int *yPtr) /* Where to store y-displacement of (0,0). */ { - register TkWindow *winPtr = (TkWindow *) tkwin; + TkWindow *winPtr = (TkWindow *) tkwin; /* * If the window is mapped, let Windows figure out the translation. @@ -6519,6 +6545,8 @@ Tk_GetVRootGeometry( int *widthPtr, int *heightPtr) /* Store dimensions of virtual root here. */ { + (void)tkwin; + *xPtr = GetSystemMetrics(SM_XVIRTUALSCREEN); *yPtr = GetSystemMetrics(SM_YVIRTUALSCREEN); *widthPtr = GetSystemMetrics(SM_CXVIRTUALSCREEN); @@ -6551,7 +6579,7 @@ Tk_MoveToplevelWindow( int x, int y) /* New location for window (within parent). */ { TkWindow *winPtr = (TkWindow *) tkwin; - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window"); @@ -6602,7 +6630,7 @@ TkWmProtocolEventProc( XEvent *eventPtr) /* X event. */ { WmInfo *wmPtr; - register ProtocolHandler *protPtr; + ProtocolHandler *protPtr; Atom protocol; int result; Tcl_Interp *interp; @@ -6680,7 +6708,7 @@ TkWmStackorderToplevelEnumProc( hPtr = Tcl_FindHashEntry(pair->table, (char *) hwnd); if (hPtr != NULL) { - childWinPtr = Tcl_GetHashValue(hPtr); + childWinPtr = (TkWindow *)Tcl_GetHashValue(hPtr); /* * Double check that same HWND does not get passed twice. @@ -6780,7 +6808,7 @@ TkWmStackorderToplevel( Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS); TkWmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table); - windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *)); + windows = (TkWindow **)ckalloc((table.numEntries+1) * sizeof(TkWindow *)); /* * Special cases: If zero or one toplevels were mapped there is no need to @@ -6793,7 +6821,7 @@ TkWmStackorderToplevel( goto done; case 1: hPtr = Tcl_FirstHashEntry(&table, &search); - windows[0] = Tcl_GetHashValue(hPtr); + windows[0] = (TkWindow *)Tcl_GetHashValue(hPtr); windows[1] = NULL; goto done; } @@ -6956,7 +6984,7 @@ TkWmAddToColormapWindows( * Automatically add the toplevel itself as the last element of the list. */ - newPtr = ckalloc((count+2) * sizeof(TkWindow *)); + newPtr = (TkWindow **)ckalloc((count+2) * sizeof(TkWindow *)); if (count > 0) { memcpy(newPtr, oldPtr, count * sizeof(TkWindow*)); } @@ -8252,7 +8280,7 @@ TkpGetWrapperWindow( static void GenerateActivateEvent(TkWindow * winPtr, const int *flagPtr) { - ActivateEvent *eventPtr = ckalloc(sizeof(ActivateEvent)); + ActivateEvent *eventPtr = (ActivateEvent *)ckalloc(sizeof(ActivateEvent)); eventPtr->ev.proc = ActivateWindow; eventPtr->winPtr = winPtr; @@ -8355,7 +8383,7 @@ void TkWinSetForegroundWindow( TkWindow *winPtr) { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; if (wmPtr->wrapper != NULL) { SetForegroundWindow(wmPtr->wrapper); @@ -8385,7 +8413,7 @@ void TkpWinToplevelWithDraw( TkWindow *winPtr) { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; wmPtr->flags |= WM_WITHDRAWN; TkpWmSetState(winPtr, WithdrawnState); @@ -8436,7 +8464,7 @@ void TkpWinToplevelDeiconify( TkWindow *winPtr) { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; wmPtr->flags &= ~WM_WITHDRAWN; @@ -8504,7 +8532,7 @@ long TkpWinToplevelIsControlledByWm( TkWindow *winPtr) { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; if (!wmPtr) { return 0; @@ -8534,7 +8562,7 @@ TkpWinToplevelMove( TkWindow *winPtr, int x, int y) { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; if (wmPtr && x >= 0 && y >= 0 && !TkpWinToplevelIsControlledByWm(winPtr)) { Tk_MoveToplevelWindow((Tk_Window) winPtr, x, y); @@ -8566,7 +8594,7 @@ TkpWinToplevelOverrideRedirect( int reqValue) { int curValue; - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; curValue = Tk_Attributes((Tk_Window) winPtr)->override_redirect; if (reqValue < 0) { @@ -8613,7 +8641,7 @@ void TkpWinToplevelDetachWindow( TkWindow *winPtr) { - register WmInfo *wmPtr = winPtr->wmInfoPtr; + WmInfo *wmPtr = winPtr->wmInfoPtr; if (winPtr->flags & TK_EMBEDDED) { int state = SendMessageW(wmPtr->wrapper, TK_STATE, -1, -1) - 1; diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 23e4923..8f071d5 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -106,7 +106,7 @@ LoadXPThemeProcs(HINSTANCE *phlib) * We have successfully loaded the library. Proceed in storing the * addresses of the functions we want to use. */ - XPThemeProcs *procs = ckalloc(sizeof(XPThemeProcs)); + XPThemeProcs *procs = (XPThemeProcs *)ckalloc(sizeof(XPThemeProcs)); #define LOADPROC(name) \ (0 != (procs->name = (name ## Proc *)(void *)GetProcAddress(handle, #name) )) @@ -138,7 +138,7 @@ LoadXPThemeProcs(HINSTANCE *phlib) static void XPThemeDeleteProc(void *clientData) { - XPThemeData *themeData = clientData; + XPThemeData *themeData = (XPThemeData *)clientData; FreeLibrary(themeData->hlibrary); ckfree(clientData); } @@ -146,9 +146,11 @@ XPThemeDeleteProc(void *clientData) static int XPThemeEnabled(Ttk_Theme theme, void *clientData) { - XPThemeData *themeData = clientData; + XPThemeData *themeData = (XPThemeData *)clientData; int active = themeData->procs->IsThemeActive(); int themed = themeData->procs->IsAppThemed(); + (void)theme; + return (active && themed); } @@ -382,12 +384,12 @@ typedef struct /* XP element specifications */ int partId; /* BP_PUSHBUTTON, BP_CHECKBUTTON, etc. */ Ttk_StateTable *statemap; /* Map Tk states to XP states */ Ttk_Padding padding; /* See NOTE-GetThemeMargins */ - int flags; -# define IGNORE_THEMESIZE 0x80000000 /* See NOTE-GetThemePartSize */ -# define PAD_MARGINS 0x40000000 /* See NOTE-GetThemeMargins */ -# define HEAP_ELEMENT 0x20000000 /* ElementInfo is on heap */ -# define HALF_HEIGHT 0x10000000 /* Used by GenericSizedElements */ -# define HALF_WIDTH 0x08000000 /* Used by GenericSizedElements */ + unsigned flags; +# define IGNORE_THEMESIZE 0x80000000U /* See NOTE-GetThemePartSize */ +# define PAD_MARGINS 0x40000000U /* See NOTE-GetThemeMargins */ +# define HEAP_ELEMENT 0x20000000U /* ElementInfo is on heap */ +# define HALF_HEIGHT 0x10000000U /* Used by GenericSizedElements */ +# define HALF_WIDTH 0x08000000U /* Used by GenericSizedElements */ } ElementInfo; typedef struct @@ -413,7 +415,7 @@ typedef struct static ElementData * NewElementData(XPThemeProcs *procs, ElementInfo *info) { - ElementData *elementData = ckalloc(sizeof(ElementData)); + ElementData *elementData = (ElementData *)ckalloc(sizeof(ElementData)); elementData->procs = procs; elementData->info = info; @@ -429,12 +431,12 @@ NewElementData(XPThemeProcs *procs, ElementInfo *info) */ static void DestroyElementData(void *clientData) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; if (elementData->info->flags & HEAP_ELEMENT) { - ckfree(elementData->info->statemap); - ckfree(elementData->info->className); - ckfree(elementData->info->elementName); - ckfree(elementData->info); + ckfree((char *)elementData->info->statemap); + ckfree((char *)elementData->info->className); + ckfree((char *)elementData->info->elementName); + ckfree((char *)elementData->info); } ckfree(clientData); } @@ -497,9 +499,10 @@ static void GenericElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; HRESULT result; SIZE size; + (void)elementRecord; if (!InitElementData(elementData, tkwin, 0)) return; @@ -533,8 +536,9 @@ static void GenericElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; RECT rc; + (void)elementRecord; if (!InitElementData(elementData, tkwin, d)) { return; @@ -578,7 +582,7 @@ GenericSizedElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; if (!InitElementData(elementData, tkwin, 0)) return; @@ -614,7 +618,7 @@ SpinboxArrowElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; if (!InitElementData(elementData, tkwin, 0)) return; @@ -643,9 +647,10 @@ static void ThumbElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; unsigned stateId = Ttk_StateTableLookup(elementData->info->statemap, state); RECT rc = BoxToRect(b); + (void)elementRecord; /* * Don't draw the thumb if we are disabled. @@ -682,7 +687,7 @@ static void PbarElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; int nBars = 3; GenericElementSize(clientData, elementRecord, tkwin, @@ -722,9 +727,10 @@ static void TabElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; int partId = elementData->info->partId; RECT rc = BoxToRect(b); + (void)elementRecord; if (!InitElementData(elementData, tkwin, d)) return; @@ -812,7 +818,7 @@ typedef struct Tcl_Obj *fontObj; } TextElement; -static Ttk_ElementOptionSpec TextElementOptions[] = +static const Ttk_ElementOptionSpec TextElementOptions[] = { { "-text", TK_OPTION_STRING, Tk_Offset(TextElement,textObj), "" }, @@ -837,13 +843,13 @@ static void TextElementSize( return; src = Tcl_GetStringFromObj(element->textObj, &len); - Tcl_WinUtfToTChar(src, len, &ds); + Tcl_DStringInit(&ds); hr = elementData->procs->GetThemeTextExtent( elementData->hTheme, elementData->hDC, elementData->info->partId, Ttk_StateTableLookup(elementData->info->statemap, 0), - (WCHAR *) Tcl_DStringValue(&ds), + Tcl_UtfToWCharDString(src, len, &ds), -1, DT_LEFT,// | DT_BOTTOM | DT_NOPREFIX, NULL, @@ -876,13 +882,13 @@ static void TextElementDraw( return; src = Tcl_GetStringFromObj(element->textObj, &len); - Tcl_WinUtfToTChar(src, len, &ds); + Tcl_DStringInit(&ds); hr = elementData->procs->DrawThemeText( elementData->hTheme, elementData->hDC, elementData->info->partId, Ttk_StateTableLookup(elementData->info->statemap, state), - (WCHAR *) Tcl_DStringValue(&ds), + Tcl_UtfToWCharDString(src, len, &ds), -1, DT_LEFT,// | DT_BOTTOM | DT_NOPREFIX, (state & TTK_STATE_DISABLED) ? DTT_GRAYED : 0, @@ -1058,7 +1064,7 @@ static ElementInfo ElementInfoTable[] = { static int GetSysFlagFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr) { - static const char *names[] = { + static const char *const names[] = { "SM_CXBORDER", "SM_CYBORDER", "SM_CXVSCROLL", "SM_CYVSCROLL", "SM_CXHSCROLL", "SM_CYHSCROLL", "SM_CXMENUCHECK", "SM_CYMENUCHECK", "SM_CXMENUSIZE", "SM_CYMENUSIZE", "SM_CXSIZE", "SM_CYSIZE", "SM_CXSMSIZE", @@ -1112,7 +1118,7 @@ Ttk_CreateVsapiElement( int objc, Tcl_Obj *const objv[]) { - XPThemeData *themeData = clientData; + XPThemeData *themeData = (XPThemeData *)clientData; ElementInfo *elementPtr = NULL; ClientData elementData; LPCWSTR className; @@ -1126,7 +1132,7 @@ Ttk_CreateVsapiElement( Ttk_ElementSpec *elementSpec = &GenericElementSpec; Tcl_DString classBuf; - static const char *optionStrings[] = + static const char *const optionStrings[] = { "-padding","-width","-height","-margins", "-syssize", "-halfheight", "-halfwidth", NULL }; enum { O_PADDING, O_WIDTH, O_HEIGHT, O_MARGINS, O_SYSSIZE, @@ -1143,7 +1149,8 @@ Ttk_CreateVsapiElement( return TCL_ERROR; } name = Tcl_GetStringFromObj(objv[0], &length); - className = (LPCWSTR) Tcl_WinUtfToTChar(name, length, &classBuf); + Tcl_DStringInit(&classBuf); + className = Tcl_UtfToWCharDString(name, length, &classBuf); /* flags or padding */ if (objc > 3) { @@ -1218,7 +1225,7 @@ Ttk_CreateVsapiElement( if (Tcl_ListObjGetElements(interp, objv[2], &count, &specs) != TCL_OK) goto retErr; /* we over-allocate to ensure there is a terminating entry */ - stateTable = ckalloc(sizeof(Ttk_StateTable) * (count + 1)); + stateTable = (Ttk_StateTable *)ckalloc(sizeof(Ttk_StateTable) * (count + 1)); memset(stateTable, 0, sizeof(Ttk_StateTable) * (count + 1)); for (n = 0, j = 0; status == TCL_OK && n < count; n += 2, ++j) { Ttk_StateSpec spec = {0,0}; @@ -1236,11 +1243,11 @@ Ttk_CreateVsapiElement( return status; } } else { - stateTable = ckalloc(sizeof(Ttk_StateTable)); + stateTable = (Ttk_StateTable *)ckalloc(sizeof(Ttk_StateTable)); memset(stateTable, 0, sizeof(Ttk_StateTable)); } - elementPtr = ckalloc(sizeof(ElementInfo)); + elementPtr = (ElementInfo *)ckalloc(sizeof(ElementInfo)); elementPtr->elementSpec = elementSpec; elementPtr->partId = partId; elementPtr->statemap = stateTable; @@ -1248,12 +1255,12 @@ Ttk_CreateVsapiElement( elementPtr->flags = HEAP_ELEMENT | flags; /* set the element name to an allocated copy */ - name = ckalloc(strlen(elementName) + 1); + name = (char *)ckalloc(strlen(elementName) + 1); strcpy(name, elementName); elementPtr->elementName = name; /* set the class name to an allocated copy */ - wname = ckalloc(Tcl_DStringLength(&classBuf) + sizeof(WCHAR)); + wname = (LPWSTR)ckalloc(Tcl_DStringLength(&classBuf) + sizeof(WCHAR)); wcscpy(wname, className); elementPtr->className = wname; @@ -1305,7 +1312,7 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd) * Set theme data and cleanup proc */ - themeData = ckalloc(sizeof(XPThemeData)); + themeData = (XPThemeData *)ckalloc(sizeof(XPThemeData)); themeData->procs = procs; themeData->hlibrary = hlibrary; |