From de829322e7a608e3f34d647a6674c32909c24689 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 10 Jan 2023 22:02:07 +0000 Subject: Eradicate uses of sprintf because it triggers deprecation warning on macOS Ventura. Only a single instance left in TkpPrintWindowId() (tkWinWindow.c). --- generic/tkBitmap.c | 10 +++++++++- generic/tkBusy.c | 10 +++++++++- generic/tkCanvLine.c | 10 +++++++++- generic/tkCanvUtil.c | 12 ++++++++++-- generic/tkCmds.c | 12 ++++++++++-- generic/tkColor.c | 10 +++++++++- generic/tkConfig.c | 16 ++++++++++++---- generic/tkCursor.c | 10 +++++++++- generic/tkEntry.c | 20 ++++++++++++++------ generic/tkEntry.h | 6 +++--- generic/tkFont.c | 14 +++++++++++--- generic/tkImage.c | 10 +++++++++- generic/tkImgPPM.c | 12 ++++++++++-- generic/tkImgPhInstance.c | 12 ++++++++++-- generic/tkOldConfig.c | 12 ++++++++++-- generic/tkOldTest.c | 16 ++++++++++++---- generic/tkScale.c | 17 +++++++++++------ generic/tkScale.h | 4 ++-- generic/tkSelect.c | 10 +++++++++- generic/tkStubInit.c | 2 +- generic/tkTest.c | 22 +++++++++++++++------- generic/tkTextDisp.c | 14 +++++++++++--- generic/tkTextImage.c | 10 +++++++++- generic/tkTextIndex.c | 10 +++++++++- generic/tkUtil.c | 12 ++++++++++-- generic/ttk/ttkCache.c | 10 +++++++++- generic/ttk/ttkEntry.c | 12 ++++++++++-- generic/ttk/ttkTreeview.c | 12 ++++++++++-- macosx/tkMacOSXEmbed.c | 2 +- macosx/tkMacOSXHLEvents.c | 4 ++-- macosx/tkMacOSXPort.h | 2 +- macosx/tkMacOSXSend.c | 2 +- macosx/tkMacOSXWm.c | 2 +- unix/tkUnixEmbed.c | 4 ++-- unix/tkUnixFont.c | 4 ++-- unix/tkUnixPort.h | 2 +- unix/tkUnixSelect.c | 4 ++-- unix/tkUnixSend.c | 10 +++++----- unix/tkUnixWm.c | 2 +- win/tkWinButton.c | 10 +++++++++- win/tkWinDialog.c | 10 +++++++++- win/tkWinMenu.c | 10 +++++++++- win/tkWinScrlbr.c | 10 +++++++++- win/tkWinSend.c | 10 +++++++++- win/tkWinTest.c | 16 ++++++++++++---- win/tkWinWindow.c | 8 ++++++++ win/tkWinWm.c | 10 +++++++++- win/tkWinX.c | 12 ++++++++++-- 48 files changed, 365 insertions(+), 96 deletions(-) diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c index 55317de..6e046c7 100644 --- a/generic/tkBitmap.c +++ b/generic/tkBitmap.c @@ -42,6 +42,14 @@ #pragma warning (default : 4305) #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 + /* * One of the following data structures exists for each bitmap that is * currently in use. Each structure is indexed with both "idTable" and @@ -834,7 +842,7 @@ Tk_GetBitmapFromData( name = (char *)Tcl_GetHashValue(dataHashPtr); } else { dispPtr->bitmapAutoNumber++; - sprintf(string, "_tk%d", dispPtr->bitmapAutoNumber); + snprintf(string, sizeof(string), "_tk%d", dispPtr->bitmapAutoNumber); name = string; Tcl_SetHashValue(dataHashPtr, name); if (Tk_DefineBitmap(interp, name, source, width, height) != TCL_OK) { diff --git a/generic/tkBusy.c b/generic/tkBusy.c index 6f58c52..ea3ac16 100644 --- a/generic/tkBusy.c +++ b/generic/tkBusy.c @@ -16,6 +16,14 @@ #include "tkBusy.h" #include "default.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 + /* * Things about the busy system that may be configured. Note that on some * platforms this may or may not have an effect. @@ -550,7 +558,7 @@ CreateBusy( tkChild = NextChild(tkChild)) { Tk_MakeWindowExist(tkChild); } - sprintf(name, fmt, Tk_Name(tkRef)); + snprintf(name, sizeof(name), fmt, Tk_Name(tkRef)); tkBusy = Tk_CreateWindow(interp, tkParent, name, NULL); ckfree(name); diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c index 2633744..cfa55f5 100644 --- a/generic/tkCanvLine.c +++ b/generic/tkCanvLine.c @@ -15,6 +15,14 @@ #include "tkCanvas.h" #include "default.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 + /* * The structure below defines the record for each line item. */ @@ -2075,7 +2083,7 @@ PrintArrowShape( LineItem *linePtr = (LineItem *) recordPtr; char *buffer = (char *)ckalloc(120); - sprintf(buffer, "%.5g %.5g %.5g", linePtr->arrowShapeA, + snprintf(buffer, sizeof(buffer), "%.5g %.5g %.5g", linePtr->arrowShapeA, linePtr->arrowShapeB, linePtr->arrowShapeC); *freeProcPtr = TCL_DYNAMIC; return buffer; diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c index 86439df..9eedf6b 100644 --- a/generic/tkCanvUtil.c +++ b/generic/tkCanvUtil.c @@ -13,6 +13,14 @@ #include "tkInt.h" #include "tkCanvas.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 + /* * Structures defined only in this file. */ @@ -570,9 +578,9 @@ TkCanvasDashPrintProc( *freeProcPtr = TCL_DYNAMIC; p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array; - sprintf(buffer, "%d", *p++ & 0xff); + snprintf(buffer, sizeof(buffer), "%d", *p++ & 0xff); while (--i) { - sprintf(buffer+strlen(buffer), " %d", *p++ & 0xff); + snprintf(buffer+strlen(buffer), sizeof(buffer)-strlen(buffer), " %d", *p++ & 0xff); } return buffer; } 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); } diff --git a/generic/tkColor.c b/generic/tkColor.c index 6b6405a..3a097ed 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -15,6 +15,14 @@ #include "tkInt.h" #include "tkColor.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 + /* * Structures of the following following type are used as keys for * colorValueTable (in TkDisplay). @@ -371,7 +379,7 @@ Tk_NameOfColor( ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - sprintf(tsdPtr->rgbString, "#%04x%04x%04x", colorPtr->red, + snprintf(tsdPtr->rgbString, sizeof(tsdPtr->rgbString), "#%04x%04x%04x", colorPtr->red, colorPtr->green, colorPtr->blue); /* diff --git a/generic/tkConfig.c b/generic/tkConfig.c index ba80776..69f0fa6 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -26,6 +26,14 @@ #include "tkInt.h" #include "tkFont.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 + /* * The following encoding is used in TYPE_FLAGS: * @@ -509,19 +517,19 @@ Tk_InitOptions( switch (source) { case OPTION_DATABASE: - sprintf(msg, "\n (database entry for \"%.50s\")", + snprintf(msg, sizeof(msg), "\n (database entry for \"%.50s\")", optionPtr->specPtr->optionName); break; case SYSTEM_DEFAULT: - sprintf(msg, "\n (system default for \"%.50s\")", + snprintf(msg, sizeof(msg), "\n (system default for \"%.50s\")", optionPtr->specPtr->optionName); break; case TABLE_DEFAULT: - sprintf(msg, "\n (default value for \"%.50s\")", + snprintf(msg, sizeof(msg), "\n (default value for \"%.50s\")", optionPtr->specPtr->optionName); } if (tkwin != NULL) { - sprintf(msg + strlen(msg) - 1, " in widget \"%.50s\")", + snprintf(msg + strlen(msg) - 1, sizeof(msg) - (strlen(msg) - 1), " in widget \"%.50s\")", Tk_PathName(tkwin)); } Tcl_AddErrorInfo(interp, msg); diff --git a/generic/tkCursor.c b/generic/tkCursor.c index 902472b..9f06843 100644 --- a/generic/tkCursor.c +++ b/generic/tkCursor.c @@ -14,6 +14,14 @@ #include "tkInt.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 + /* * A TkCursor structure exists for each cursor that is currently active. Each * structure is indexed with two hash tables defined below. One of the tables @@ -425,7 +433,7 @@ Tk_NameOfCursor( if (!dispPtr->cursorInit) { printid: - sprintf(dispPtr->cursorString, "cursor id 0x%" TCL_Z_MODIFIER "x", (size_t)cursor); + snprintf(dispPtr->cursorString, sizeof(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/tkEntry.c b/generic/tkEntry.c index bf7626a..c0388a3 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -19,6 +19,14 @@ #include "default.h" #include "tkEntry.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 + /* * The following macro defines how many extra pixels to leave on each side of * the text in the entry. @@ -1370,7 +1378,7 @@ ConfigureEntry( } else if (dvalue < sbPtr->fromValue) { dvalue = sbPtr->fromValue; } - sprintf(sbPtr->formatBuf, sbPtr->valueFormat, dvalue); + snprintf(sbPtr->formatBuf, sizeof(sbPtr->formatBuf), sbPtr->valueFormat, dvalue); /* * No check for error return here as well, because any possible @@ -3529,11 +3537,11 @@ ExpandPercents( number = -1; break; } - 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 */ @@ -4400,7 +4408,7 @@ SpinboxInvoke( dvalue = sbPtr->toValue; } } - sprintf(sbPtr->formatBuf, sbPtr->valueFormat, dvalue); + snprintf(sbPtr->formatBuf, sizeof(sbPtr->formatBuf), sbPtr->valueFormat, dvalue); code = EntryValueChanged(entryPtr, sbPtr->formatBuf); } } @@ -4517,9 +4525,9 @@ ComputeFormat( fDigits++; /* Zero to left of decimal point. */ } if (fDigits <= eDigits) { - sprintf(sbPtr->digitFormat, "%%.%df", afterDecimal); + snprintf(sbPtr->digitFormat, sizeof(sbPtr->digitFormat), "%%.%df", afterDecimal); } else { - sprintf(sbPtr->digitFormat, "%%.%de", numDigits-1); + snprintf(sbPtr->digitFormat, sizeof(sbPtr->digitFormat), "%%.%de", numDigits-1); } sbPtr->valueFormat = sbPtr->digitFormat; return TCL_OK; diff --git a/generic/tkEntry.h b/generic/tkEntry.h index 6b1bf87..8d863cf 100644 --- a/generic/tkEntry.h +++ b/generic/tkEntry.h @@ -217,11 +217,11 @@ typedef struct { * multiple of this value. */ char *formatBuf; /* string into which to format value. * Malloc'ed. */ - char *reqFormat; /* Sprintf conversion specifier used for the + char *reqFormat; /* Snprintf conversion specifier used for the * value that the users requests. Malloc'ed */ - char *valueFormat; /* Sprintf conversion specifier used for the + char *valueFormat; /* Snprintf conversion specifier used for the * value. */ - char digitFormat[16]; /* Sprintf conversion specifier computed from + char digitFormat[16]; /* Snprintf conversion specifier computed from * digits and other information; used for the * value. */ diff --git a/generic/tkFont.c b/generic/tkFont.c index 8138c34..873ec43 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -17,6 +17,14 @@ #include "tkMacOSXInt.h" /* Defines TK_DRAW_IN_CONTEXT */ #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 + /* * The following structure is used to keep track of all the fonts that exist * in the current application. It must be stored in the TkMainInfo for the @@ -660,7 +668,7 @@ Tk_FontObjCmd( */ for (i = 1; ; i++) { - sprintf(buf, "font%d", i); + snprintf(buf, sizeof(buf), "font%d", i); namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, buf); if (namedHashPtr == NULL) { break; @@ -3328,7 +3336,7 @@ Tk_TextLayoutToPostscript( p += TkUtfToUniChar(p, &ch); if ((ch == '(') || (ch == ')') || (ch == '\\') || (ch < 0x20)) { /* - * Tricky point: the "03" is necessary in the sprintf below, + * Tricky point: the "03" is necessary in the snprintf below, * so that a full three digits of octal are always generated. * Without the "03", a number following this sequence could be * interpreted by Postscript as part of this sequence. @@ -3354,7 +3362,7 @@ Tk_TextLayoutToPostscript( if (ch > 0xffff) { goto noMapping; } - sprintf(uindex, "%04X", ch); /* endianness? */ + snprintf(uindex, sizeof(uindex), "%04X", ch); /* endianness? */ glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0); if (glyphname) { ps = Tcl_GetStringFromObj(psObj, &len); diff --git a/generic/tkImage.c b/generic/tkImage.c index d42ed7d..54a0fe1 100644 --- a/generic/tkImage.c +++ b/generic/tkImage.c @@ -13,6 +13,14 @@ #include "tkInt.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 + /* * Each call to Tk_GetImage returns a pointer to one of the following * structures, which is used as a token by clients (widgets) that display @@ -285,7 +293,7 @@ Tk_ImageObjCmd( if ((objc == 3) || (*(arg = Tcl_GetString(objv[3])) == '-')) { do { dispPtr->imageId++; - sprintf(idString, "image%d", dispPtr->imageId); + snprintf(idString, sizeof(idString), "image%d", dispPtr->imageId); name = idString; } while (Tcl_FindCommand(interp, name, NULL, 0) != NULL); firstOption = 3; diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c index a53213e..54fe5cf 100644 --- a/generic/tkImgPPM.c +++ b/generic/tkImgPPM.c @@ -16,6 +16,14 @@ #include "tkInt.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 + /* * The maximum amount of memory to allocate for data read from the file. If we * need more than this, we do it in pieces. @@ -305,7 +313,7 @@ FileWritePPM( return TCL_ERROR; } - sprintf(header, "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height); + snprintf(header, sizeof(header), "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height); Tcl_Write(chan, header, -1); pixLinePtr = blockPtr->pixelPtr + blockPtr->offset[0]; @@ -376,7 +384,7 @@ StringWritePPM( char header[16 + TCL_INTEGER_SPACE * 2]; Tcl_Obj *byteArrayObj; - sprintf(header, "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height); + snprintf(header, sizeof(header), "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height); /* * Construct a byte array of the right size with the header and diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index 37ee3d9..4fe7436 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -21,6 +21,14 @@ #include "tkImgPhoto.h" #include "tkPort.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 + /* * Declaration for internal Xlib function used here: */ @@ -339,9 +347,9 @@ TkImgPhotoGet( XFree((char *) visInfoPtr); if (mono) { - sprintf(buf, "%d", nRed); + snprintf(buf, sizeof(buf), "%d", nRed); } else { - sprintf(buf, "%d/%d/%d", nRed, nGreen, nBlue); + snprintf(buf, sizeof(buf), "%d/%d/%d", nRed, nGreen, nBlue); } instancePtr->defaultPalette = Tk_GetUid(buf); diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index 7854246..7711e2b 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.c @@ -14,6 +14,14 @@ #include "tkInt.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 + /* * Forward declarations for functions defined later in this file: */ @@ -773,7 +781,7 @@ FormatConfigValue( } break; case TK_CONFIG_INT: - sprintf(buffer, "%d", *((int *)ptr)); + snprintf(buffer, sizeof(buffer), "%d", *((int *)ptr)); result = buffer; break; case TK_CONFIG_DOUBLE: @@ -851,7 +859,7 @@ FormatConfigValue( result = Tk_NameOfJoinStyle(*((int *)ptr)); break; case TK_CONFIG_PIXELS: - sprintf(buffer, "%d", *((int *)ptr)); + snprintf(buffer, sizeof(buffer),"%d", *((int *)ptr)); result = buffer; break; case TK_CONFIG_MM: diff --git a/generic/tkOldTest.c b/generic/tkOldTest.c index 8996f31..9662e26 100644 --- a/generic/tkOldTest.c +++ b/generic/tkOldTest.c @@ -24,6 +24,14 @@ #endif #include "tkInt.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 + /* * The following data structure represents the model for a test image: */ @@ -267,7 +275,7 @@ ImageGet( char buffer[100]; XGCValues gcValues; - sprintf(buffer, "%s get", timPtr->imageName); + snprintf(buffer, sizeof(buffer), "%s get", timPtr->imageName); Tcl_SetVar2(timPtr->interp, timPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); @@ -312,7 +320,7 @@ ImageDisplay( TImageInstance *instPtr = clientData; char buffer[200 + TCL_INTEGER_SPACE * 6]; - sprintf(buffer, "%s display %d %d %d %d %d %d", + snprintf(buffer, sizeof(buffer), "%s display %d %d %d %d %d %d", instPtr->modelPtr->imageName, imageX, imageY, width, height, drawableX, drawableY); Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName, NULL, @@ -357,7 +365,7 @@ ImageFree( TImageInstance *instPtr = clientData; char buffer[200]; - sprintf(buffer, "%s free", instPtr->modelPtr->imageName); + snprintf(buffer, sizeof(buffer), "%s free", instPtr->modelPtr->imageName); Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); Tk_FreeColor(instPtr->fg); @@ -391,7 +399,7 @@ ImageDelete( TImageModel *timPtr = clientData; char buffer[100]; - sprintf(buffer, "%s delete", timPtr->imageName); + snprintf(buffer, sizeof(buffer), "%s delete", timPtr->imageName); Tcl_SetVar2(timPtr->interp, timPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); diff --git a/generic/tkScale.c b/generic/tkScale.c index 79cfecb..7026821 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -21,10 +21,15 @@ #include "tkInt.h" #include "tkScale.h" -#if defined(_WIN32) -#define snprintf _snprintf +#ifdef _MSC_VER +/* + * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. + * Note that sprintf is deprecated. + */ +# define snprintf _snprintf #endif + /* * The following table defines the legal values for the -orient option. It is * used together with the "enum orient" declaration in tkScale.h. @@ -974,15 +979,15 @@ ComputeFormat( if (forTicks) { if (fDigits <= eDigits) { - sprintf(scalePtr->tickFormat, "%%.%df", afterDecimal); + snprintf(scalePtr->tickFormat, sizeof(scalePtr->tickFormat), "%%.%df", afterDecimal); } else { - sprintf(scalePtr->tickFormat, "%%.%de", numDigits - 1); + snprintf(scalePtr->tickFormat, sizeof(scalePtr->tickFormat), "%%.%de", numDigits - 1); } } else { if (fDigits <= eDigits) { - sprintf(scalePtr->valueFormat, "%%.%df", afterDecimal); + snprintf(scalePtr->valueFormat, sizeof(scalePtr->valueFormat), "%%.%df", afterDecimal); } else { - sprintf(scalePtr->valueFormat, "%%.%de", numDigits - 1); + snprintf(scalePtr->valueFormat, sizeof(scalePtr->valueFormat), "%%.%de", numDigits - 1); } } } diff --git a/generic/tkScale.h b/generic/tkScale.h index e68b786..2ce2190 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -73,9 +73,9 @@ typedef struct TkScale { * values. 0 means we get to choose the number * based on resolution and/or the range of the * scale. */ - char valueFormat[16]; /* Sprintf conversion specifier computed from + char valueFormat[16]; /* Snprintf conversion specifier computed from * digits and other information. */ - char tickFormat[16]; /* Sprintf conversion specifier computed from + char tickFormat[16]; /* Snprintf conversion specifier computed from * tick interval. */ double bigIncrement; /* Amount to use for large increments to scale * value. (0 means we pick a value). */ diff --git a/generic/tkSelect.c b/generic/tkSelect.c index ef636da..fae72c6 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -14,6 +14,14 @@ #include "tkInt.h" #include "tkSelect.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 + /* * When a selection handler is set up by invoking "selection handle", one of * the following data structures is set up to hold information about the @@ -1476,7 +1484,7 @@ TkSelDefaultSelection( if (maxBytes < 20) { return -1; } - sprintf(buffer, "0x%x", (unsigned int) infoPtr->time); + snprintf(buffer, sizeof(buffer), "0x%x", (unsigned int) infoPtr->time); *typePtr = XA_INTEGER; return strlen(buffer); } diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 8d3588a..23397db 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -151,7 +151,7 @@ TkpPrintWindowId( * the hex representation of a pointer. */ Window window) /* Window to be printed into buffer. */ { - sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)window); + snprintf(buf, sizeof(buf), "0x%" TCL_Z_MODIFIER "x", (size_t)window); } int diff --git a/generic/tkTest.c b/generic/tkTest.c index b652068..75dec6c 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -28,6 +28,14 @@ #include "tkWinInt.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 + #if defined(MAC_OSX_TK) #include "tkMacOSXInt.h" #include "tkScrollbar.h" @@ -1505,7 +1513,7 @@ ImageGet( char buffer[100]; XGCValues gcValues; - sprintf(buffer, "%s get", timPtr->imageName); + snprintf(buffer, sizeof(buffer), "%s get", timPtr->imageName); Tcl_SetVar2(timPtr->interp, timPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); @@ -1574,7 +1582,7 @@ ImageDisplay( * Log the message. */ - sprintf(instPtr->buffer, "%s display %d %d %d %d", + snprintf(instPtr->buffer, sizeof(instPtr->buffer), "%s display %d %d %d %d", instPtr->modelPtr->imageName, imageX, imageY, width, height); } Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName, @@ -1589,7 +1597,7 @@ ImageDisplay( */ if (instPtr->displayFailed == False) { - sprintf(instPtr->buffer, "%s display %d %d %d %d", + snprintf(instPtr->buffer, sizeof(instPtr->buffer), "%s display %d %d %d %d", instPtr->modelPtr->imageName, imageX, imageY, width, height); } instPtr->displayFailed = True; @@ -1635,7 +1643,7 @@ ImageFree( TImageInstance *instPtr = (TImageInstance *)clientData; char buffer[200]; - sprintf(buffer, "%s free", instPtr->modelPtr->imageName); + snprintf(buffer, sizeof(buffer), "%s free", instPtr->modelPtr->imageName); Tcl_SetVar2(instPtr->modelPtr->interp, instPtr->modelPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); Tk_FreeColor(instPtr->fg); @@ -1669,7 +1677,7 @@ ImageDelete( TImageModel *timPtr = (TImageModel *)clientData; char buffer[100]; - sprintf(buffer, "%s delete", timPtr->imageName); + snprintf(buffer, sizeof(buffer), "%s delete", timPtr->imageName); Tcl_SetVar2(timPtr->interp, timPtr->varName, NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); @@ -1828,7 +1836,7 @@ TestmetricsObjCmd( "\": must be cxhscroll or cyvscroll", NULL); return TCL_ERROR; } - sprintf(buf, "%d", val); + snprintf(buf, sizeof(buf), "%d", val); Tcl_AppendResult(interp, buf, NULL); return TCL_OK; } @@ -1899,7 +1907,7 @@ TestpropObjCmd( value = 0xff & *p; p += 1; } - sprintf(buffer, "0x%lx", value); + snprintf(buffer, sizeof(buffer), "0x%lx", value); Tcl_AppendElement(interp, buffer); } } diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index cf1cb1b..3c2c799 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -29,6 +29,14 @@ #define OK_TO_LOG 1 #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 + /* * "Calculations of line pixel heights and the size of the vertical * scrollbar." @@ -3064,7 +3072,7 @@ AsyncUpdateLineMetrics( if (tkTextDebug) { char buffer[2 * TCL_INTEGER_SPACE + 1]; - sprintf(buffer, "%d %d", lineNum, dInfoPtr->lastMetricUpdateLine); + snprintf(buffer, sizeof(buffer), "%d %d", lineNum, dInfoPtr->lastMetricUpdateLine); LOG("tk_textInvalidateLine", buffer); } @@ -3271,7 +3279,7 @@ TkTextUpdateLineMetrics( if (tkTextDebug) { char buffer[4 * TCL_INTEGER_SPACE + 3]; - sprintf(buffer, "%d %d %d %d", + snprintf(buffer, sizeof(buffer), "%d %d %d %d", lineNum, endLine, totalLines, count); LOG("tk_textInvalidateLine", buffer); } @@ -4141,7 +4149,7 @@ TkTextUpdateOneLine( Tcl_Panic("Mustn't ever update line height of last artificial line"); } - sprintf(buffer, "%d %d", TkBTreeLinesTo(textPtr,linePtr), pixelHeight); + snprintf(buffer, sizeof(buffer), "%d %d", TkBTreeLinesTo(textPtr,linePtr), pixelHeight); LOG("tk_textNumPixels", buffer); } if (textPtr->dInfoPtr->scrollbarTimer == NULL) { diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c index 776eb04..feff1ec 100644 --- a/generic/tkTextImage.c +++ b/generic/tkTextImage.c @@ -13,6 +13,14 @@ #include "tkPort.h" #include "tkText.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 + /* * Macro that determines the size of an embedded image segment: */ @@ -410,7 +418,7 @@ EmbImageConfigure( if (conflict) { char buf[4 + TCL_INTEGER_SPACE]; - sprintf(buf, "#%d", count+1); + snprintf(buf, sizeof(buf), "#%d", count+1); Tcl_DStringAppend(&newName, buf, -1); } name = Tcl_DStringValue(&newName); diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index e6632d0..7417e7f 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -15,6 +15,14 @@ #include "tkText.h" #include "default.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 + /* * Index to use to select last character in line (very large integer): */ @@ -1128,7 +1136,7 @@ TkTextPrintIndex( charIndex += numBytes; } - return sprintf(string, "%d.%d", + return snprintf(string, sizeof(string), "%d.%d", TkBTreeLinesTo(textPtr, indexPtr->linePtr) + 1, charIndex); } diff --git a/generic/tkUtil.c b/generic/tkUtil.c index 3cc8dbf..63bbc0e 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -13,6 +13,14 @@ #include "tkInt.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 + /* * The structure below defines the implementation of the "statekey" Tcl * object, used for quickly finding a mapping in a TkStateMap. @@ -423,7 +431,7 @@ TkOffsetPrintProc( return "end"; } p = (char *)ckalloc(32); - sprintf(p, "%d", offsetPtr->flags & ~TK_OFFSET_INDEX); + snprintf(p, sizeof(p), "%d", offsetPtr->flags & ~TK_OFFSET_INDEX); *freeProcPtr = TCL_DYNAMIC; return p; } @@ -456,7 +464,7 @@ TkOffsetPrintProc( if (offsetPtr->flags & TK_OFFSET_RELATIVE) { *q++ = '#'; } - sprintf(q, "%d,%d", offsetPtr->xoffset, offsetPtr->yoffset); + snprintf(q, sizeof(q), "%d,%d", offsetPtr->xoffset, offsetPtr->yoffset); *freeProcPtr = TCL_DYNAMIC; return p; } 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); } diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index 2f04e74..9a03178 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -596,7 +596,7 @@ TkpTestembedCmd( if (containerPtr->parent == None) { Tcl_DStringAppendElement(&dString, ""); } else if (all) { - sprintf(buffer, "0x%lx", containerPtr->parent); + snprintf(buffer, sizeof(buffer), "0x%lx", containerPtr->parent); Tcl_DStringAppendElement(&dString, buffer); } else { Tcl_DStringAppendElement(&dString, "XXX"); diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index 5055f38..3b87fbe 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -272,14 +272,14 @@ static const char *scriptTextProc = "::tk::mac::DoScriptText"; err = AEGetParamPtr(theDesc, keyDirectObject, typeWildCard, &initialType, NULL, 0, NULL); if (err != noErr) { - sprintf(errString, "AEDoScriptHandler: GetParamDesc error %d", (int)err); + snprintf(errString, sizeof(errString), "AEDoScriptHandler: GetParamDesc error %d", (int)err); AEPutParamPtr((AppleEvent*)[replyEvent aeDesc], keyErrorString, typeChar, errString, strlen(errString)); return; } if (MissedAnyParameters((AppleEvent*)theDesc)) { - sprintf(errString, "AEDoScriptHandler: extra parameters"); + snprintf(errString, sizeof(errString), "AEDoScriptHandler: extra parameters"); AEPutParamPtr((AppleEvent*)[replyEvent aeDesc], keyErrorString, typeChar,errString, strlen(errString)); return; diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h index ab843f9..b5aa459 100644 --- a/macosx/tkMacOSXPort.h +++ b/macosx/tkMacOSXPort.h @@ -162,7 +162,7 @@ */ #define TkpPrintWindowId(buf,w) \ - sprintf((buf), "0x%lx", (unsigned long) (w)) + snprintf((buf), sizeof(buf), "0x%lx", (unsigned long) (w)) /* * Turn off Tk double-buffering as Aqua windows are already double-buffered. diff --git a/macosx/tkMacOSXSend.c b/macosx/tkMacOSXSend.c index a651bcd..ee5d97f 100644 --- a/macosx/tkMacOSXSend.c +++ b/macosx/tkMacOSXSend.c @@ -267,7 +267,7 @@ Tk_SetAppName( actualName = Tcl_DStringValue(&dString); } suffix++; - sprintf(Tcl_DStringValue(&dString) + offset, "%d", suffix); + snprintf(Tcl_DStringValue(&dString) + offset, sizeof(Tcl_DStringValue(&dString)) - offset, "%d", suffix); i = 0; } else { i++; diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 3fd8af7..a13455b 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -2074,7 +2074,7 @@ WmFrameCmd( if (window == None) { window = Tk_WindowId((Tk_Window)winPtr); } - sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)window); + snprintf(buf, sizeof(buf), "0x%" TCL_Z_MODIFIER "x", (size_t)window); Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); return TCL_OK; } diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c index ff7860b..f6378ad 100644 --- a/unix/tkUnixEmbed.c +++ b/unix/tkUnixEmbed.c @@ -907,7 +907,7 @@ TkpTestembedCmd( if (containerPtr->parent == None) { Tcl_DStringAppendElement(&dString, ""); } else if (all) { - sprintf(buffer, "0x%lx", containerPtr->parent); + snprintf(buffer, sizeof(buffer), "0x%lx", containerPtr->parent); Tcl_DStringAppendElement(&dString, buffer); } else { Tcl_DStringAppendElement(&dString, "XXX"); @@ -924,7 +924,7 @@ TkpTestembedCmd( if (containerPtr->wrapper == None) { Tcl_DStringAppendElement(&dString, ""); } else if (all) { - sprintf(buffer, "0x%lx", containerPtr->wrapper); + snprintf(buffer, sizeof(buffer), "0x%lx", containerPtr->wrapper); Tcl_DStringAppendElement(&dString, buffer); } else { Tcl_DStringAppendElement(&dString, "XXX"); diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 665b260..1a14d98 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -2802,7 +2802,7 @@ GetScreenFont( rest = strchr(rest + 1, '-'); } *str = '\0'; - sprintf(buf, "%.200s-%d-*-*-*-*-*%s", nameList[bestIdx[1]], + snprintf(buf, sizeof(buf), "%.200s-%d-*-*-*-*-*%s", nameList[bestIdx[1]], (int)(-wantPtr->fa.size+0.5), rest); *str = '-'; fontStructPtr = XLoadQueryFont(display, buf); @@ -2940,7 +2940,7 @@ ListFonts( { char buf[256]; - sprintf(buf, "-*-%.80s-*-*-*-*-*-*-*-*-*-*-*-*", faceName); + snprintf(buf, sizeof(buf), "-*-%.80s-*-*-*-*-*-*-*-*-*-*-*-*", faceName); return XListFonts(display, buf, 10000, numNamesPtr); } diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h index 156eb04..7f764a4 100644 --- a/unix/tkUnixPort.h +++ b/unix/tkUnixPort.h @@ -191,7 +191,7 @@ #ifndef __CYGWIN__ #define TkpPrintWindowId(buf,w) \ - sprintf((buf), "0x%08lx", (unsigned long) (w)) + snprintf((buf), sizeof(buf), "0x%08lx", (unsigned long) (w)) #endif #endif /* _UNIXPORT */ diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c index 527bc4c..aec6c31 100644 --- a/unix/tkUnixSelect.c +++ b/unix/tkUnixSelect.c @@ -1511,7 +1511,7 @@ SelCvtFromX32( } else { char buf[12]; - sprintf(buf, "0x%x", (unsigned int) *propPtr); + snprintf(buf, sizeof(buf), "0x%x", (unsigned int) *propPtr); Tcl_DStringAppendElement(dsPtr, buf); } } @@ -1537,7 +1537,7 @@ SelCvtFromX8( for ( ; numValues > 0; propPtr++, numValues--) { char buf[12]; - sprintf(buf, "0x%x", (unsigned char) *propPtr); + snprintf(buf, sizeof(buf), "0x%x", (unsigned char) *propPtr); Tcl_DStringAppendElement(dsPtr, buf); } Tcl_DStringAppend(dsPtr, " ", 1); diff --git a/unix/tkUnixSend.c b/unix/tkUnixSend.c index 03d124f..523f178 100644 --- a/unix/tkUnixSend.c +++ b/unix/tkUnixSend.c @@ -476,7 +476,7 @@ RegAddName( char id[30], *newProp; int idLength, newBytes; - sprintf(id, "%x ", (unsigned) commWindow); + snprintf(id, sizeof(id), "%x ", (unsigned) commWindow); idLength = strlen(id); newBytes = idLength + strlen(name) + 1; newProp = (char *)ckalloc(regPtr->propLength + newBytes); @@ -875,7 +875,7 @@ Tk_SetAppName( Tcl_DStringSetLength(&dString, offset+TCL_INTEGER_SPACE); actualName = Tcl_DStringValue(&dString); } - sprintf(Tcl_DStringValue(&dString) + offset, "%d", i); + snprintf(Tcl_DStringValue(&dString) + offset, sizeof(Tcl_DStringValue(&dString)) - offset, "%d", i); } w = RegFindName(regPtr, actualName); if (w == None) { @@ -1096,7 +1096,7 @@ Tk_SendObjCmd( if (!async) { char buffer[TCL_INTEGER_SPACE * 2]; - sprintf(buffer, "%x %d", + snprintf(buffer, sizeof(buffer), "%x %d", (unsigned) Tk_WindowId(dispPtr->commTkwin), localData.sendSerial); Tcl_DStringAppend(&request, "\0-r ", 4); @@ -1620,7 +1620,7 @@ SendEventProc( if (result != TCL_OK) { char buffer[TCL_INTEGER_SPACE]; - sprintf(buffer, "%d", result); + snprintf(buffer, sizeof(buffer), "%d", result); Tcl_DStringAppend(&reply, "\0-c ", 4); Tcl_DStringAppend(&reply, buffer, -1); } @@ -1796,7 +1796,7 @@ AppendErrorProc( pcPtr = pcPtr->nextPtr) { if ((pcPtr == pendingPtr) && (pcPtr->result == NULL)) { pcPtr->result = (char *)ckalloc(strlen(pcPtr->target) + 50); - sprintf(pcPtr->result, "no application named \"%s\"", + snprintf(pcPtr->result, sizeof(pcPtr->result), "no application named \"%s\"", pcPtr->target); pcPtr->code = TCL_ERROR; pcPtr->gotResponse = 1; diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 8330098..46beecf 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -1879,7 +1879,7 @@ WmFrameCmd( if (window == None) { window = Tk_WindowId((Tk_Window) winPtr); } - sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)window); + snprintf(buf, sizeof(buf), "0x%" TCL_Z_MODIFIER "x", (size_t)window); Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); return TCL_OK; } diff --git a/win/tkWinButton.c b/win/tkWinButton.c index 4e965c2..ebf0ec6 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -14,6 +14,14 @@ #include "tkWinInt.h" #include "tkButton.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 + /* * These macros define the base style flags for the different button types. */ @@ -186,7 +194,7 @@ TkpButtonSetDefaults(void) { int width = GetSystemMetrics(SM_CXEDGE); if (width > 0) { - sprintf(tkDefButtonBorderWidth, "%d", width); + snprintf(tkDefButtonBorderWidth, sizeof(tkDefButtonBorderWidth), "%d", width); } } diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index cb765bb..4ac8c12 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -25,6 +25,14 @@ # pragma comment (lib, "uuid.lib") #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 + /* These needed for compilation with VC++ 5.2 */ /* XXX - remove these since need at least VC 6 */ #ifndef BIF_EDITBOX @@ -3027,7 +3035,7 @@ SetTkDialog( Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); char buf[32]; - sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)clientData); + snprintf(buf, sizeof(buf), "0x%" TCL_Z_MODIFIER "x", (size_t)clientData); Tcl_SetVar2(tsdPtr->debugInterp, "tk_dialog", NULL, buf, TCL_GLOBAL_ONLY); } diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 1d2af7e..4728e3e 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -15,6 +15,14 @@ #include "tkWinInt.h" #include "tkMenu.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 + /* * The class of the window for popup menus. */ @@ -3440,7 +3448,7 @@ SetDefaults( DeleteObject(menuFont); Tcl_DStringAppendElement(&menuFontDString, faceName); - sprintf(sizeString, "%d", pointSize); + snprintf(sizeString, sizeof(sizeString), "%d", pointSize); Tcl_DStringAppendElement(&menuFontDString, sizeString); if (bold || italic) { diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c index 409a6db..76c8419 100644 --- a/win/tkWinScrlbr.c +++ b/win/tkWinScrlbr.c @@ -13,6 +13,14 @@ #include "tkWinInt.h" #include "tkScrollbar.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 + /* * The following constant is used to specify the maximum scroll position. This * value is limited by the Win32 API to either 16-bits or 32-bits, depending @@ -360,7 +368,7 @@ UpdateScrollbarMetrics(void) vArrowHeight = GetSystemMetrics(SM_CYVSCROLL); vThumb = GetSystemMetrics(SM_CYVTHUMB); - sprintf(tkDefScrollbarWidth, "%d", arrowWidth); + snprintf(tkDefScrollbarWidth, sizeof(tkDefScrollbarWidth), "%d", arrowWidth); } /* diff --git a/win/tkWinSend.c b/win/tkWinSend.c index d1d6777..7da614c 100644 --- a/win/tkWinSend.c +++ b/win/tkWinSend.c @@ -14,6 +14,14 @@ #include "tkInt.h" #include "tkWinSendCom.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 + /* * Should be defined in WTypes.h but mingw 1.0 is missing them. */ @@ -683,7 +691,7 @@ RegisterInterp( Tcl_DStringSetLength(&dString, offset+TCL_INTEGER_SPACE); actualName = Tcl_DStringValue(&dString); } - sprintf(Tcl_DStringValue(&dString) + offset, "%d", i); + snprintf(Tcl_DStringValue(&dString) + offset, sizeof(Tcl_DStringValue(&dString)) - offset, "%d", i); } hr = BuildMoniker(actualName, &pmk); diff --git a/win/tkWinTest.c b/win/tkWinTest.c index 8a292b3..d1bb00c 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -18,6 +18,14 @@ #define USE_TK_STUBS #include "tkWinInt.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 + HWND tkWinCurrentDialog; /* @@ -171,7 +179,7 @@ AppendSystemError( if (error == ERROR_CALL_NOT_IMPLEMENTED) { strcpy(msgBuf, "function not supported under Win32s"); } else { - sprintf(msgBuf, "unknown error: %ld", error); + snprintf(msgBuf, sizeof(msgBuf), "unknown error: %ld", error); } msg = msgBuf; } else { @@ -198,7 +206,7 @@ AppendSystemError( msg = msgPtr; } - sprintf(id, "%ld", error); + snprintf(id, sizeof(id), "%ld", error); Tcl_SetErrorCode(interp, "WINDOWS", id, msg, NULL); Tcl_AppendToObj(resultPtr, msg, length); Tcl_SetObjResult(interp, resultPtr); @@ -402,14 +410,14 @@ TestwineventObjCmd( wParam = MAKEWPARAM(id, 0); lParam = (LPARAM)child; } - sprintf(buf, "%d", (int) SendMessageA(hwnd, message, wParam, lParam)); + snprintf(buf, sizeof(buf), "%d", (int) SendMessageA(hwnd, message, wParam, lParam)); Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); break; } default: { char buf[TCL_INTEGER_SPACE]; - sprintf(buf, "%d", + snprintf(buf, sizeof(buf), "%d", (int) SendDlgItemMessageA(hwnd, id, message, wParam, lParam)); Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); break; diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index 3478b08..c47504d 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -13,6 +13,14 @@ #include "tkWinInt.h" #include "tkBusy.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 + typedef struct { int initialized; /* 0 means table below needs initializing. */ Tcl_HashTable windowTable; /* The windowTable maps from HWND to Tk_Window diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 7b2b0cf..c5b7e71 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -16,6 +16,14 @@ #include "tkWinInt.h" #include +#ifdef _MSC_VER +/* + * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. + * Note that sprintf is deprecated. + */ +# define snprintf _snprintf +#endif + /* * These next two defines are only valid on Win2K/XP+. */ @@ -3723,7 +3731,7 @@ WmFrameCmd( if (hwnd == NULL) { hwnd = Tk_GetHWND(Tk_WindowId((Tk_Window) winPtr)); } - sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)hwnd); + snprintf(buf, sizeof(buf), "0x%" TCL_Z_MODIFIER "x", (size_t)hwnd); Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); return TCL_OK; } diff --git a/win/tkWinX.c b/win/tkWinX.c index 1a9bc2a..482a660 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -14,6 +14,14 @@ #define XLIB_ILLEGAL_ACCESS #include "tkWinInt.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 + /* * The w32api 1.1 package (included in Mingw 1.1) does not define _WIN32_IE by * default. Define it here to gain access to the InitCommonControlsEx API in @@ -146,7 +154,7 @@ TkGetServerInfo( GetVersionExW(&os); } /* Write the first character last, preventing multi-thread issues. */ - sprintf(buffer+1, "indows %d.%d %d %s", (int)os.dwMajorVersion, + snprintf(buffer+1, sizeof(buffer)-1, "indows %d.%d %d %s", (int)os.dwMajorVersion, (int)os.dwMinorVersion, (int)os.dwBuildNumber, #ifdef _WIN64 "Win64" @@ -1533,7 +1541,7 @@ UpdateInputLanguage( if (charsetInfo.ciACP == CP_UTF8) { strcpy(codepage, "utf-8"); } else { - sprintf(codepage, "cp%d", charsetInfo.ciACP); + snprintf(codepage, sizeof(codepage), "cp%d", charsetInfo.ciACP); } if ((encoding = Tcl_GetEncoding(NULL, codepage)) == NULL) { -- cgit v0.12 From 12c0146aaec25379a108581c8582dd79eedcc066 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 11 Jan 2023 23:33:22 +0000 Subject: The last missing change sprintf --> snprintf. --- win/tkWinWindow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index c47504d..872ac40 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -178,7 +178,7 @@ TkpPrintWindowId( { HWND hwnd = (window) ? Tk_GetHWND(window) : 0; - sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)hwnd); + snprintf(buf, TCL_INTEGER_SPACE, "0x%" TCL_Z_MODIFIER "x", (size_t)hwnd); } /* -- cgit v0.12 From 91c03f8f7b13c7f0c997749c6808cd01db9807a3 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 12 Jan 2023 00:04:55 +0000 Subject: =?UTF-8?q?Provide=20explicit=20size=20in=20snprintf=20when=20need?= =?UTF-8?q?ed.=20Fix=20gcc=20warning:=20'argument=20to=20=E2=80=98sizeof?= =?UTF-8?q?=E2=80=99=20in=20=E2=80=98snprintf=E2=80=99=20call=20is=20the?= =?UTF-8?q?=20same=20expression=20as=20the=20destination;=20did=20you=20me?= =?UTF-8?q?an=20to=20provide=20an=20explicit=20length=3F=20[-Wsizeof-point?= =?UTF-8?q?er-memaccess]'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generic/tkBusy.c | 2 +- generic/tkCanvLine.c | 2 +- generic/tkCanvUtil.c | 4 ++-- generic/tkConfig.c | 8 ++++---- generic/tkEntry.c | 7 ++++--- generic/tkOldConfig.c | 4 ++-- generic/tkSelect.c | 2 +- generic/tkStubInit.c | 2 +- generic/tkText.c | 2 +- generic/tkTextIndex.c | 2 +- generic/tkUtil.c | 4 ++-- macosx/tkMacOSXPort.h | 2 +- unix/tkUnixPort.h | 2 +- unix/tkUnixSend.c | 2 +- 14 files changed, 23 insertions(+), 22 deletions(-) diff --git a/generic/tkBusy.c b/generic/tkBusy.c index ea3ac16..075b892 100644 --- a/generic/tkBusy.c +++ b/generic/tkBusy.c @@ -558,7 +558,7 @@ CreateBusy( tkChild = NextChild(tkChild)) { Tk_MakeWindowExist(tkChild); } - snprintf(name, sizeof(name), fmt, Tk_Name(tkRef)); + snprintf(name, length + 6, fmt, Tk_Name(tkRef)); tkBusy = Tk_CreateWindow(interp, tkParent, name, NULL); ckfree(name); diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c index cfa55f5..642d1c2 100644 --- a/generic/tkCanvLine.c +++ b/generic/tkCanvLine.c @@ -2083,7 +2083,7 @@ PrintArrowShape( LineItem *linePtr = (LineItem *) recordPtr; char *buffer = (char *)ckalloc(120); - snprintf(buffer, sizeof(buffer), "%.5g %.5g %.5g", linePtr->arrowShapeA, + snprintf(buffer, 120, "%.5g %.5g %.5g", linePtr->arrowShapeA, linePtr->arrowShapeB, linePtr->arrowShapeC); *freeProcPtr = TCL_DYNAMIC; return buffer; diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c index 9eedf6b..5e586ab 100644 --- a/generic/tkCanvUtil.c +++ b/generic/tkCanvUtil.c @@ -578,9 +578,9 @@ TkCanvasDashPrintProc( *freeProcPtr = TCL_DYNAMIC; p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array; - snprintf(buffer, sizeof(buffer), "%d", *p++ & 0xff); + snprintf(buffer, 4 * i, "%d", *p++ & 0xff); while (--i) { - snprintf(buffer+strlen(buffer), sizeof(buffer)-strlen(buffer), " %d", *p++ & 0xff); + snprintf(buffer + strlen(buffer), 4 * i - strlen(buffer), " %d", *p++ & 0xff); } return buffer; } diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 69f0fa6..1ff5c65 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -517,19 +517,19 @@ Tk_InitOptions( switch (source) { case OPTION_DATABASE: - snprintf(msg, sizeof(msg), "\n (database entry for \"%.50s\")", + snprintf(msg, 200, "\n (database entry for \"%.50s\")", optionPtr->specPtr->optionName); break; case SYSTEM_DEFAULT: - snprintf(msg, sizeof(msg), "\n (system default for \"%.50s\")", + snprintf(msg, 200, "\n (system default for \"%.50s\")", optionPtr->specPtr->optionName); break; case TABLE_DEFAULT: - snprintf(msg, sizeof(msg), "\n (default value for \"%.50s\")", + snprintf(msg, 200, "\n (default value for \"%.50s\")", optionPtr->specPtr->optionName); } if (tkwin != NULL) { - snprintf(msg + strlen(msg) - 1, sizeof(msg) - (strlen(msg) - 1), " in widget \"%.50s\")", + snprintf(msg + strlen(msg) - 1, 200 - (strlen(msg) - 1), " in widget \"%.50s\")", Tk_PathName(tkwin)); } Tcl_AddErrorInfo(interp, msg); diff --git a/generic/tkEntry.c b/generic/tkEntry.c index c0388a3..fc574a0 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -1113,6 +1113,7 @@ ConfigureEntry( double oldFrom = 0.0; /* lint initialization */ double oldTo = 0.0; /* lint initialization */ int code; + size_t formatSpace = TCL_DOUBLE_SPACE; /* * Eliminate any existing trace on a variable monitored by the entry. @@ -1201,7 +1202,7 @@ ConfigureEntry( */ int min, max; - size_t formatLen, formatSpace = TCL_DOUBLE_SPACE; + size_t formatLen; char fbuf[4], *fmt = sbPtr->reqFormat; formatLen = strlen(fmt); @@ -1378,7 +1379,7 @@ ConfigureEntry( } else if (dvalue < sbPtr->fromValue) { dvalue = sbPtr->fromValue; } - snprintf(sbPtr->formatBuf, sizeof(sbPtr->formatBuf), sbPtr->valueFormat, dvalue); + snprintf(sbPtr->formatBuf, formatSpace, sbPtr->valueFormat, dvalue); /* * No check for error return here as well, because any possible @@ -4408,7 +4409,7 @@ SpinboxInvoke( dvalue = sbPtr->toValue; } } - snprintf(sbPtr->formatBuf, sizeof(sbPtr->formatBuf), sbPtr->valueFormat, dvalue); + snprintf(sbPtr->formatBuf, TCL_DOUBLE_SPACE, sbPtr->valueFormat, dvalue); code = EntryValueChanged(entryPtr, sbPtr->formatBuf); } } diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index 7711e2b..5d8a042 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.c @@ -781,7 +781,7 @@ FormatConfigValue( } break; case TK_CONFIG_INT: - snprintf(buffer, sizeof(buffer), "%d", *((int *)ptr)); + snprintf(buffer, 200, "%d", *((int *)ptr)); result = buffer; break; case TK_CONFIG_DOUBLE: @@ -859,7 +859,7 @@ FormatConfigValue( result = Tk_NameOfJoinStyle(*((int *)ptr)); break; case TK_CONFIG_PIXELS: - snprintf(buffer, sizeof(buffer),"%d", *((int *)ptr)); + snprintf(buffer, 200, "%d", *((int *)ptr)); result = buffer; break; case TK_CONFIG_MM: diff --git a/generic/tkSelect.c b/generic/tkSelect.c index fae72c6..4a84e57 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -1484,7 +1484,7 @@ TkSelDefaultSelection( if (maxBytes < 20) { return -1; } - snprintf(buffer, sizeof(buffer), "0x%x", (unsigned int) infoPtr->time); + snprintf(buffer, maxBytes, "0x%x", (unsigned int) infoPtr->time); *typePtr = XA_INTEGER; return strlen(buffer); } diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 23397db..47742c1 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -151,7 +151,7 @@ TkpPrintWindowId( * the hex representation of a pointer. */ Window window) /* Window to be printed into buffer. */ { - snprintf(buf, sizeof(buf), "0x%" TCL_Z_MODIFIER "x", (size_t)window); + snprintf(buf, TCL_INTEGER_SPACE, "0x%" TCL_Z_MODIFIER "x", (size_t)window); } int diff --git a/generic/tkText.c b/generic/tkText.c index ea6c5fc..ce9bce7 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -6836,7 +6836,7 @@ TkpTesttextCmd( size_t len; int lineIndex, byteIndex, byteOffset; TkTextIndex index; - char buf[64]; + char buf[TK_POS_CHARS]; Tcl_CmdInfo info; if (objc < 3) { diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 7417e7f..c371530 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -1136,7 +1136,7 @@ TkTextPrintIndex( charIndex += numBytes; } - return snprintf(string, sizeof(string), "%d.%d", + return snprintf(string, TK_POS_CHARS, "%d.%d", TkBTreeLinesTo(textPtr, indexPtr->linePtr) + 1, charIndex); } diff --git a/generic/tkUtil.c b/generic/tkUtil.c index 63bbc0e..73a323b 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -431,7 +431,7 @@ TkOffsetPrintProc( return "end"; } p = (char *)ckalloc(32); - snprintf(p, sizeof(p), "%d", offsetPtr->flags & ~TK_OFFSET_INDEX); + snprintf(p, 32, "%d", offsetPtr->flags & ~TK_OFFSET_INDEX); *freeProcPtr = TCL_DYNAMIC; return p; } @@ -464,7 +464,7 @@ TkOffsetPrintProc( if (offsetPtr->flags & TK_OFFSET_RELATIVE) { *q++ = '#'; } - snprintf(q, sizeof(q), "%d,%d", offsetPtr->xoffset, offsetPtr->yoffset); + snprintf(q, 32, "%d,%d", offsetPtr->xoffset, offsetPtr->yoffset); *freeProcPtr = TCL_DYNAMIC; return p; } diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h index b5aa459..2a50663 100644 --- a/macosx/tkMacOSXPort.h +++ b/macosx/tkMacOSXPort.h @@ -162,7 +162,7 @@ */ #define TkpPrintWindowId(buf,w) \ - snprintf((buf), sizeof(buf), "0x%lx", (unsigned long) (w)) + snprintf((buf), TCL_INTEGER_SPACE, "0x%lx", (unsigned long) (w)) /* * Turn off Tk double-buffering as Aqua windows are already double-buffered. diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h index 7f764a4..8b6efce 100644 --- a/unix/tkUnixPort.h +++ b/unix/tkUnixPort.h @@ -191,7 +191,7 @@ #ifndef __CYGWIN__ #define TkpPrintWindowId(buf,w) \ - snprintf((buf), sizeof(buf), "0x%08lx", (unsigned long) (w)) + snprintf((buf), TCL_INTEGER_SPACE, "0x%08lx", (unsigned long) (w)) #endif #endif /* _UNIXPORT */ diff --git a/unix/tkUnixSend.c b/unix/tkUnixSend.c index 523f178..bd33576 100644 --- a/unix/tkUnixSend.c +++ b/unix/tkUnixSend.c @@ -1796,7 +1796,7 @@ AppendErrorProc( pcPtr = pcPtr->nextPtr) { if ((pcPtr == pendingPtr) && (pcPtr->result == NULL)) { pcPtr->result = (char *)ckalloc(strlen(pcPtr->target) + 50); - snprintf(pcPtr->result, sizeof(pcPtr->result), "no application named \"%s\"", + snprintf(pcPtr->result, strlen(pcPtr->target) + 50, "no application named \"%s\"", pcPtr->target); pcPtr->code = TCL_ERROR; pcPtr->gotResponse = 1; -- cgit v0.12 From 2d4a3f8ce9a84fd47a0b8586f5b2f62c282a3c95 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 12 Jan 2023 00:31:57 +0000 Subject: Fix mistake. --- macosx/tkMacOSXSend.c | 4 ++-- unix/tkUnixSend.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXSend.c b/macosx/tkMacOSXSend.c index ee5d97f..72c4bcf 100644 --- a/macosx/tkMacOSXSend.c +++ b/macosx/tkMacOSXSend.c @@ -263,11 +263,11 @@ Tk_SetAppName( Tcl_DStringAppend(&dString, name, -1); Tcl_DStringAppend(&dString, " #", 2); offset = Tcl_DStringLength(&dString); - Tcl_DStringSetLength(&dString, offset + 10); + Tcl_DStringSetLength(&dString, offset + TCL_INTEGER_SPACE); actualName = Tcl_DStringValue(&dString); } suffix++; - snprintf(Tcl_DStringValue(&dString) + offset, sizeof(Tcl_DStringValue(&dString)) - offset, "%d", suffix); + snprintf(Tcl_DStringValue(&dString) + offset, TCL_INTEGER_SPACE, "%d", suffix); i = 0; } else { i++; diff --git a/unix/tkUnixSend.c b/unix/tkUnixSend.c index bd33576..72b2b1e 100644 --- a/unix/tkUnixSend.c +++ b/unix/tkUnixSend.c @@ -875,7 +875,7 @@ Tk_SetAppName( Tcl_DStringSetLength(&dString, offset+TCL_INTEGER_SPACE); actualName = Tcl_DStringValue(&dString); } - snprintf(Tcl_DStringValue(&dString) + offset, sizeof(Tcl_DStringValue(&dString)) - offset, "%d", i); + snprintf(Tcl_DStringValue(&dString) + offset, TCL_INTEGER_SPACE, "%d", i); } w = RegFindName(regPtr, actualName); if (w == None) { -- cgit v0.12 From cdc8d2fa8d71e9a6f9e452006cc7b10acc9ab930 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 14 Jan 2023 11:10:28 +0000 Subject: Factorise definition of snprintf in tkWinInt.h (MSVC before 2015 didn't know snprintf). --- generic/tkBind.c | 8 -------- generic/tkBitmap.c | 12 ++++-------- generic/tkBusy.c | 8 ++------ generic/tkCanvLine.c | 8 ++------ generic/tkCanvUtil.c | 8 ++------ generic/tkCmds.c | 8 -------- generic/tkColor.c | 8 ++------ generic/tkConfig.c | 8 ++------ generic/tkCursor.c | 8 ++------ generic/tkEntry.c | 8 ++------ generic/tkFont.c | 8 ++------ generic/tkImage.c | 8 ++------ generic/tkImgPPM.c | 8 ++------ generic/tkImgPhInstance.c | 8 ++------ generic/tkOldConfig.c | 8 ++------ generic/tkOldTest.c | 8 ++------ generic/tkScale.c | 9 ++------- generic/tkSelect.c | 8 ++------ generic/tkTest.c | 8 -------- generic/tkTextDisp.c | 8 -------- generic/tkTextImage.c | 8 ++------ generic/tkTextIndex.c | 8 ++------ generic/tkUtil.c | 8 ++------ generic/ttk/ttkCache.c | 8 ++------ generic/ttk/ttkEntry.c | 8 ++------ generic/ttk/ttkTreeview.c | 8 ++------ win/tkWinButton.c | 8 -------- win/tkWinDialog.c | 8 -------- win/tkWinInt.h | 9 +++++++++ win/tkWinMenu.c | 8 -------- win/tkWinScrlbr.c | 8 -------- win/tkWinSend.c | 9 +-------- win/tkWinTest.c | 8 -------- win/tkWinWindow.c | 8 -------- win/tkWinWm.c | 8 -------- win/tkWinX.c | 8 -------- 36 files changed, 56 insertions(+), 239 deletions(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index 830e429..0cf887d 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -31,14 +31,6 @@ # define DEBUG(expr) expr #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 - #define SIZE_OF_ARRAY(arr) (sizeof(arr)/sizeof(arr[0])) /* diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c index 6e046c7..332e583 100644 --- a/generic/tkBitmap.c +++ b/generic/tkBitmap.c @@ -14,6 +14,10 @@ #include "tkInt.h" +#ifdef _WIN32 +#include "tkWinInt.h" +#endif + /* * The includes below are for pre-defined bitmaps. * @@ -42,14 +46,6 @@ #pragma warning (default : 4305) #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 - /* * One of the following data structures exists for each bitmap that is * currently in use. Each structure is indexed with both "idTable" and diff --git a/generic/tkBusy.c b/generic/tkBusy.c index 075b892..32db4fc 100644 --- a/generic/tkBusy.c +++ b/generic/tkBusy.c @@ -16,12 +16,8 @@ #include "tkBusy.h" #include "default.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c index 642d1c2..de46813 100644 --- a/generic/tkCanvLine.c +++ b/generic/tkCanvLine.c @@ -15,12 +15,8 @@ #include "tkCanvas.h" #include "default.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c index 5e586ab..310df53 100644 --- a/generic/tkCanvUtil.c +++ b/generic/tkCanvUtil.c @@ -13,12 +13,8 @@ #include "tkInt.h" #include "tkCanvas.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkCmds.c b/generic/tkCmds.c index 20e8c48..a642137 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -22,14 +22,6 @@ #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: */ diff --git a/generic/tkColor.c b/generic/tkColor.c index 3a097ed..bc4c30c 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -15,12 +15,8 @@ #include "tkInt.h" #include "tkColor.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 1ff5c65..9e4c875 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -26,12 +26,8 @@ #include "tkInt.h" #include "tkFont.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkCursor.c b/generic/tkCursor.c index 9f06843..50c6803 100644 --- a/generic/tkCursor.c +++ b/generic/tkCursor.c @@ -14,12 +14,8 @@ #include "tkInt.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkEntry.c b/generic/tkEntry.c index fc574a0..86b79ac 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -19,12 +19,8 @@ #include "default.h" #include "tkEntry.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkFont.c b/generic/tkFont.c index 873ec43..ea8cd20 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -17,12 +17,8 @@ #include "tkMacOSXInt.h" /* Defines TK_DRAW_IN_CONTEXT */ #endif -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkImage.c b/generic/tkImage.c index 54a0fe1..8cd5519 100644 --- a/generic/tkImage.c +++ b/generic/tkImage.c @@ -13,12 +13,8 @@ #include "tkInt.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c index 54fe5cf..fe76e36 100644 --- a/generic/tkImgPPM.c +++ b/generic/tkImgPPM.c @@ -16,12 +16,8 @@ #include "tkInt.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index 4fe7436..05fa40c 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -21,12 +21,8 @@ #include "tkImgPhoto.h" #include "tkPort.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index 5d8a042..fe27ef6 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.c @@ -14,12 +14,8 @@ #include "tkInt.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkOldTest.c b/generic/tkOldTest.c index 9662e26..1c0c575 100644 --- a/generic/tkOldTest.c +++ b/generic/tkOldTest.c @@ -24,12 +24,8 @@ #endif #include "tkInt.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkScale.c b/generic/tkScale.c index 7026821..2d6502d 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -21,15 +21,10 @@ #include "tkInt.h" #include "tkScale.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif - /* * The following table defines the legal values for the -orient option. It is * used together with the "enum orient" declaration in tkScale.h. diff --git a/generic/tkSelect.c b/generic/tkSelect.c index 4a84e57..1f0214e 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -14,12 +14,8 @@ #include "tkInt.h" #include "tkSelect.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkTest.c b/generic/tkTest.c index 75dec6c..96793df 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -28,14 +28,6 @@ #include "tkWinInt.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 - #if defined(MAC_OSX_TK) #include "tkMacOSXInt.h" #include "tkScrollbar.h" diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 3c2c799..b23c6f2 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -29,14 +29,6 @@ #define OK_TO_LOG 1 #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 - /* * "Calculations of line pixel heights and the size of the vertical * scrollbar." diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c index feff1ec..4f1b284 100644 --- a/generic/tkTextImage.c +++ b/generic/tkTextImage.c @@ -13,12 +13,8 @@ #include "tkPort.h" #include "tkText.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index c371530..cb7ba7b 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -15,12 +15,8 @@ #include "tkText.h" #include "default.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/tkUtil.c b/generic/tkUtil.c index 73a323b..a673b68 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -13,12 +13,8 @@ #include "tkInt.h" -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/ttk/ttkCache.c b/generic/ttk/ttkCache.c index 7b5ca01..f4d1846 100644 --- a/generic/ttk/ttkCache.c +++ b/generic/ttk/ttkCache.c @@ -31,12 +31,8 @@ #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 +#ifdef _WIN32 +#include "tkWinInt.h" #endif struct Ttk_ResourceCache_ { diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index fe684a7..85ec1da 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -12,12 +12,8 @@ #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 +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index e6267cf..717cbb5 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -8,12 +8,8 @@ #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 +#ifdef _WIN32 +#include "tkWinInt.h" #endif #define MAX(a,b) ((a) > (b) ? (a) : (b)) diff --git a/win/tkWinButton.c b/win/tkWinButton.c index ebf0ec6..98ed69e 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -14,14 +14,6 @@ #include "tkWinInt.h" #include "tkButton.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 - /* * These macros define the base style flags for the different button types. */ diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 4ac8c12..ef3a5fb 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -25,14 +25,6 @@ # pragma comment (lib, "uuid.lib") #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 - /* These needed for compilation with VC++ 5.2 */ /* XXX - remove these since need at least VC 6 */ #ifndef BIF_EDITBOX diff --git a/win/tkWinInt.h b/win/tkWinInt.h index ccc57db..5801076 100644 --- a/win/tkWinInt.h +++ b/win/tkWinInt.h @@ -242,4 +242,13 @@ MODULE_SCOPE Tcl_Obj * TkWin32ErrorObj(HRESULT hrError); #define GWLP_ID GWL_ID #endif /* !GWLP_WNDPROC */ +/* + * MSVC versions before 2015 don't know snprintf, but _snprintf is compatible. + * Note that sprintf is deprecated. + */ + +#ifdef _MSC_VER +# define snprintf _snprintf +#endif + #endif /* _TKWININT */ diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 4728e3e..7634147 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -15,14 +15,6 @@ #include "tkWinInt.h" #include "tkMenu.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 - /* * The class of the window for popup menus. */ diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c index 76c8419..4e1c733 100644 --- a/win/tkWinScrlbr.c +++ b/win/tkWinScrlbr.c @@ -13,14 +13,6 @@ #include "tkWinInt.h" #include "tkScrollbar.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 - /* * The following constant is used to specify the maximum scroll position. This * value is limited by the Win32 API to either 16-bits or 32-bits, depending diff --git a/win/tkWinSend.c b/win/tkWinSend.c index 7da614c..7d63cec 100644 --- a/win/tkWinSend.c +++ b/win/tkWinSend.c @@ -13,14 +13,7 @@ #include "tkInt.h" #include "tkWinSendCom.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 +#include "tkWinInt.h" /* * Should be defined in WTypes.h but mingw 1.0 is missing them. diff --git a/win/tkWinTest.c b/win/tkWinTest.c index d1bb00c..d4639d6 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -18,14 +18,6 @@ #define USE_TK_STUBS #include "tkWinInt.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 - HWND tkWinCurrentDialog; /* diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index 872ac40..01e43a6 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -13,14 +13,6 @@ #include "tkWinInt.h" #include "tkBusy.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 - typedef struct { int initialized; /* 0 means table below needs initializing. */ Tcl_HashTable windowTable; /* The windowTable maps from HWND to Tk_Window diff --git a/win/tkWinWm.c b/win/tkWinWm.c index c5b7e71..34ae154 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -16,14 +16,6 @@ #include "tkWinInt.h" #include -#ifdef _MSC_VER -/* - * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible. - * Note that sprintf is deprecated. - */ -# define snprintf _snprintf -#endif - /* * These next two defines are only valid on Win2K/XP+. */ diff --git a/win/tkWinX.c b/win/tkWinX.c index 482a660..e7720ae 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -14,14 +14,6 @@ #define XLIB_ILLEGAL_ACCESS #include "tkWinInt.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 - /* * The w32api 1.1 package (included in Mingw 1.1) does not define _WIN32_IE by * default. Define it here to gain access to the InitCommonControlsEx API in -- cgit v0.12 From 958e264af4de5a4217a417a03a5afad507132caf Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 15 Jan 2023 09:47:29 +0000 Subject: Really use snprintf (and not _snprintf) when MSVC is at least 2015. --- win/tkWinInt.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/win/tkWinInt.h b/win/tkWinInt.h index 5801076..98c1a35 100644 --- a/win/tkWinInt.h +++ b/win/tkWinInt.h @@ -246,9 +246,8 @@ MODULE_SCOPE Tcl_Obj * TkWin32ErrorObj(HRESULT hrError); * MSVC versions before 2015 don't know snprintf, but _snprintf is compatible. * Note that sprintf is deprecated. */ - -#ifdef _MSC_VER -# define snprintf _snprintf +#if defined(_MSC_VER) && _MSC_VER < 1900 +# define snprintf _snprintf #endif #endif /* _TKWININT */ -- cgit v0.12 From 45d6212d0a25f85b915bcd0de42c0526834acd46 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 15 Jan 2023 09:59:06 +0000 Subject: Factorise one more #define snprintf --- unix/tkUnixScale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/tkUnixScale.c b/unix/tkUnixScale.c index a603432..a83f5a1 100644 --- a/unix/tkUnixScale.c +++ b/unix/tkUnixScale.c @@ -13,8 +13,8 @@ #include "tkInt.h" #include "tkScale.h" -#if defined(_WIN32) -#define snprintf _snprintf +#ifdef _WIN32 +#include "tkWinInt.h" #endif /* -- cgit v0.12 From 6c1a90db870f006ca6baa57c8fc1be8d16eb5d55 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 15 Jan 2023 09:59:28 +0000 Subject: Fix error in comment. --- unix/tkUnixScale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/tkUnixScale.c b/unix/tkUnixScale.c index a83f5a1..c9a5efe 100644 --- a/unix/tkUnixScale.c +++ b/unix/tkUnixScale.c @@ -1,7 +1,7 @@ /* * tkUnixScale.c -- * - * This file implements the X specific portion of the scrollbar widget. + * This file implements the X specific portion of the scale widget. * * Copyright (c) 1996 by Sun Microsystems, Inc. * Copyright (c) 1998-2000 by Scriptics Corporation. -- cgit v0.12