|
5 | 5 |
|
6 | 6 | #ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
7 | 7 | #define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
| 8 | + |
| 9 | +#ifndef NO_LOCALE_SUPPORT |
8 | 10 | #include <clocale>
|
| 11 | +#endif |
9 | 12 |
|
10 | 13 | /* This header provides common string manipulation support, such as UTF-8,
|
11 | 14 | * portable conversion from/to string...
|
|
14 | 17 | */
|
15 | 18 |
|
16 | 19 | namespace Json {
|
17 |
| - |
18 |
| -/// Fallback for decimal_point on android, where the lconv is an empty struct. |
19 |
| -template<typename Lconv, bool=(sizeof(Lconv) >= sizeof(char*))> |
20 |
| -struct Locale { |
21 |
| - static char decimalPoint() { |
22 |
| - return '\0'; |
23 |
| - } |
24 |
| -}; |
25 |
| - |
26 |
| -/// Return decimal_point for the current locale. |
27 |
| -template<typename Lconv> |
28 |
| -struct Locale<Lconv, true> { |
29 |
| - static char decimalPoint() { |
30 |
| - Lconv* lc = localeconv(); |
31 |
| - if (lc == NULL) { |
32 |
| - return '\0'; |
33 |
| - } |
34 |
| - return *(lc->decimal_point); |
35 |
| - } |
36 |
| -}; |
| 20 | +static char getDecimalPoint() { |
| 21 | +#ifdef NO_LOCALE_SUPPORT |
| 22 | + return '\0'; |
| 23 | +#else |
| 24 | + struct lconv* lc = localeconv(); |
| 25 | + return lc ? *(lc->decimal_point) : '\0'; |
| 26 | +#endif |
| 27 | +} |
37 | 28 |
|
38 | 29 | /// Converts a unicode code-point to UTF-8.
|
39 | 30 | static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
@@ -104,7 +95,7 @@ static inline void fixNumericLocale(char* begin, char* end) {
|
104 | 95 | }
|
105 | 96 |
|
106 | 97 | static inline void fixNumericLocaleInput(char* begin, char* end) {
|
107 |
| - char decimalPoint = Locale<struct lconv>::decimalPoint(); |
| 98 | + char decimalPoint = getDecimalPoint(); |
108 | 99 | if (decimalPoint != '\0' && decimalPoint != '.') {
|
109 | 100 | while (begin < end) {
|
110 | 101 | if (*begin == '.') {
|
|
0 commit comments