summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pugixml.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index ac036e3..518ceec 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -7998,11 +7998,11 @@ PUGI__NS_BEGIN
// gets mantissa digits in the form of 0.xxxxx with 0. implied and the exponent
#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 && !defined(_WIN32_WCE)
- PUGI__FN void convert_number_to_mantissa_exponent(double value, char* buffer, size_t buffer_size, char** out_mantissa, int* out_exponent)
+ PUGI__FN void convert_number_to_mantissa_exponent(double value, char (&buffer)[32], char** out_mantissa, int* out_exponent)
{
// get base values
int sign, exponent;
- _ecvt_s(buffer, buffer_size, value, DBL_DIG + 1, &exponent, &sign);
+ _ecvt_s(buffer, sizeof(buffer), value, DBL_DIG + 1, &exponent, &sign);
// truncate redundant zeros
truncate_zeros(buffer, buffer + strlen(buffer));
@@ -8012,20 +8012,18 @@ PUGI__NS_BEGIN
*out_exponent = exponent;
}
#else
- PUGI__FN void convert_number_to_mantissa_exponent(double value, char* buffer, size_t buffer_size, char** out_mantissa, int* out_exponent)
+ PUGI__FN void convert_number_to_mantissa_exponent(double value, char (&buffer)[32], char** out_mantissa, int* out_exponent)
{
// get a scientific notation value with IEEE DBL_DIG decimals
#if defined(PUGI__HAVE_SNPRINTF)
- snprintf(buffer, buffer_size, "%.*e", DBL_DIG, value);
+ snprintf(buffer, 32, "%.*e", DBL_DIG, value);
#elif defined(PUGI__MSVC_CRT_VERSION)
- _snprintf(buffer, buffer_size, "%.*e", DBL_DIG, value);
- buffer[buffer_size - 1] = '\0';
+ _snprintf(buffer, 32, "%.*e", DBL_DIG, value);
+ buffer[31] = '\0';
#else
sprintf(buffer, "%.*e", DBL_DIG, value);
- assert(strlen(buffer) < buffer_size);
#endif
-
// get the exponent (possibly negative)
char* exponent_string = strchr(buffer, 'e');
assert(exponent_string);
@@ -8061,7 +8059,7 @@ PUGI__NS_BEGIN
char* mantissa;
int exponent;
- convert_number_to_mantissa_exponent(value, mantissa_buffer, sizeof(mantissa_buffer), &mantissa, &exponent);
+ convert_number_to_mantissa_exponent(value, mantissa_buffer, &mantissa, &exponent);
// allocate a buffer of suitable length for the number
size_t result_size = strlen(mantissa_buffer) + (exponent > 0 ? exponent : -exponent) + 4;