kopia lustrzana https://github.com/Hamlib/Hamlib
rodzic
086c3f7f1d
commit
0600adb077
|
@ -124,7 +124,7 @@ CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item)
|
||||||
CJSON_PUBLIC(const char*) cJSON_Version(void)
|
CJSON_PUBLIC(const char*) cJSON_Version(void)
|
||||||
{
|
{
|
||||||
static char version[15];
|
static char version[15];
|
||||||
sprintf(version, "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH);
|
snprintf(version, sizeof(version), "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH);
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
@ -560,18 +560,18 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
|
||||||
/* This checks for NaN and Infinity */
|
/* This checks for NaN and Infinity */
|
||||||
if (isnan(d) || isinf(d))
|
if (isnan(d) || isinf(d))
|
||||||
{
|
{
|
||||||
length = sprintf((char*)number_buffer, "null");
|
length = snprintf((char*)number_buffer, sizeof(number_buffer), "null");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */
|
/* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */
|
||||||
length = sprintf((char*)number_buffer, "%1.15g", d);
|
length = snprintf((char*)number_buffer, sizeof(number_buffer), "%1.15g", d);
|
||||||
|
|
||||||
/* Check whether the original double can be recovered */
|
/* Check whether the original double can be recovered */
|
||||||
if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || !compare_double((double)test, d))
|
if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || !compare_double((double)test, d))
|
||||||
{
|
{
|
||||||
/* If not, print with 17 decimal places of precision */
|
/* If not, print with 17 decimal places of precision */
|
||||||
length = sprintf((char*)number_buffer, "%1.17g", d);
|
length = snprintf((char*)number_buffer, sizeof(number_buffer), "%1.17g", d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue