diff options
author | fvogel <fvogelnew1@free.fr> | 2023-01-18 20:23:38 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2023-01-18 20:23:38 (GMT) |
commit | e1fdc1e995e1e01172159c960f7fe8d611cfaf64 (patch) | |
tree | 66f5ec6ffcc6e3d649cc3d98b77882fbe92807e6 /generic/tkEntry.c | |
parent | f413e249b3c0711dbefa5521ed2cc26c5bd20968 (diff) | |
parent | bc9027416eca9c0e52af3a412e4e012bc2495511 (diff) | |
download | tk-e1fdc1e995e1e01172159c960f7fe8d611cfaf64.zip tk-e1fdc1e995e1e01172159c960f7fe8d611cfaf64.tar.gz tk-e1fdc1e995e1e01172159c960f7fe8d611cfaf64.tar.bz2 |
Merge core-8-6-branch: Eradicate uses of sprintf because it triggers deprecation warning on macOS Ventura. Resolve conflicts. Remove sprintf calls specific to the main branch.
Diffstat (limited to 'generic/tkEntry.c')
-rw-r--r-- | generic/tkEntry.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 8b8e772..1ebce19 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -19,6 +19,10 @@ #include "tkEntry.h" #include "default.h" +#ifdef _WIN32 +#include "tkWinInt.h" +#endif + /* * The following macro defines how many extra pixels to leave on each side of * the text in the entry. @@ -1123,6 +1127,7 @@ ConfigureEntry( double oldFrom = 0.0; double oldTo = 0.0; int code; + size_t formatSpace = TCL_DOUBLE_SPACE; /* * Eliminate any existing trace on a variable monitored by the entry. @@ -1213,7 +1218,7 @@ ConfigureEntry( */ int min, max; - size_t formatLen, formatSpace = TCL_DOUBLE_SPACE; + size_t formatLen; char fbuf[4], *fmt = sbPtr->reqFormat; formatLen = strlen(fmt); @@ -1390,7 +1395,7 @@ ConfigureEntry( } else if (dvalue < sbPtr->fromValue) { dvalue = sbPtr->fromValue; } - sprintf(sbPtr->formatBuf, sbPtr->valueFormat, dvalue); + snprintf(sbPtr->formatBuf, formatSpace, sbPtr->valueFormat, dvalue); /* * No check for error return here as well, because any possible @@ -3628,11 +3633,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", (int)index); + snprintf(numStorage, sizeof(numStorage), "%d", (int)index); string = numStorage; break; case 'P': /* 'Peeked' new value of the string */ @@ -4506,7 +4511,7 @@ SpinboxInvoke( dvalue = sbPtr->toValue; } } - sprintf(sbPtr->formatBuf, sbPtr->valueFormat, dvalue); + snprintf(sbPtr->formatBuf, TCL_DOUBLE_SPACE, sbPtr->valueFormat, dvalue); code = EntryValueChanged(entryPtr, sbPtr->formatBuf); } } @@ -4623,9 +4628,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; |