diff --git a/generic/tk.decls b/generic/tk.decls index d3aaa6df8..3c94054f2 100644 --- a/generic/tk.decls +++ b/generic/tk.decls @@ -806,7 +806,7 @@ declare 211 { Tk_OptionTable optionToken, Tk_Window tkwin) } declare 212 {nostub {Don't use this function in a stub-enabled extension}} { - void Tk_MainEx(Tcl_Size argc, char **argv, Tcl_AppInitProc *appInitProc, + TCL_NORETURN1 void Tk_MainEx(Tcl_Size argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp) } declare 213 { @@ -1216,11 +1216,11 @@ export { int exact) } export { - void Tk_MainEx(Tcl_Size argc, char **argv, Tcl_AppInitProc *appInitProc, + TCL_NORETURN1 void Tk_MainEx(Tcl_Size argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp) } export { - void Tk_MainExW(Tcl_Size argc, wchar_t **argv, + TCL_NORETURN1 void Tk_MainExW(Tcl_Size argc, wchar_t **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); } diff --git a/generic/tkConfig.c b/generic/tkConfig.c index c1325c393..7362831c1 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -2176,7 +2176,7 @@ GetObjectForOption( objPtr = Tcl_NewStringObj(*((char **)internalPtr), TCL_INDEX_NONE); break; case TK_OPTION_STRING_TABLE: { - int value; + int value = 0; if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) { value = *((signed char *)internalPtr); diff --git a/generic/tkDecls.h b/generic/tkDecls.h index 22d1fd7c7..daeaee8cd 100644 --- a/generic/tkDecls.h +++ b/generic/tkDecls.h @@ -680,7 +680,7 @@ EXTERN int Tk_GetScrollInfoObj(Tcl_Interp *interp, EXTERN int Tk_InitOptions(Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin); /* 212 */ -EXTERN void Tk_MainEx(Tcl_Size argc, char **argv, +EXTERN TCL_NORETURN1 void Tk_MainEx(Tcl_Size argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); /* 213 */ @@ -1149,7 +1149,7 @@ typedef struct TkStubs { int (*tk_GetReliefFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr); /* 209 */ int (*tk_GetScrollInfoObj) (Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[], double *dblPtr, int *intPtr); /* 210 */ int (*tk_InitOptions) (Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin); /* 211 */ - TCL_DEPRECATED_API("Don't use this function in a stub-enabled extension") void (*tk_MainEx) (Tcl_Size argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); /* 212 */ + TCL_DEPRECATED_API("Don't use this function in a stub-enabled extension") TCL_NORETURN1 void (*tk_MainEx) (Tcl_Size argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); /* 212 */ void (*tk_RestoreSavedOptions) (Tk_SavedOptions *savePtr); /* 213 */ int (*tk_SetOptions) (Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionTable, Tcl_Size objc, Tcl_Obj *const objv[], Tk_Window tkwin, Tk_SavedOptions *savePtr, int *maskPtr); /* 214 */ void (*tk_InitConsoleChannels) (Tcl_Interp *interp); /* 215 */ diff --git a/generic/tkMain.c b/generic/tkMain.c index 949afca9a..a712dcebc 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -16,7 +16,9 @@ #include "tkInt.h" -extern int TkCygwinMainEx(Tcl_Size, char **, Tcl_AppInitProc *, Tcl_Interp *); +#if defined(_WIN32) && !defined(UNICODE) && !defined(STATIC_BUILD) +MODULE_SCOPE void TkCygwinMainEx(Tcl_Size, char **, Tcl_AppInitProc *, Tcl_Interp *); +#endif /* * The default prompt used when the user has not overridden it. @@ -161,7 +163,7 @@ static void StdinProc(void *clientData, int mask); *---------------------------------------------------------------------- */ -void +TCL_NORETURN1 void Tk_MainEx( Tcl_Size argc, /* Number of arguments. */ TCHAR **argv, /* Array of argument strings. */ @@ -204,10 +206,8 @@ Tk_MainEx( * Tk_MainEx function of libtk8.?.dll, not this one. */ if (Tcl_GetVar2(interp, "env", "DISPLAY", TCL_GLOBAL_ONLY)) { loadCygwinTk: - if (TkCygwinMainEx(argc, argv, appInitProc, interp)) { - /* Should never reach here. */ - return; - } + TkCygwinMainEx(argc, argv, appInitProc, interp); + /* Only returns when Tk_MainEx() was not found */ } else { Tcl_Size j; diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 53f6936ed..8c9d5569f 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -2943,7 +2943,7 @@ DeleteWindowsExitProc( tsdPtr->initialized = 0; } -#if defined(_WIN32) +#if defined(_WIN32) && !defined(STATIC_BUILD) static HMODULE tkcygwindll = NULL; @@ -2954,9 +2954,8 @@ static HMODULE tkcygwindll = NULL; * This means that the system encoding is utf-8, so we don't have to do any * encoding conversions. */ -extern int TkCygwinMainEx(Tcl_Size, char **, Tcl_AppInitProc *, Tcl_Interp *); -int +MODULE_SCOPE void TkCygwinMainEx( Tcl_Size argc, /* Number of arguments. */ char **argv, /* Array of argument strings. */ @@ -2975,20 +2974,20 @@ TkCygwinMainEx( name[len-2] = '.'; name[len-1] = name[len-5]; wcscpy(name+len, L".dll"); +#if TCL_MAJOR_VERSION > 8 + memcpy(name+len-12, L"libtcl9tk8", 10 * sizeof(WCHAR)); +#else memcpy(name+len-8, L"libtk8", 6 * sizeof(WCHAR)); +#endif tkcygwindll = LoadLibraryW(name); - if (!tkcygwindll) { - /* dll is not present */ - return 0; - } - tkmainex = (void (*)(Tcl_Size, char **, Tcl_AppInitProc *, Tcl_Interp *)) - (void *)GetProcAddress(tkcygwindll, "Tk_MainEx"); - if (!tkmainex) { - return 0; + if (tkcygwindll) { + tkmainex = (void (*)(Tcl_Size, char **, Tcl_AppInitProc *, Tcl_Interp *)) + (void *)GetProcAddress(tkcygwindll, "Tk_MainEx"); + if (tkmainex) { + tkmainex(argc, argv, appInitProc, interp); + } } - tkmainex(argc, argv, appInitProc, interp); - return 1; } #endif /* _WIN32 */