diff --git a/errors.txt b/errors.txt deleted file mode 100644 index d3a6c6db..00000000 --- a/errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -- test/test-class_parser - - 617 failed -- test/test-regression - - 11 failed -- test/test-testsuites - - 43 failed - diff --git a/src/json.hpp b/src/json.hpp index e47abab4..2ab32885 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -10517,12 +10517,13 @@ class basic_json } explicit lexer(std::istream& i) - // : ia(new input_stream_adapter(i)) - : ia(new cached_input_stream_adapter(i)) + : ia(new cached_input_stream_adapter(i)), + decimal_point_char(get_decimal_point()) {} lexer(const char* buff, const size_t len) - : ia(new input_buffer_adapter(buff, len)) + : ia(new input_buffer_adapter(buff, len)), + decimal_point_char(get_decimal_point()) {} ~lexer() @@ -10536,6 +10537,18 @@ class basic_json lexer operator=(const lexer&) = delete; private: + ///////////////////// + // locales + ///////////////////// + + /// return the locale-dependent decimal point + static char get_decimal_point() noexcept + { + const auto loc = localeconv(); + assert(loc != nullptr); + return (loc->decimal_point == nullptr) ? '.' : loc->decimal_point[0]; + } + ///////////////////// // scan functions ///////////////////// @@ -10815,7 +10828,8 @@ class basic_json return token_type::parse_error; } - add(current); + // add current character and fix decimal point + add((state == 4) ? decimal_point_char : current); get(); old_state = state; state = lookup[state][static_cast(current)]; @@ -11103,6 +11117,9 @@ class basic_json long long value_integer = 0; unsigned long long value_unsigned = 0; double value_float = 0; + + // the decimal point + const char decimal_point_char = '\0'; }; /*!