1
0
mirror of https://github.com/nlohmann/json synced 2024-12-04 09:10:05 +00:00

Bugfix: when working with C formatting functions we need to query C locales (localeconv) rather than std::locale

This commit is contained in:
Alex Astashyn 2016-12-06 00:43:12 -05:00
parent e41a956782
commit d643360575
2 changed files with 22 additions and 2 deletions

View File

@ -9108,7 +9108,7 @@ basic_json_parser_66:
// this is a helper to determine whether to
// parse the token into floating-point or
// integral type. We wouldn't need it if
// we had separate token types for interal
// we had separate token types for integral
// and floating-point cases.
bool is_integral() const
{
@ -9172,9 +9172,19 @@ basic_json_parser_66:
const char* data = m_start;
const size_t len = static_cast<size_t>(m_end - m_start);
#if 0
const char decimal_point_char =
std::use_facet< std::numpunct<char> >(
std::locale()).decimal_point();
#else
// Since dealing with strtod family of functions,
// need to use the C locales instead of C++
const auto loc = localeconv();
assert(loc != nullptr);
const char decimal_point_char =
!loc->decimal_point ? '.'
: loc->decimal_point[0];
#endif
// replace decimal separator with locale-specific
// version, when necessary; data will be repointed

View File

@ -8257,7 +8257,7 @@ class basic_json
// this is a helper to determine whether to
// parse the token into floating-point or
// integral type. We wouldn't need it if
// we had separate token types for interal
// we had separate token types for integral
// and floating-point cases.
bool is_integral() const
{
@ -8321,9 +8321,19 @@ class basic_json
const char* data = m_start;
const size_t len = static_cast<size_t>(m_end - m_start);
#if 0
const char decimal_point_char =
std::use_facet< std::numpunct<char> >(
std::locale()).decimal_point();
#else
// Since dealing with strtod family of functions,
// need to use the C locales instead of C++
const auto loc = localeconv();
assert(loc != nullptr);
const char decimal_point_char =
!loc->decimal_point ? '.'
: loc->decimal_point[0];
#endif
// replace decimal separator with locale-specific
// version, when necessary; data will be repointed