From 5b0ab3da0e490d51ca930773cc40292bdc101a00 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 26 Sep 2019 08:56:18 +0000 Subject: Better fix for [2026405]: winfo id bug in cygwin build. Actually, formatting of %p is libc-specific, now that we have TCL_Z_MODIFIER we can make it platform-independant for all cases. --- generic/tkCursor.c | 2 +- generic/tkStubInit.c | 2 +- win/tkWinDialog.c | 2 +- win/tkWinSend.c | 2 +- win/tkWinWindow.c | 11 +---------- 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/generic/tkCursor.c b/generic/tkCursor.c index ff66d17..21c713a 100644 --- a/generic/tkCursor.c +++ b/generic/tkCursor.c @@ -425,7 +425,7 @@ Tk_NameOfCursor( if (!dispPtr->cursorInit) { printid: - sprintf(dispPtr->cursorString, "cursor id %p", cursor); + sprintf(dispPtr->cursorString, "cursor id 0x%" TCL_Z_MODIFIER "x", (size_t)cursor); return dispPtr->cursorString; } idHashPtr = Tcl_FindHashEntry(&dispPtr->cursorIdTable, (char *) cursor); diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 10669ad..d6af991 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -116,7 +116,7 @@ TkpPrintWindowId( * the hex representation of a pointer. */ Window window) /* Window to be printed into buffer. */ { - sprintf(buf, "%#08lx", (unsigned long) (window)); + sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)window); } int diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 27137e7..8640e6a 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -3014,7 +3014,7 @@ SetTkDialog( Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); char buf[32]; - sprintf(buf, "0x%p", (HWND) clientData); + sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)clientData); Tcl_SetVar2(tsdPtr->debugInterp, "tk_dialog", NULL, buf, TCL_GLOBAL_ONLY); } diff --git a/win/tkWinSend.c b/win/tkWinSend.c index d8ef23b..8fa1eaf 100644 --- a/win/tkWinSend.c +++ b/win/tkWinSend.c @@ -150,7 +150,7 @@ Tk_SetAppName( return ""; } tsdPtr->initialized = 1; - TRACE("Initialized COM library for interp 0x%08X\n", (long)interp); + TRACE("Initialized COM library for interp 0x%" TCL_Z_MODIFIER "x\n", (size_t)interp); } /* diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index ceceee6..56fc87c 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -170,16 +170,7 @@ TkpPrintWindowId( { HWND hwnd = (window) ? Tk_GetHWND(window) : 0; - /* - * Use pointer representation, because Win64 is P64 (*not* LP64). Windows - * doesn't print the 0x for %p, so we do it. - * Bug 2026405: cygwin does output 0x for %p so test and recover. - */ - - sprintf(buf, "0x%p", hwnd); - if (buf[2] == '0' && buf[3] == 'x') { - sprintf(buf, "%p", hwnd); - } + sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)hwnd); } /* -- cgit v0.12