Merge pull request #1525 from realm/kneth/bug/dont-call-localeconv-on-android

localeconv() doesn't exist on Android API < 21.
This commit is contained in:
Kenneth Geisshirt 2017-11-27 11:57:21 +01:00 committed by GitHub
commit 594be6f80c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View File

@ -1,3 +1,17 @@
X.Y.Z Release notes
=============================================================
### Breaking changes
* None.
### Enchancements
* None
### Bug fixes
* Fixed a bug in 3rd party JSON parser: `localeconv()` does not exist on Android API < 21 and should not be called.
### Internal
* None.
2.0.11 Release notes (2017-11-23) 2.0.11 Release notes (2017-11-23)
============================================================= =============================================================
### Breaking changes ### Breaking changes

14
vendor/json.hpp vendored
View File

@ -8333,15 +8333,15 @@ class basic_json
// check if buffer was large enough // check if buffer was large enough
assert(static_cast<size_t>(written_bytes) < m_buf.size()); assert(static_cast<size_t>(written_bytes) < m_buf.size());
#if defined(ANDROID)
// Android NDK doesn't have access to locale info yet; API < 21 doesn't have localeconv()
const char thousands_sep = ',';
const char decimal_point = '.';
#else
// read information from locale // read information from locale
const auto loc = localeconv(); const auto loc = localeconv();
assert(loc != nullptr); assert(loc != nullptr);
#if defined(ANDROID)
// Android NDK doesn't have access to locale info yet
const char thousands_sep = ',';
const char decimal_point = '.';
#else
const char thousands_sep = !loc->thousands_sep ? '\0' const char thousands_sep = !loc->thousands_sep ? '\0'
: loc->thousands_sep[0]; : loc->thousands_sep[0];
@ -11176,11 +11176,11 @@ basic_json_parser_74:
// since dealing with strtod family of functions, we're // since dealing with strtod family of functions, we're
// getting the decimal point char from the C locale facilities // getting the decimal point char from the C locale facilities
// instead of C++'s numpunct facet of the current std::locale // instead of C++'s numpunct facet of the current std::locale
const auto loc = localeconv();
assert(loc != nullptr);
#if defined(ANDROID) #if defined(ANDROID)
const char decimal_point_char = '.'; const char decimal_point_char = '.';
#else #else
const auto loc = localeconv();
assert(loc != nullptr);
const char decimal_point_char = (loc->decimal_point == nullptr) ? '.' : loc->decimal_point[0]; const char decimal_point_char = (loc->decimal_point == nullptr) ? '.' : loc->decimal_point[0];
#endif #endif