This commit is contained in:
Cameron Druyor 2016-05-08 14:19:17 +00:00
commit 864fb58bf7
3 changed files with 390 additions and 745 deletions

View File

@ -6152,10 +6152,7 @@ class basic_json
// remove '+' sign from the exponent if necessary // remove '+' sign from the exponent if necessary
if (not m_type.bits.exp_plus) if (not m_type.bits.exp_plus)
{ {
if (len > static_cast<int>(sizeof(buf))) len = std::min(len, static_cast<int>(sizeof(buf)));
{
len = sizeof(buf);
}
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
{ {
if (buf[i] == '+') if (buf[i] == '+')
@ -7412,8 +7409,7 @@ class basic_json
{ {
lexer_char_t yych; lexer_char_t yych;
unsigned int yyaccept = 0; unsigned int yyaccept = 0;
static const unsigned char yybm[] = static const unsigned char yybm[] = {
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 32, 32, 0, 0, 32, 0, 0, 0, 32, 32, 0, 0, 32, 0, 0,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
@ -7447,716 +7443,340 @@ class basic_json
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
}; };
if ((m_limit - m_cursor) < 5) if ((m_limit - m_cursor) < 5) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yybm[0 + yych] & 32) if (yybm[0+yych] & 32) {
{
goto basic_json_parser_6; goto basic_json_parser_6;
} }
if (yych <= '\\') if (yych <= '\\') {
{ if (yych <= '-') {
if (yych <= '-') if (yych <= '"') {
{ if (yych <= 0x00) goto basic_json_parser_2;
if (yych <= '"') if (yych <= '!') goto basic_json_parser_4;
{
if (yych <= 0x00)
{
goto basic_json_parser_2;
}
if (yych <= '!')
{
goto basic_json_parser_4;
}
goto basic_json_parser_9; goto basic_json_parser_9;
} } else {
else if (yych <= '+') goto basic_json_parser_4;
{ if (yych <= ',') goto basic_json_parser_10;
if (yych <= '+')
{
goto basic_json_parser_4;
}
if (yych <= ',')
{
goto basic_json_parser_10;
}
goto basic_json_parser_12; goto basic_json_parser_12;
} }
} } else {
else if (yych <= '9') {
{ if (yych <= '/') goto basic_json_parser_4;
if (yych <= '9') if (yych <= '0') goto basic_json_parser_13;
{
if (yych <= '/')
{
goto basic_json_parser_4;
}
if (yych <= '0')
{
goto basic_json_parser_13;
}
goto basic_json_parser_15; goto basic_json_parser_15;
} } else {
else if (yych <= ':') goto basic_json_parser_17;
{ if (yych == '[') goto basic_json_parser_19;
if (yych <= ':')
{
goto basic_json_parser_17;
}
if (yych == '[')
{
goto basic_json_parser_19;
}
goto basic_json_parser_4; goto basic_json_parser_4;
} }
} }
} } else {
else if (yych <= 't') {
{ if (yych <= 'f') {
if (yych <= 't') if (yych <= ']') goto basic_json_parser_21;
{ if (yych <= 'e') goto basic_json_parser_4;
if (yych <= 'f')
{
if (yych <= ']')
{
goto basic_json_parser_21;
}
if (yych <= 'e')
{
goto basic_json_parser_4;
}
goto basic_json_parser_23; goto basic_json_parser_23;
} } else {
else if (yych == 'n') goto basic_json_parser_24;
{ if (yych <= 's') goto basic_json_parser_4;
if (yych == 'n')
{
goto basic_json_parser_24;
}
if (yych <= 's')
{
goto basic_json_parser_4;
}
goto basic_json_parser_25; goto basic_json_parser_25;
} }
} } else {
else if (yych <= '|') {
{ if (yych == '{') goto basic_json_parser_26;
if (yych <= '|')
{
if (yych == '{')
{
goto basic_json_parser_26;
}
goto basic_json_parser_4; goto basic_json_parser_4;
} } else {
else if (yych <= '}') goto basic_json_parser_28;
{ if (yych == 0xEF) goto basic_json_parser_30;
if (yych <= '}')
{
goto basic_json_parser_28;
}
if (yych == 0xEF)
{
goto basic_json_parser_30;
}
goto basic_json_parser_4; goto basic_json_parser_4;
} }
} }
} }
basic_json_parser_2: basic_json_parser_2:
++m_cursor; ++m_cursor;
{ { return token_type::end_of_input; }
return token_type::end_of_input;
}
basic_json_parser_4: basic_json_parser_4:
++m_cursor; ++m_cursor;
basic_json_parser_5: basic_json_parser_5:
{ { return token_type::parse_error; }
return token_type::parse_error;
}
basic_json_parser_6: basic_json_parser_6:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yybm[0 + yych] & 32) if (yybm[0+yych] & 32) {
{
goto basic_json_parser_6; goto basic_json_parser_6;
} }
{ { return scan(); }
return scan();
}
basic_json_parser_9: basic_json_parser_9:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych <= 0x0F) if (yych <= 0x0F) goto basic_json_parser_5;
{
goto basic_json_parser_5;
}
goto basic_json_parser_32; goto basic_json_parser_32;
basic_json_parser_10: basic_json_parser_10:
++m_cursor; ++m_cursor;
{ { return token_type::value_separator; }
return token_type::value_separator;
}
basic_json_parser_12: basic_json_parser_12:
yych = *++m_cursor; yych = *++m_cursor;
if (yych <= '/') if (yych <= '/') goto basic_json_parser_5;
{ if (yych <= '0') goto basic_json_parser_13;
goto basic_json_parser_5; if (yych <= '9') goto basic_json_parser_15;
}
if (yych <= '0')
{
goto basic_json_parser_13;
}
if (yych <= '9')
{
goto basic_json_parser_15;
}
goto basic_json_parser_5; goto basic_json_parser_5;
basic_json_parser_13: basic_json_parser_13:
yyaccept = 1; yyaccept = 1;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych <= 'D') if (yych <= 'D') {
{ if (yych == '.') goto basic_json_parser_37;
if (yych == '.') } else {
{ if (yych <= 'E') goto basic_json_parser_38;
goto basic_json_parser_37; if (yych == 'e') goto basic_json_parser_38;
}
}
else
{
if (yych <= 'E')
{
goto basic_json_parser_38;
}
if (yych == 'e')
{
goto basic_json_parser_38;
}
} }
basic_json_parser_14: basic_json_parser_14:
{ { return token_type::value_number; }
return token_type::value_number;
}
basic_json_parser_15: basic_json_parser_15:
yyaccept = 1; yyaccept = 1;
m_marker = ++m_cursor; m_marker = ++m_cursor;
if ((m_limit - m_cursor) < 3) if ((m_limit - m_cursor) < 3) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yybm[0 + yych] & 64) if (yybm[0+yych] & 64) {
{
goto basic_json_parser_15; goto basic_json_parser_15;
} }
if (yych <= 'D') if (yych <= 'D') {
{ if (yych == '.') goto basic_json_parser_37;
if (yych == '.')
{
goto basic_json_parser_37;
}
goto basic_json_parser_14; goto basic_json_parser_14;
} } else {
else if (yych <= 'E') goto basic_json_parser_38;
{ if (yych == 'e') goto basic_json_parser_38;
if (yych <= 'E')
{
goto basic_json_parser_38;
}
if (yych == 'e')
{
goto basic_json_parser_38;
}
goto basic_json_parser_14; goto basic_json_parser_14;
} }
basic_json_parser_17: basic_json_parser_17:
++m_cursor; ++m_cursor;
{ { return token_type::name_separator; }
return token_type::name_separator;
}
basic_json_parser_19: basic_json_parser_19:
++m_cursor; ++m_cursor;
{ { return token_type::begin_array; }
return token_type::begin_array;
}
basic_json_parser_21: basic_json_parser_21:
++m_cursor; ++m_cursor;
{ { return token_type::end_array; }
return token_type::end_array;
}
basic_json_parser_23: basic_json_parser_23:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych == 'a') if (yych == 'a') goto basic_json_parser_39;
{
goto basic_json_parser_39;
}
goto basic_json_parser_5; goto basic_json_parser_5;
basic_json_parser_24: basic_json_parser_24:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych == 'u') if (yych == 'u') goto basic_json_parser_40;
{
goto basic_json_parser_40;
}
goto basic_json_parser_5; goto basic_json_parser_5;
basic_json_parser_25: basic_json_parser_25:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych == 'r') if (yych == 'r') goto basic_json_parser_41;
{
goto basic_json_parser_41;
}
goto basic_json_parser_5; goto basic_json_parser_5;
basic_json_parser_26: basic_json_parser_26:
++m_cursor; ++m_cursor;
{ { return token_type::begin_object; }
return token_type::begin_object;
}
basic_json_parser_28: basic_json_parser_28:
++m_cursor; ++m_cursor;
{ { return token_type::end_object; }
return token_type::end_object;
}
basic_json_parser_30: basic_json_parser_30:
yyaccept = 0; yyaccept = 0;
yych = *(m_marker = ++m_cursor); yych = *(m_marker = ++m_cursor);
if (yych == 0xBB) if (yych == 0xBB) goto basic_json_parser_42;
{
goto basic_json_parser_42;
}
goto basic_json_parser_5; goto basic_json_parser_5;
basic_json_parser_31: basic_json_parser_31:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
basic_json_parser_32: basic_json_parser_32:
if (yybm[0 + yych] & 128) if (yybm[0+yych] & 128) {
{
goto basic_json_parser_31; goto basic_json_parser_31;
} }
if (yych <= 0x0F) if (yych <= 0x0F) goto basic_json_parser_33;
{ if (yych <= '"') goto basic_json_parser_34;
goto basic_json_parser_33;
}
if (yych <= '"')
{
goto basic_json_parser_34;
}
goto basic_json_parser_36; goto basic_json_parser_36;
basic_json_parser_33: basic_json_parser_33:
m_cursor = m_marker; m_cursor = m_marker;
if (yyaccept == 0) if (yyaccept == 0) {
{
goto basic_json_parser_5; goto basic_json_parser_5;
} } else {
else
{
goto basic_json_parser_14; goto basic_json_parser_14;
} }
basic_json_parser_34: basic_json_parser_34:
++m_cursor; ++m_cursor;
{ { return token_type::value_string; }
return token_type::value_string;
}
basic_json_parser_36: basic_json_parser_36:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= 'e') if (yych <= 'e') {
{ if (yych <= '/') {
if (yych <= '/') if (yych == '"') goto basic_json_parser_31;
{ if (yych <= '.') goto basic_json_parser_33;
if (yych == '"')
{
goto basic_json_parser_31; goto basic_json_parser_31;
} } else {
if (yych <= '.') if (yych <= '\\') {
{ if (yych <= '[') goto basic_json_parser_33;
goto basic_json_parser_33;
}
goto basic_json_parser_31; goto basic_json_parser_31;
} } else {
else if (yych == 'b') goto basic_json_parser_31;
{
if (yych <= '\\')
{
if (yych <= '[')
{
goto basic_json_parser_33;
}
goto basic_json_parser_31;
}
else
{
if (yych == 'b')
{
goto basic_json_parser_31;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
} }
} } else {
else if (yych <= 'q') {
{ if (yych <= 'f') goto basic_json_parser_31;
if (yych <= 'q') if (yych == 'n') goto basic_json_parser_31;
{
if (yych <= 'f')
{
goto basic_json_parser_31;
}
if (yych == 'n')
{
goto basic_json_parser_31;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
else if (yych <= 's') {
{ if (yych <= 'r') goto basic_json_parser_31;
if (yych <= 's')
{
if (yych <= 'r')
{
goto basic_json_parser_31;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
else if (yych <= 't') goto basic_json_parser_31;
{ if (yych <= 'u') goto basic_json_parser_43;
if (yych <= 't')
{
goto basic_json_parser_31;
}
if (yych <= 'u')
{
goto basic_json_parser_43;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
} }
} }
basic_json_parser_37: basic_json_parser_37:
yych = *++m_cursor; yych = *++m_cursor;
if (yych <= '/') if (yych <= '/') goto basic_json_parser_33;
{ if (yych <= '9') goto basic_json_parser_44;
goto basic_json_parser_33;
}
if (yych <= '9')
{
goto basic_json_parser_44;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_38: basic_json_parser_38:
yych = *++m_cursor; yych = *++m_cursor;
if (yych <= ',') if (yych <= ',') {
{ if (yych == '+') goto basic_json_parser_46;
if (yych == '+')
{
goto basic_json_parser_46;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
else if (yych <= '-') goto basic_json_parser_46;
{ if (yych <= '/') goto basic_json_parser_33;
if (yych <= '-') if (yych <= '9') goto basic_json_parser_47;
{
goto basic_json_parser_46;
}
if (yych <= '/')
{
goto basic_json_parser_33;
}
if (yych <= '9')
{
goto basic_json_parser_47;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
basic_json_parser_39: basic_json_parser_39:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 'l') if (yych == 'l') goto basic_json_parser_49;
{
goto basic_json_parser_49;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_40: basic_json_parser_40:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 'l') if (yych == 'l') goto basic_json_parser_50;
{
goto basic_json_parser_50;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_41: basic_json_parser_41:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 'u') if (yych == 'u') goto basic_json_parser_51;
{
goto basic_json_parser_51;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_42: basic_json_parser_42:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 0xBF) if (yych == 0xBF) goto basic_json_parser_52;
{
goto basic_json_parser_52;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_43: basic_json_parser_43:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= '@') if (yych <= '@') {
{ if (yych <= '/') goto basic_json_parser_33;
if (yych <= '/') if (yych <= '9') goto basic_json_parser_54;
{
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
if (yych <= '9') if (yych <= 'F') goto basic_json_parser_54;
{ if (yych <= '`') goto basic_json_parser_33;
goto basic_json_parser_54; if (yych <= 'f') goto basic_json_parser_54;
}
goto basic_json_parser_33;
}
else
{
if (yych <= 'F')
{
goto basic_json_parser_54;
}
if (yych <= '`')
{
goto basic_json_parser_33;
}
if (yych <= 'f')
{
goto basic_json_parser_54;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
basic_json_parser_44: basic_json_parser_44:
yyaccept = 1; yyaccept = 1;
m_marker = ++m_cursor; m_marker = ++m_cursor;
if ((m_limit - m_cursor) < 3) if ((m_limit - m_cursor) < 3) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= 'D') if (yych <= 'D') {
{ if (yych <= '/') goto basic_json_parser_14;
if (yych <= '/') if (yych <= '9') goto basic_json_parser_44;
{
goto basic_json_parser_14; goto basic_json_parser_14;
} } else {
if (yych <= '9') if (yych <= 'E') goto basic_json_parser_38;
{ if (yych == 'e') goto basic_json_parser_38;
goto basic_json_parser_44;
}
goto basic_json_parser_14;
}
else
{
if (yych <= 'E')
{
goto basic_json_parser_38;
}
if (yych == 'e')
{
goto basic_json_parser_38;
}
goto basic_json_parser_14; goto basic_json_parser_14;
} }
basic_json_parser_46: basic_json_parser_46:
yych = *++m_cursor; yych = *++m_cursor;
if (yych <= '/') if (yych <= '/') goto basic_json_parser_33;
{ if (yych >= ':') goto basic_json_parser_33;
goto basic_json_parser_33;
}
if (yych >= ':')
{
goto basic_json_parser_33;
}
basic_json_parser_47: basic_json_parser_47:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= '/') if (yych <= '/') goto basic_json_parser_14;
{ if (yych <= '9') goto basic_json_parser_47;
goto basic_json_parser_14;
}
if (yych <= '9')
{
goto basic_json_parser_47;
}
goto basic_json_parser_14; goto basic_json_parser_14;
basic_json_parser_49: basic_json_parser_49:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 's') if (yych == 's') goto basic_json_parser_55;
{
goto basic_json_parser_55;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_50: basic_json_parser_50:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 'l') if (yych == 'l') goto basic_json_parser_56;
{
goto basic_json_parser_56;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_51: basic_json_parser_51:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 'e') if (yych == 'e') goto basic_json_parser_58;
{
goto basic_json_parser_58;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_52: basic_json_parser_52:
++m_cursor; ++m_cursor;
{ { return scan(); }
return scan();
}
basic_json_parser_54: basic_json_parser_54:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= '@') if (yych <= '@') {
{ if (yych <= '/') goto basic_json_parser_33;
if (yych <= '/') if (yych <= '9') goto basic_json_parser_60;
{
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
if (yych <= '9') if (yych <= 'F') goto basic_json_parser_60;
{ if (yych <= '`') goto basic_json_parser_33;
goto basic_json_parser_60; if (yych <= 'f') goto basic_json_parser_60;
}
goto basic_json_parser_33;
}
else
{
if (yych <= 'F')
{
goto basic_json_parser_60;
}
if (yych <= '`')
{
goto basic_json_parser_33;
}
if (yych <= 'f')
{
goto basic_json_parser_60;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
basic_json_parser_55: basic_json_parser_55:
yych = *++m_cursor; yych = *++m_cursor;
if (yych == 'e') if (yych == 'e') goto basic_json_parser_61;
{
goto basic_json_parser_61;
}
goto basic_json_parser_33; goto basic_json_parser_33;
basic_json_parser_56: basic_json_parser_56:
++m_cursor; ++m_cursor;
{ { return token_type::literal_null; }
return token_type::literal_null;
}
basic_json_parser_58: basic_json_parser_58:
++m_cursor; ++m_cursor;
{ { return token_type::literal_true; }
return token_type::literal_true;
}
basic_json_parser_60: basic_json_parser_60:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= '@') if (yych <= '@') {
{ if (yych <= '/') goto basic_json_parser_33;
if (yych <= '/') if (yych <= '9') goto basic_json_parser_63;
{
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
if (yych <= '9') if (yych <= 'F') goto basic_json_parser_63;
{ if (yych <= '`') goto basic_json_parser_33;
goto basic_json_parser_63; if (yych <= 'f') goto basic_json_parser_63;
}
goto basic_json_parser_33;
}
else
{
if (yych <= 'F')
{
goto basic_json_parser_63;
}
if (yych <= '`')
{
goto basic_json_parser_33;
}
if (yych <= 'f')
{
goto basic_json_parser_63;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
basic_json_parser_61: basic_json_parser_61:
++m_cursor; ++m_cursor;
{ { return token_type::literal_false; }
return token_type::literal_false;
}
basic_json_parser_63: basic_json_parser_63:
++m_cursor; ++m_cursor;
if (m_limit <= m_cursor) if (m_limit <= m_cursor) yyfill(); // LCOV_EXCL_LINE;
{
yyfill(); // LCOV_EXCL_LINE;
}
yych = *m_cursor; yych = *m_cursor;
if (yych <= '@') if (yych <= '@') {
{ if (yych <= '/') goto basic_json_parser_33;
if (yych <= '/') if (yych <= '9') goto basic_json_parser_31;
{
goto basic_json_parser_33; goto basic_json_parser_33;
} } else {
if (yych <= '9') if (yych <= 'F') goto basic_json_parser_31;
{ if (yych <= '`') goto basic_json_parser_33;
goto basic_json_parser_31; if (yych <= 'f') goto basic_json_parser_31;
}
goto basic_json_parser_33;
}
else
{
if (yych <= 'F')
{
goto basic_json_parser_31;
}
if (yych <= '`')
{
goto basic_json_parser_33;
}
if (yych <= 'f')
{
goto basic_json_parser_31;
}
goto basic_json_parser_33; goto basic_json_parser_33;
} }
} }
@ -8422,10 +8042,9 @@ basic_json_parser_63:
// remember this number was parsed (for later serialization) // remember this number was parsed (for later serialization)
result.m_type.bits.parsed = true; result.m_type.bits.parsed = true;
// 'found_radix_point' will be set to 0xFF upon finding a radix // 'found_radix_point' will be set to true upon finding a radix
// point and later used to mask in/out the precision depending // point. if it is not found, then the precision will be updated
// whether a radix is found i.e. 'precision &= found_radix_point' bool found_radix_point = false;
uint8_t found_radix_point = 0;
uint8_t precision = 0; uint8_t precision = 0;
// accumulate the integer conversion result (unsigned for now) // accumulate the integer conversion result (unsigned for now)
@ -8463,7 +8082,7 @@ basic_json_parser_63:
// reset precision count // reset precision count
precision = 0; precision = 0;
found_radix_point = 0xFF; found_radix_point = true;
continue; continue;
} }
// assume exponent (if not then will fail parse): change to // assume exponent (if not then will fail parse): change to
@ -8501,8 +8120,21 @@ basic_json_parser_63:
} }
// If no radix point was found then precision would now be set to // If no radix point was found then precision would now be set to
// the number of digits, which is wrong - clear it. // the number of digits, which is wrong - decrement it to sig figs - 1
result.m_type.bits.precision = precision & found_radix_point; if(not found_radix_point)
{
int trailing_zeros = 0;
for (int j = precision-1;j>=0;--j)
{
auto c = *(m_start+j);
if(c == '0')
++trailing_zeros;
else if((c > '0' and c <= '9') or c == '-')
break;
}
precision -= (trailing_zeros + 1);
}
result.m_type.bits.precision = precision;
// save the value (if not a float) // save the value (if not a float)
if (type == value_t::number_unsigned) if (type == value_t::number_unsigned)

View File

@ -6152,10 +6152,7 @@ class basic_json
// remove '+' sign from the exponent if necessary // remove '+' sign from the exponent if necessary
if (not m_type.bits.exp_plus) if (not m_type.bits.exp_plus)
{ {
if (len > static_cast<int>(sizeof(buf))) len = std::min(len, static_cast<int>(sizeof(buf)));
{
len = sizeof(buf);
}
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
{ {
if (buf[i] == '+') if (buf[i] == '+')
@ -7732,10 +7729,9 @@ class basic_json
// remember this number was parsed (for later serialization) // remember this number was parsed (for later serialization)
result.m_type.bits.parsed = true; result.m_type.bits.parsed = true;
// 'found_radix_point' will be set to 0xFF upon finding a radix // 'found_radix_point' will be set to true upon finding a radix
// point and later used to mask in/out the precision depending // point. if it is not found, then the precision will be updated
// whether a radix is found i.e. 'precision &= found_radix_point' bool found_radix_point = false;
uint8_t found_radix_point = 0;
uint8_t precision = 0; uint8_t precision = 0;
// accumulate the integer conversion result (unsigned for now) // accumulate the integer conversion result (unsigned for now)
@ -7773,7 +7769,7 @@ class basic_json
// reset precision count // reset precision count
precision = 0; precision = 0;
found_radix_point = 0xFF; found_radix_point = true;
continue; continue;
} }
// assume exponent (if not then will fail parse): change to // assume exponent (if not then will fail parse): change to
@ -7811,8 +7807,21 @@ class basic_json
} }
// If no radix point was found then precision would now be set to // If no radix point was found then precision would now be set to
// the number of digits, which is wrong - clear it. // the number of digits, which is wrong - decrement it to sig figs - 1
result.m_type.bits.precision = precision & found_radix_point; if(not found_radix_point)
{
int trailing_zeros = 0;
for (int j = precision-1;j>=0;--j)
{
auto c = *(m_start+j);
if(c == '0')
++trailing_zeros;
else if((c > '0' and c <= '9') or c == '-')
break;
}
precision -= (trailing_zeros + 1);
}
result.m_type.bits.precision = precision;
// save the value (if not a float) // save the value (if not a float)
if (type == value_t::number_unsigned) if (type == value_t::number_unsigned)

View File

@ -13951,7 +13951,9 @@ TEST_CASE("regression tests")
json j2a = 2342e-2; json j2a = 2342e-2;
//issue #230 //issue #230
//json j2b = json::parse("2342e-2"); json j2b = json::parse("2342e-2");
//diabolical version
json j2c = json::parse("234200e-4");
json j3a = 10E3; json j3a = 10E3;
json j3b = json::parse("10E3"); json j3b = json::parse("10E3");
@ -13975,7 +13977,8 @@ TEST_CASE("regression tests")
CHECK(j2a.dump() == "23.42"); CHECK(j2a.dump() == "23.42");
//issue #230 //issue #230
//CHECK(j2b.dump() == "23.42"); CHECK(j2b.dump() == "2.342e01");
CHECK(j2c.dump() == "2.342e01");
CHECK(j3a.dump() == "10000"); CHECK(j3a.dump() == "10000");
CHECK(j3b.dump() == "1E04"); CHECK(j3b.dump() == "1E04");
@ -13992,6 +13995,7 @@ TEST_CASE("regression tests")
CHECK(dest == expected); CHECK(dest == expected);
} }
} }
// special test case to check if memory is leaked if constructor throws // special test case to check if memory is leaked if constructor throws