mirror of
https://github.com/zeek/zeek.git
synced 2025-10-01 22:28:20 +00:00
src/3rdparty: modp: Disable deprecation warning for sprintf
This commit is contained in:
parent
dfd32b3b37
commit
6a060588c2
1 changed files with 21 additions and 0 deletions
21
src/3rdparty/modp_numtoa.c
vendored
21
src/3rdparty/modp_numtoa.c
vendored
|
@ -186,7 +186,14 @@ size_t modp_dtoa(double value, char* str, int prec)
|
||||||
which can be 100s of characters overflowing your buffers == bad
|
which can be 100s of characters overflowing your buffers == bad
|
||||||
*/
|
*/
|
||||||
if (value >= thres_max) {
|
if (value >= thres_max) {
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
// Ignore the diagnostic warning about sprintf being deprecated here. We
|
||||||
|
// have to assume that the size of the string is long enough here
|
||||||
|
// because we'd have to change the function definition to support
|
||||||
|
// passing a length.
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
int n = sprintf(str, "%.*e", DBL_DECIMAL_DIG - 1, neg ? -value : value);
|
int n = sprintf(str, "%.*e", DBL_DECIMAL_DIG - 1, neg ? -value : value);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
n -= sn_strip_trailing_zeros(str);
|
n -= sn_strip_trailing_zeros(str);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
@ -287,7 +294,14 @@ size_t modp_dtoa2(double value, char* str, int prec)
|
||||||
which can be 100s of characters overflowing your buffers == bad
|
which can be 100s of characters overflowing your buffers == bad
|
||||||
*/
|
*/
|
||||||
if (value >= thres_max) {
|
if (value >= thres_max) {
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
// Ignore the diagnostic warning about sprintf being deprecated here. We
|
||||||
|
// have to assume that the size of the string is long enough here
|
||||||
|
// because we'd have to change the function definition to support
|
||||||
|
// passing a length.
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
int n = sprintf(str, "%.*e", DBL_DECIMAL_DIG - 1, neg ? -value : value);
|
int n = sprintf(str, "%.*e", DBL_DECIMAL_DIG - 1, neg ? -value : value);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
n -= sn_strip_trailing_zeros(str);
|
n -= sn_strip_trailing_zeros(str);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
@ -306,7 +320,14 @@ size_t modp_dtoa2(double value, char* str, int prec)
|
||||||
double smallest = _pow10r[prec];
|
double smallest = _pow10r[prec];
|
||||||
|
|
||||||
if (value != 0.0 && value < smallest) {
|
if (value != 0.0 && value < smallest) {
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
// Ignore the diagnostic warning about sprintf being deprecated here. We
|
||||||
|
// have to assume that the size of the string is long enough here
|
||||||
|
// because we'd have to change the function definition to support
|
||||||
|
// passing a length.
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
int n = sprintf(str, "%.*e", DBL_DECIMAL_DIG - 1, neg ? -value : value);
|
int n = sprintf(str, "%.*e", DBL_DECIMAL_DIG - 1, neg ? -value : value);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
n -= sn_strip_trailing_zeros(str);
|
n -= sn_strip_trailing_zeros(str);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue