1 --- src/parser/sax_token_parser.cpp
2 +++ src/parser/sax_token_parser.cpp
5 #include <mdds/sorted_string_map.hpp>
12 m_elem.raw_name = elem.name;
15 +static uint8_t readUint8(char const * begin, char const * end, char const ** endptr) {
17 + char const * p = begin;
18 + for (; p != end; ++p) {
20 + if (c < '0' || c > '9') {
23 + n = 10 * n + (c - '0');
24 + if (n > std::numeric_limits<uint8_t>::max()) {
37 void sax_token_handler_wrapper_base::attribute(std::string_view name, std::string_view val)
39 decl_attr_type dat = decl_attr::get().find(name.data(), name.size());
41 const char* p = val.data();
42 const char* p_end = p + val.size();
44 - char* endptr = nullptr;
45 - long v = std::strtol(p, &endptr, 10);
46 + const char* endptr = nullptr;
47 + uint8_t v = readUint8(p, p_end, &endptr);
49 - if (!endptr || endptr >= p_end || *endptr != '.')
50 + if (!endptr || endptr == p_end || *endptr != '.')
53 m_declaration.version_major = v;
56 - v = std::strtol(p, &endptr, 10);
57 + v = readUint8(p, p_end, &endptr);
59 - if (!endptr || endptr > p_end)
63 m_declaration.version_minor = v;