File tree 1 file changed +23
-3
lines changed
1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change 15
15
16
16
namespace Json {
17
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
+ };
37
+
18
38
// / Converts a unicode code-point to UTF-8.
19
39
static inline JSONCPP_STRING codePointToUTF8 (unsigned int cp) {
20
40
JSONCPP_STRING result;
@@ -84,11 +104,11 @@ static inline void fixNumericLocale(char* begin, char* end) {
84
104
}
85
105
86
106
static inline void fixNumericLocaleInput (char * begin, char * end) {
87
- struct lconv * lc = localeconv ();
88
- if ((lc != NULL ) && (*(lc-> decimal_point ) != ' .' ) ) {
107
+ char decimalPoint = Locale< struct lconv >:: decimalPoint ();
108
+ if (decimalPoint != ' \0 ' && decimalPoint != ' .' ) {
89
109
while (begin < end) {
90
110
if (*begin == ' .' ) {
91
- *begin = *(lc-> decimal_point ) ;
111
+ *begin = decimalPoint ;
92
112
}
93
113
++begin;
94
114
}
You can’t perform that action at this time.
0 commit comments