diff options
author | fvogel <fvogelnew1@free.fr> | 2023-01-10 22:02:07 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2023-01-10 22:02:07 (GMT) |
commit | de829322e7a608e3f34d647a6674c32909c24689 (patch) | |
tree | e1bf010662468253e4acc69da003c61f1558df61 /generic/tkCmds.c | |
parent | 7249bffdfb065bb08b668338d6c68291fa19654b (diff) | |
download | tk-de829322e7a608e3f34d647a6674c32909c24689.zip tk-de829322e7a608e3f34d647a6674c32909c24689.tar.gz tk-de829322e7a608e3f34d647a6674c32909c24689.tar.bz2 |
Eradicate uses of sprintf because it triggers deprecation warning on macOS Ventura. Only a single instance left in TkpPrintWindowId() (tkWinWindow.c).
Diffstat (limited to 'generic/tkCmds.c')
-rw-r--r-- | generic/tkCmds.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/generic/tkCmds.c b/generic/tkCmds.c index b9e07e7..20e8c48 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -22,6 +22,14 @@ #include "tkUnixInt.h" #endif +#ifdef _MSC_VER +/* + * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. + * Note that sprintf is deprecated. + */ +# define snprintf _snprintf +#endif + /* * Forward declarations for functions defined later in this file: */ @@ -1805,10 +1813,10 @@ Tk_WinfoObjCmd( if (string == NULL) { strcpy(buf, "unknown"); } else { - sprintf(buf, "%s %d", string, visInfoPtr[i].depth); + snprintf(buf, sizeof(buf), "%s %d", string, visInfoPtr[i].depth); } if (includeVisualId) { - sprintf(visualIdString, " 0x%lx", + snprintf(visualIdString, sizeof(visualIdString), " 0x%lx", (unsigned long) visInfoPtr[i].visualid); strcat(buf, visualIdString); } |