mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-05-18 03:32:13 +02:00
Merge pull request #528 from DrMetallius/master
Used macros to disable localeconv() calls
This commit is contained in:
commit
c4ab6d733f
@ -5,7 +5,10 @@
|
|||||||
|
|
||||||
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||||
#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef NO_LOCALE_SUPPORT
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This header provides common string manipulation support, such as UTF-8,
|
/* This header provides common string manipulation support, such as UTF-8,
|
||||||
* portable conversion from/to string...
|
* portable conversion from/to string...
|
||||||
@ -14,26 +17,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
|
static char getDecimalPoint() {
|
||||||
/// Fallback for decimal_point on android, where the lconv is an empty struct.
|
#ifdef NO_LOCALE_SUPPORT
|
||||||
template<typename Lconv, bool=(sizeof(Lconv) >= sizeof(char*))>
|
|
||||||
struct Locale {
|
|
||||||
static char decimalPoint() {
|
|
||||||
return '\0';
|
return '\0';
|
||||||
}
|
#else
|
||||||
};
|
struct lconv* lc = localeconv();
|
||||||
|
return lc ? *(lc->decimal_point) : '\0';
|
||||||
/// Return decimal_point for the current locale.
|
#endif
|
||||||
template<typename Lconv>
|
}
|
||||||
struct Locale<Lconv, true> {
|
|
||||||
static char decimalPoint() {
|
|
||||||
Lconv* lc = localeconv();
|
|
||||||
if (lc == NULL) {
|
|
||||||
return '\0';
|
|
||||||
}
|
|
||||||
return *(lc->decimal_point);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Converts a unicode code-point to UTF-8.
|
/// Converts a unicode code-point to UTF-8.
|
||||||
static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
||||||
@ -104,7 +95,7 @@ static inline void fixNumericLocale(char* begin, char* end) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void fixNumericLocaleInput(char* begin, char* end) {
|
static inline void fixNumericLocaleInput(char* begin, char* end) {
|
||||||
char decimalPoint = Locale<struct lconv>::decimalPoint();
|
char decimalPoint = getDecimalPoint();
|
||||||
if (decimalPoint != '\0' && decimalPoint != '.') {
|
if (decimalPoint != '\0' && decimalPoint != '.') {
|
||||||
while (begin < end) {
|
while (begin < end) {
|
||||||
if (*begin == '.') {
|
if (*begin == '.') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user