File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change 1515
1616namespace Json {
1717
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+
1838// / Converts a unicode code-point to UTF-8.
1939static inline JSONCPP_STRING codePointToUTF8 (unsigned int cp) {
2040 JSONCPP_STRING result;
@@ -84,11 +104,11 @@ static inline void fixNumericLocale(char* begin, char* end) {
84104}
85105
86106static 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 != ' .' ) {
89109 while (begin < end) {
90110 if (*begin == ' .' ) {
91- *begin = *(lc-> decimal_point ) ;
111+ *begin = decimalPoint ;
92112 }
93113 ++begin;
94114 }
You can’t perform that action at this time.
0 commit comments