diff options
author | Renaud Guillard <dev@nore.fr> | 2017-06-05 13:31:58 +0200 |
---|---|---|
committer | Renaud Guillard <dev@nore.fr> | 2017-06-05 13:31:58 +0200 |
commit | 810f1f600d5366fc3d3f95189ce2fe7699532e25 (patch) | |
tree | 11ade62bd719b2808f5d703c23e681ce7b7a1d1a /src | |
parent | b5e9d933ad5232a1585f8bc8dfe7860e17dad57f (diff) |
use _snprintf if MSVC
Diffstat (limited to 'src')
-rw-r--r-- | src/pugixml.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 9973999..37a62fc 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -4632,7 +4632,11 @@ PUGI__NS_BEGIN PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, float value) { char buf[128]; +#if defined(PUGI__MSVC_CRT_VERSION) + _snprintf(buf, 128, "%.9g", value); +#else snprintf(buf, 128, "%.9g", value); +#endif buf[127] = '\0'; return set_value_ascii(dest, header, header_mask, buf); @@ -4642,7 +4646,11 @@ PUGI__NS_BEGIN PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, double value) { char buf[128]; +#if defined(PUGI__MSVC_CRT_VERSION) + _snprintf(buf, 128, "%.17g", value); +#else snprintf(buf, 128, "%.17g", value); +#endif buf[127] = '\0'; return set_value_ascii(dest, header, header_mask, buf); @@ -7999,7 +8007,11 @@ PUGI__NS_BEGIN PUGI__FN void convert_number_to_mantissa_exponent(double value, char* buffer, size_t buffer_size, char** out_mantissa, int* out_exponent) { // get a scientific notation value with IEEE DBL_DIG decimals +#if defined(PUGI__MSVC_CRT_VERSION) + _snprintf(buffer, buffer_size, "%.*e", DBL_DIG, value); +#else snprintf(buffer, buffer_size, "%.*e", DBL_DIG, value); +#endif buffer[buffer_size - 1] = '\0'; // get the exponent (possibly negative) |