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/ttk | |
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/ttk')
-rw-r--r-- | generic/ttk/ttkCache.c | 10 | ||||
-rw-r--r-- | generic/ttk/ttkEntry.c | 12 | ||||
-rw-r--r-- | generic/ttk/ttkTreeview.c | 12 |
3 files changed, 29 insertions, 5 deletions
diff --git a/generic/ttk/ttkCache.c b/generic/ttk/ttkCache.c index c29007c..7b5ca01 100644 --- a/generic/ttk/ttkCache.c +++ b/generic/ttk/ttkCache.c @@ -31,6 +31,14 @@ #include "tkInt.h" #include "ttkTheme.h" +#ifdef _MSC_VER +/* + * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. + * Note that sprintf is deprecated. + */ +# define snprintf _snprintf +#endif + struct Ttk_ResourceCache_ { Tcl_Interp *interp; /* Interpreter for error reporting */ Tk_Window tkwin; /* Cache window. */ @@ -209,7 +217,7 @@ void Ttk_RegisterNamedColor( char nameBuf[14]; Tcl_Obj *colorNameObj; - sprintf(nameBuf, "#%04X%04X%04X", + snprintf(nameBuf, sizeof(nameBuf), "#%04X%04X%04X", colorPtr->red, colorPtr->green, colorPtr->blue); colorNameObj = Tcl_NewStringObj(nameBuf, -1); Tcl_IncrRefCount(colorNameObj); diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 6cf88c3..fe684a7 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -12,6 +12,14 @@ #include "ttkTheme.h" #include "ttkWidget.h" +#ifdef _MSC_VER +/* + * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. + * Note that sprintf is deprecated. + */ +# define snprintf _snprintf +#endif + /* * Extra bits for core.flags: */ @@ -443,11 +451,11 @@ ExpandPercents( } else { number = -1; } - sprintf(numStorage, "%d", number); + snprintf(numStorage, sizeof(numStorage), "%d", number); string = numStorage; break; case 'i': /* index of insert/delete */ - sprintf(numStorage, "%d", index); + snprintf(numStorage, sizeof(numStorage), "%d", index); string = numStorage; break; case 'P': /* 'Peeked' new value of the string */ diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index 0dff72f..e6267cf 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -8,6 +8,14 @@ #include "ttkTheme.h" #include "ttkWidget.h" +#ifdef _MSC_VER +/* + * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. + * Note that sprintf is deprecated. + */ +# define snprintf _snprintf +#endif + #define MAX(a,b) ((a) > (b) ? (a) : (b)) #define DEF_TREE_ROWS "10" @@ -2209,7 +2217,7 @@ static int TreeviewHorribleIdentify( if (dColumnNumber < 0) { goto done; } - sprintf(dcolbuf, "#%d", dColumnNumber); + snprintf(dcolbuf, sizeof(dcolbuf), "#%d", dColumnNumber); if (Ttk_BoxContains(tv->tree.headingArea,x,y)) { if (-HALO <= x1 - x && x1 - x <= HALO) { @@ -2598,7 +2606,7 @@ static int TreeviewInsertCommand( char idbuf[16]; do { ++tv->tree.serial; - sprintf(idbuf, "I%03X", tv->tree.serial); + snprintf(idbuf, sizeof(idbuf), "I%03X", tv->tree.serial); entryPtr = Tcl_CreateHashEntry(&tv->tree.items, idbuf, &isNew); } while (!isNew); } |