json 2.8.2 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +13 -0
- data/ext/json/ext/fbuffer/fbuffer.h +46 -16
- data/ext/json/ext/generator/generator.c +68 -40
- data/ext/json/ext/parser/extconf.rb +1 -1
- data/ext/json/ext/parser/parser.c +132 -132
- data/ext/json/ext/parser/parser.rl +16 -16
- data/lib/json/common.rb +38 -18
- data/lib/json/ext/generator/state.rb +11 -0
- data/lib/json/truffle_ruby/generator.rb +25 -17
- data/lib/json/version.rb +1 -1
- metadata +2 -2
@@ -28,19 +28,6 @@ static const char deprecated_create_additions_warning[] =
|
|
28
28
|
"and will be removed in 3.0, use JSON.unsafe_load or explicitly "
|
29
29
|
"pass `create_additions: true`";
|
30
30
|
|
31
|
-
#ifndef HAVE_RB_GC_MARK_LOCATIONS
|
32
|
-
// For TruffleRuby
|
33
|
-
void rb_gc_mark_locations(const VALUE *start, const VALUE *end)
|
34
|
-
{
|
35
|
-
VALUE *value = start;
|
36
|
-
|
37
|
-
while (value < end) {
|
38
|
-
rb_gc_mark(*value);
|
39
|
-
value++;
|
40
|
-
}
|
41
|
-
}
|
42
|
-
#endif
|
43
|
-
|
44
31
|
#ifndef HAVE_RB_HASH_BULK_INSERT
|
45
32
|
// For TruffleRuby
|
46
33
|
void rb_hash_bulk_insert(long count, const VALUE *pairs, VALUE hash)
|
@@ -266,7 +253,10 @@ static inline void rvalue_stack_pop(rvalue_stack *stack, long count)
|
|
266
253
|
static void rvalue_stack_mark(void *ptr)
|
267
254
|
{
|
268
255
|
rvalue_stack *stack = (rvalue_stack *)ptr;
|
269
|
-
|
256
|
+
long index;
|
257
|
+
for (index = 0; index < stack->head; index++) {
|
258
|
+
rb_gc_mark(stack->ptr[index]);
|
259
|
+
}
|
270
260
|
}
|
271
261
|
|
272
262
|
static void rvalue_stack_free(void *ptr)
|
@@ -427,6 +417,14 @@ static char *JSON_parse_number(JSON_Parser *json, char *p, char *pe, VALUE *resu
|
|
427
417
|
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
|
428
418
|
|
429
419
|
|
420
|
+
#ifndef HAVE_STRNLEN
|
421
|
+
static size_t strnlen(const char *s, size_t maxlen)
|
422
|
+
{
|
423
|
+
char *p;
|
424
|
+
return ((p = memchr(s, '\0', maxlen)) ? p - s : maxlen);
|
425
|
+
}
|
426
|
+
#endif
|
427
|
+
|
430
428
|
#define PARSE_ERROR_FRAGMENT_LEN 32
|
431
429
|
#ifdef RBIMPL_ATTR_NORETURN
|
432
430
|
RBIMPL_ATTR_NORETURN()
|
@@ -449,11 +447,11 @@ static void raise_parse_error(const char *format, const char *start)
|
|
449
447
|
|
450
448
|
|
451
449
|
|
452
|
-
#line
|
450
|
+
#line 473 "parser.rl"
|
453
451
|
|
454
452
|
|
455
453
|
|
456
|
-
#line
|
454
|
+
#line 455 "parser.c"
|
457
455
|
enum {JSON_object_start = 1};
|
458
456
|
enum {JSON_object_first_final = 32};
|
459
457
|
enum {JSON_object_error = 0};
|
@@ -461,7 +459,7 @@ enum {JSON_object_error = 0};
|
|
461
459
|
enum {JSON_object_en_main = 1};
|
462
460
|
|
463
461
|
|
464
|
-
#line
|
462
|
+
#line 513 "parser.rl"
|
465
463
|
|
466
464
|
|
467
465
|
#define PUSH(result) rvalue_stack_push(json->stack, result, &json->stack_handle, &json->stack)
|
@@ -477,14 +475,14 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
|
|
477
475
|
long stack_head = json->stack->head;
|
478
476
|
|
479
477
|
|
480
|
-
#line
|
478
|
+
#line 479 "parser.c"
|
481
479
|
{
|
482
480
|
cs = JSON_object_start;
|
483
481
|
}
|
484
482
|
|
485
|
-
#line
|
483
|
+
#line 528 "parser.rl"
|
486
484
|
|
487
|
-
#line
|
485
|
+
#line 486 "parser.c"
|
488
486
|
{
|
489
487
|
short _widec;
|
490
488
|
if ( p == pe )
|
@@ -513,7 +511,7 @@ case 2:
|
|
513
511
|
goto st2;
|
514
512
|
goto st0;
|
515
513
|
tr2:
|
516
|
-
#line
|
514
|
+
#line 492 "parser.rl"
|
517
515
|
{
|
518
516
|
char *np;
|
519
517
|
json->parsing_name = true;
|
@@ -529,7 +527,7 @@ st3:
|
|
529
527
|
if ( ++p == pe )
|
530
528
|
goto _test_eof3;
|
531
529
|
case 3:
|
532
|
-
#line
|
530
|
+
#line 531 "parser.c"
|
533
531
|
switch( (*p) ) {
|
534
532
|
case 13: goto st3;
|
535
533
|
case 32: goto st3;
|
@@ -596,7 +594,7 @@ case 8:
|
|
596
594
|
goto st8;
|
597
595
|
goto st0;
|
598
596
|
tr11:
|
599
|
-
#line
|
597
|
+
#line 481 "parser.rl"
|
600
598
|
{
|
601
599
|
char *np = JSON_parse_value(json, p, pe, result, current_nesting);
|
602
600
|
if (np == NULL) {
|
@@ -610,20 +608,20 @@ st9:
|
|
610
608
|
if ( ++p == pe )
|
611
609
|
goto _test_eof9;
|
612
610
|
case 9:
|
613
|
-
#line
|
611
|
+
#line 612 "parser.c"
|
614
612
|
_widec = (*p);
|
615
613
|
if ( (*p) < 13 ) {
|
616
614
|
if ( (*p) > 9 ) {
|
617
615
|
if ( 10 <= (*p) && (*p) <= 10 ) {
|
618
616
|
_widec = (short)(128 + ((*p) - -128));
|
619
617
|
if (
|
620
|
-
#line
|
618
|
+
#line 490 "parser.rl"
|
621
619
|
json->allow_trailing_comma ) _widec += 256;
|
622
620
|
}
|
623
621
|
} else if ( (*p) >= 9 ) {
|
624
622
|
_widec = (short)(128 + ((*p) - -128));
|
625
623
|
if (
|
626
|
-
#line
|
624
|
+
#line 490 "parser.rl"
|
627
625
|
json->allow_trailing_comma ) _widec += 256;
|
628
626
|
}
|
629
627
|
} else if ( (*p) > 13 ) {
|
@@ -631,26 +629,26 @@ case 9:
|
|
631
629
|
if ( 32 <= (*p) && (*p) <= 32 ) {
|
632
630
|
_widec = (short)(128 + ((*p) - -128));
|
633
631
|
if (
|
634
|
-
#line
|
632
|
+
#line 490 "parser.rl"
|
635
633
|
json->allow_trailing_comma ) _widec += 256;
|
636
634
|
}
|
637
635
|
} else if ( (*p) > 44 ) {
|
638
636
|
if ( 47 <= (*p) && (*p) <= 47 ) {
|
639
637
|
_widec = (short)(128 + ((*p) - -128));
|
640
638
|
if (
|
641
|
-
#line
|
639
|
+
#line 490 "parser.rl"
|
642
640
|
json->allow_trailing_comma ) _widec += 256;
|
643
641
|
}
|
644
642
|
} else {
|
645
643
|
_widec = (short)(128 + ((*p) - -128));
|
646
644
|
if (
|
647
|
-
#line
|
645
|
+
#line 490 "parser.rl"
|
648
646
|
json->allow_trailing_comma ) _widec += 256;
|
649
647
|
}
|
650
648
|
} else {
|
651
649
|
_widec = (short)(128 + ((*p) - -128));
|
652
650
|
if (
|
653
|
-
#line
|
651
|
+
#line 490 "parser.rl"
|
654
652
|
json->allow_trailing_comma ) _widec += 256;
|
655
653
|
}
|
656
654
|
switch( _widec ) {
|
@@ -671,14 +669,14 @@ case 9:
|
|
671
669
|
goto st10;
|
672
670
|
goto st0;
|
673
671
|
tr4:
|
674
|
-
#line
|
672
|
+
#line 503 "parser.rl"
|
675
673
|
{ p--; {p++; cs = 32; goto _out;} }
|
676
674
|
goto st32;
|
677
675
|
st32:
|
678
676
|
if ( ++p == pe )
|
679
677
|
goto _test_eof32;
|
680
678
|
case 32:
|
681
|
-
#line
|
679
|
+
#line 680 "parser.c"
|
682
680
|
goto st0;
|
683
681
|
st10:
|
684
682
|
if ( ++p == pe )
|
@@ -780,13 +778,13 @@ case 20:
|
|
780
778
|
if ( 47 <= (*p) && (*p) <= 47 ) {
|
781
779
|
_widec = (short)(128 + ((*p) - -128));
|
782
780
|
if (
|
783
|
-
#line
|
781
|
+
#line 490 "parser.rl"
|
784
782
|
json->allow_trailing_comma ) _widec += 256;
|
785
783
|
}
|
786
784
|
} else if ( (*p) >= 42 ) {
|
787
785
|
_widec = (short)(128 + ((*p) - -128));
|
788
786
|
if (
|
789
|
-
#line
|
787
|
+
#line 490 "parser.rl"
|
790
788
|
json->allow_trailing_comma ) _widec += 256;
|
791
789
|
}
|
792
790
|
switch( _widec ) {
|
@@ -805,20 +803,20 @@ case 21:
|
|
805
803
|
if ( (*p) <= 41 ) {
|
806
804
|
_widec = (short)(128 + ((*p) - -128));
|
807
805
|
if (
|
808
|
-
#line
|
806
|
+
#line 490 "parser.rl"
|
809
807
|
json->allow_trailing_comma ) _widec += 256;
|
810
808
|
}
|
811
809
|
} else if ( (*p) > 42 ) {
|
812
810
|
if ( 43 <= (*p) )
|
813
811
|
{ _widec = (short)(128 + ((*p) - -128));
|
814
812
|
if (
|
815
|
-
#line
|
813
|
+
#line 490 "parser.rl"
|
816
814
|
json->allow_trailing_comma ) _widec += 256;
|
817
815
|
}
|
818
816
|
} else {
|
819
817
|
_widec = (short)(128 + ((*p) - -128));
|
820
818
|
if (
|
821
|
-
#line
|
819
|
+
#line 490 "parser.rl"
|
822
820
|
json->allow_trailing_comma ) _widec += 256;
|
823
821
|
}
|
824
822
|
switch( _widec ) {
|
@@ -841,13 +839,13 @@ case 22:
|
|
841
839
|
if ( 42 <= (*p) && (*p) <= 42 ) {
|
842
840
|
_widec = (short)(128 + ((*p) - -128));
|
843
841
|
if (
|
844
|
-
#line
|
842
|
+
#line 490 "parser.rl"
|
845
843
|
json->allow_trailing_comma ) _widec += 256;
|
846
844
|
}
|
847
845
|
} else {
|
848
846
|
_widec = (short)(128 + ((*p) - -128));
|
849
847
|
if (
|
850
|
-
#line
|
848
|
+
#line 490 "parser.rl"
|
851
849
|
json->allow_trailing_comma ) _widec += 256;
|
852
850
|
}
|
853
851
|
} else if ( (*p) > 46 ) {
|
@@ -855,19 +853,19 @@ case 22:
|
|
855
853
|
if ( 48 <= (*p) )
|
856
854
|
{ _widec = (short)(128 + ((*p) - -128));
|
857
855
|
if (
|
858
|
-
#line
|
856
|
+
#line 490 "parser.rl"
|
859
857
|
json->allow_trailing_comma ) _widec += 256;
|
860
858
|
}
|
861
859
|
} else if ( (*p) >= 47 ) {
|
862
860
|
_widec = (short)(128 + ((*p) - -128));
|
863
861
|
if (
|
864
|
-
#line
|
862
|
+
#line 490 "parser.rl"
|
865
863
|
json->allow_trailing_comma ) _widec += 256;
|
866
864
|
}
|
867
865
|
} else {
|
868
866
|
_widec = (short)(128 + ((*p) - -128));
|
869
867
|
if (
|
870
|
-
#line
|
868
|
+
#line 490 "parser.rl"
|
871
869
|
json->allow_trailing_comma ) _widec += 256;
|
872
870
|
}
|
873
871
|
switch( _widec ) {
|
@@ -891,20 +889,20 @@ case 23:
|
|
891
889
|
if ( (*p) <= 9 ) {
|
892
890
|
_widec = (short)(128 + ((*p) - -128));
|
893
891
|
if (
|
894
|
-
#line
|
892
|
+
#line 490 "parser.rl"
|
895
893
|
json->allow_trailing_comma ) _widec += 256;
|
896
894
|
}
|
897
895
|
} else if ( (*p) > 10 ) {
|
898
896
|
if ( 11 <= (*p) )
|
899
897
|
{ _widec = (short)(128 + ((*p) - -128));
|
900
898
|
if (
|
901
|
-
#line
|
899
|
+
#line 490 "parser.rl"
|
902
900
|
json->allow_trailing_comma ) _widec += 256;
|
903
901
|
}
|
904
902
|
} else {
|
905
903
|
_widec = (short)(128 + ((*p) - -128));
|
906
904
|
if (
|
907
|
-
#line
|
905
|
+
#line 490 "parser.rl"
|
908
906
|
json->allow_trailing_comma ) _widec += 256;
|
909
907
|
}
|
910
908
|
switch( _widec ) {
|
@@ -1018,7 +1016,7 @@ case 31:
|
|
1018
1016
|
_out: {}
|
1019
1017
|
}
|
1020
1018
|
|
1021
|
-
#line
|
1019
|
+
#line 529 "parser.rl"
|
1022
1020
|
|
1023
1021
|
if (cs >= JSON_object_first_final) {
|
1024
1022
|
long count = json->stack->head - stack_head;
|
@@ -1069,7 +1067,7 @@ case 31:
|
|
1069
1067
|
}
|
1070
1068
|
|
1071
1069
|
|
1072
|
-
#line
|
1070
|
+
#line 1071 "parser.c"
|
1073
1071
|
enum {JSON_value_start = 1};
|
1074
1072
|
enum {JSON_value_first_final = 29};
|
1075
1073
|
enum {JSON_value_error = 0};
|
@@ -1077,7 +1075,7 @@ enum {JSON_value_error = 0};
|
|
1077
1075
|
enum {JSON_value_en_main = 1};
|
1078
1076
|
|
1079
1077
|
|
1080
|
-
#line
|
1078
|
+
#line 662 "parser.rl"
|
1081
1079
|
|
1082
1080
|
|
1083
1081
|
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
|
@@ -1085,14 +1083,14 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
1085
1083
|
int cs = EVIL;
|
1086
1084
|
|
1087
1085
|
|
1088
|
-
#line
|
1086
|
+
#line 1087 "parser.c"
|
1089
1087
|
{
|
1090
1088
|
cs = JSON_value_start;
|
1091
1089
|
}
|
1092
1090
|
|
1093
|
-
#line
|
1091
|
+
#line 669 "parser.rl"
|
1094
1092
|
|
1095
|
-
#line
|
1093
|
+
#line 1094 "parser.c"
|
1096
1094
|
{
|
1097
1095
|
if ( p == pe )
|
1098
1096
|
goto _test_eof;
|
@@ -1126,7 +1124,7 @@ st0:
|
|
1126
1124
|
cs = 0;
|
1127
1125
|
goto _out;
|
1128
1126
|
tr2:
|
1129
|
-
#line
|
1127
|
+
#line 607 "parser.rl"
|
1130
1128
|
{
|
1131
1129
|
char *np = JSON_parse_string(json, p, pe, result);
|
1132
1130
|
if (np == NULL) {
|
@@ -1138,7 +1136,7 @@ tr2:
|
|
1138
1136
|
}
|
1139
1137
|
goto st29;
|
1140
1138
|
tr3:
|
1141
|
-
#line
|
1139
|
+
#line 617 "parser.rl"
|
1142
1140
|
{
|
1143
1141
|
char *np;
|
1144
1142
|
if(pe > p + 8 && !strncmp(MinusInfinity, p, 9)) {
|
@@ -1158,7 +1156,7 @@ tr3:
|
|
1158
1156
|
}
|
1159
1157
|
goto st29;
|
1160
1158
|
tr7:
|
1161
|
-
#line
|
1159
|
+
#line 635 "parser.rl"
|
1162
1160
|
{
|
1163
1161
|
char *np;
|
1164
1162
|
json->in_array++;
|
@@ -1168,7 +1166,7 @@ tr7:
|
|
1168
1166
|
}
|
1169
1167
|
goto st29;
|
1170
1168
|
tr11:
|
1171
|
-
#line
|
1169
|
+
#line 643 "parser.rl"
|
1172
1170
|
{
|
1173
1171
|
char *np;
|
1174
1172
|
np = JSON_parse_object(json, p, pe, result, current_nesting + 1);
|
@@ -1176,7 +1174,7 @@ tr11:
|
|
1176
1174
|
}
|
1177
1175
|
goto st29;
|
1178
1176
|
tr25:
|
1179
|
-
#line
|
1177
|
+
#line 600 "parser.rl"
|
1180
1178
|
{
|
1181
1179
|
if (json->allow_nan) {
|
1182
1180
|
*result = CInfinity;
|
@@ -1186,7 +1184,7 @@ tr25:
|
|
1186
1184
|
}
|
1187
1185
|
goto st29;
|
1188
1186
|
tr27:
|
1189
|
-
#line
|
1187
|
+
#line 593 "parser.rl"
|
1190
1188
|
{
|
1191
1189
|
if (json->allow_nan) {
|
1192
1190
|
*result = CNaN;
|
@@ -1196,19 +1194,19 @@ tr27:
|
|
1196
1194
|
}
|
1197
1195
|
goto st29;
|
1198
1196
|
tr31:
|
1199
|
-
#line
|
1197
|
+
#line 587 "parser.rl"
|
1200
1198
|
{
|
1201
1199
|
*result = Qfalse;
|
1202
1200
|
}
|
1203
1201
|
goto st29;
|
1204
1202
|
tr34:
|
1205
|
-
#line
|
1203
|
+
#line 584 "parser.rl"
|
1206
1204
|
{
|
1207
1205
|
*result = Qnil;
|
1208
1206
|
}
|
1209
1207
|
goto st29;
|
1210
1208
|
tr37:
|
1211
|
-
#line
|
1209
|
+
#line 590 "parser.rl"
|
1212
1210
|
{
|
1213
1211
|
*result = Qtrue;
|
1214
1212
|
}
|
@@ -1217,9 +1215,9 @@ st29:
|
|
1217
1215
|
if ( ++p == pe )
|
1218
1216
|
goto _test_eof29;
|
1219
1217
|
case 29:
|
1220
|
-
#line
|
1218
|
+
#line 649 "parser.rl"
|
1221
1219
|
{ p--; {p++; cs = 29; goto _out;} }
|
1222
|
-
#line
|
1220
|
+
#line 1221 "parser.c"
|
1223
1221
|
switch( (*p) ) {
|
1224
1222
|
case 13: goto st29;
|
1225
1223
|
case 32: goto st29;
|
@@ -1460,7 +1458,7 @@ case 28:
|
|
1460
1458
|
_out: {}
|
1461
1459
|
}
|
1462
1460
|
|
1463
|
-
#line
|
1461
|
+
#line 670 "parser.rl"
|
1464
1462
|
|
1465
1463
|
if (json->freeze) {
|
1466
1464
|
OBJ_FREEZE(*result);
|
@@ -1475,7 +1473,7 @@ case 28:
|
|
1475
1473
|
}
|
1476
1474
|
|
1477
1475
|
|
1478
|
-
#line
|
1476
|
+
#line 1477 "parser.c"
|
1479
1477
|
enum {JSON_integer_start = 1};
|
1480
1478
|
enum {JSON_integer_first_final = 3};
|
1481
1479
|
enum {JSON_integer_error = 0};
|
@@ -1483,7 +1481,7 @@ enum {JSON_integer_error = 0};
|
|
1483
1481
|
enum {JSON_integer_en_main = 1};
|
1484
1482
|
|
1485
1483
|
|
1486
|
-
#line
|
1484
|
+
#line 691 "parser.rl"
|
1487
1485
|
|
1488
1486
|
|
1489
1487
|
#define MAX_FAST_INTEGER_SIZE 18
|
@@ -1523,7 +1521,7 @@ static char *JSON_decode_integer(JSON_Parser *json, char *p, VALUE *result)
|
|
1523
1521
|
}
|
1524
1522
|
|
1525
1523
|
|
1526
|
-
#line
|
1524
|
+
#line 1525 "parser.c"
|
1527
1525
|
enum {JSON_float_start = 1};
|
1528
1526
|
enum {JSON_float_first_final = 6};
|
1529
1527
|
enum {JSON_float_error = 0};
|
@@ -1531,7 +1529,7 @@ enum {JSON_float_error = 0};
|
|
1531
1529
|
enum {JSON_float_en_main = 1};
|
1532
1530
|
|
1533
1531
|
|
1534
|
-
#line
|
1532
|
+
#line 743 "parser.rl"
|
1535
1533
|
|
1536
1534
|
|
1537
1535
|
static char *JSON_parse_number(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
@@ -1540,15 +1538,15 @@ static char *JSON_parse_number(JSON_Parser *json, char *p, char *pe, VALUE *resu
|
|
1540
1538
|
bool is_float = false;
|
1541
1539
|
|
1542
1540
|
|
1543
|
-
#line
|
1541
|
+
#line 1542 "parser.c"
|
1544
1542
|
{
|
1545
1543
|
cs = JSON_float_start;
|
1546
1544
|
}
|
1547
1545
|
|
1548
|
-
#line
|
1546
|
+
#line 751 "parser.rl"
|
1549
1547
|
json->memo = p;
|
1550
1548
|
|
1551
|
-
#line
|
1549
|
+
#line 1550 "parser.c"
|
1552
1550
|
{
|
1553
1551
|
if ( p == pe )
|
1554
1552
|
goto _test_eof;
|
@@ -1588,24 +1586,24 @@ case 6:
|
|
1588
1586
|
goto st0;
|
1589
1587
|
goto tr7;
|
1590
1588
|
tr7:
|
1591
|
-
#line
|
1589
|
+
#line 735 "parser.rl"
|
1592
1590
|
{ p--; {p++; cs = 7; goto _out;} }
|
1593
1591
|
goto st7;
|
1594
1592
|
st7:
|
1595
1593
|
if ( ++p == pe )
|
1596
1594
|
goto _test_eof7;
|
1597
1595
|
case 7:
|
1598
|
-
#line
|
1596
|
+
#line 1597 "parser.c"
|
1599
1597
|
goto st0;
|
1600
1598
|
tr8:
|
1601
|
-
#line
|
1599
|
+
#line 736 "parser.rl"
|
1602
1600
|
{ is_float = true; }
|
1603
1601
|
goto st3;
|
1604
1602
|
st3:
|
1605
1603
|
if ( ++p == pe )
|
1606
1604
|
goto _test_eof3;
|
1607
1605
|
case 3:
|
1608
|
-
#line
|
1606
|
+
#line 1607 "parser.c"
|
1609
1607
|
if ( 48 <= (*p) && (*p) <= 57 )
|
1610
1608
|
goto st8;
|
1611
1609
|
goto st0;
|
@@ -1624,14 +1622,14 @@ case 8:
|
|
1624
1622
|
goto st0;
|
1625
1623
|
goto tr7;
|
1626
1624
|
tr9:
|
1627
|
-
#line
|
1625
|
+
#line 736 "parser.rl"
|
1628
1626
|
{ is_float = true; }
|
1629
1627
|
goto st4;
|
1630
1628
|
st4:
|
1631
1629
|
if ( ++p == pe )
|
1632
1630
|
goto _test_eof4;
|
1633
1631
|
case 4:
|
1634
|
-
#line
|
1632
|
+
#line 1633 "parser.c"
|
1635
1633
|
switch( (*p) ) {
|
1636
1634
|
case 43: goto st5;
|
1637
1635
|
case 45: goto st5;
|
@@ -1688,7 +1686,7 @@ case 10:
|
|
1688
1686
|
_out: {}
|
1689
1687
|
}
|
1690
1688
|
|
1691
|
-
#line
|
1689
|
+
#line 753 "parser.rl"
|
1692
1690
|
|
1693
1691
|
if (cs >= JSON_float_first_final) {
|
1694
1692
|
if (!is_float) {
|
@@ -1744,7 +1742,7 @@ case 10:
|
|
1744
1742
|
|
1745
1743
|
|
1746
1744
|
|
1747
|
-
#line
|
1745
|
+
#line 1746 "parser.c"
|
1748
1746
|
enum {JSON_array_start = 1};
|
1749
1747
|
enum {JSON_array_first_final = 22};
|
1750
1748
|
enum {JSON_array_error = 0};
|
@@ -1752,7 +1750,7 @@ enum {JSON_array_error = 0};
|
|
1752
1750
|
enum {JSON_array_en_main = 1};
|
1753
1751
|
|
1754
1752
|
|
1755
|
-
#line
|
1753
|
+
#line 833 "parser.rl"
|
1756
1754
|
|
1757
1755
|
|
1758
1756
|
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
|
@@ -1765,14 +1763,14 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
1765
1763
|
long stack_head = json->stack->head;
|
1766
1764
|
|
1767
1765
|
|
1768
|
-
#line
|
1766
|
+
#line 1767 "parser.c"
|
1769
1767
|
{
|
1770
1768
|
cs = JSON_array_start;
|
1771
1769
|
}
|
1772
1770
|
|
1773
|
-
#line
|
1771
|
+
#line 845 "parser.rl"
|
1774
1772
|
|
1775
|
-
#line
|
1773
|
+
#line 1774 "parser.c"
|
1776
1774
|
{
|
1777
1775
|
short _widec;
|
1778
1776
|
if ( p == pe )
|
@@ -1812,7 +1810,7 @@ case 2:
|
|
1812
1810
|
goto st2;
|
1813
1811
|
goto st0;
|
1814
1812
|
tr2:
|
1815
|
-
#line
|
1813
|
+
#line 813 "parser.rl"
|
1816
1814
|
{
|
1817
1815
|
VALUE v = Qnil;
|
1818
1816
|
char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
|
@@ -1827,12 +1825,12 @@ st3:
|
|
1827
1825
|
if ( ++p == pe )
|
1828
1826
|
goto _test_eof3;
|
1829
1827
|
case 3:
|
1830
|
-
#line
|
1828
|
+
#line 1829 "parser.c"
|
1831
1829
|
_widec = (*p);
|
1832
1830
|
if ( 44 <= (*p) && (*p) <= 44 ) {
|
1833
1831
|
_widec = (short)(128 + ((*p) - -128));
|
1834
1832
|
if (
|
1835
|
-
#line
|
1833
|
+
#line 823 "parser.rl"
|
1836
1834
|
json->allow_trailing_comma ) _widec += 256;
|
1837
1835
|
}
|
1838
1836
|
switch( _widec ) {
|
@@ -1879,14 +1877,14 @@ case 7:
|
|
1879
1877
|
goto st3;
|
1880
1878
|
goto st7;
|
1881
1879
|
tr4:
|
1882
|
-
#line
|
1880
|
+
#line 825 "parser.rl"
|
1883
1881
|
{ p--; {p++; cs = 22; goto _out;} }
|
1884
1882
|
goto st22;
|
1885
1883
|
st22:
|
1886
1884
|
if ( ++p == pe )
|
1887
1885
|
goto _test_eof22;
|
1888
1886
|
case 22:
|
1889
|
-
#line
|
1887
|
+
#line 1888 "parser.c"
|
1890
1888
|
goto st0;
|
1891
1889
|
st8:
|
1892
1890
|
if ( ++p == pe )
|
@@ -1954,13 +1952,13 @@ case 13:
|
|
1954
1952
|
if ( 10 <= (*p) && (*p) <= 10 ) {
|
1955
1953
|
_widec = (short)(128 + ((*p) - -128));
|
1956
1954
|
if (
|
1957
|
-
#line
|
1955
|
+
#line 823 "parser.rl"
|
1958
1956
|
json->allow_trailing_comma ) _widec += 256;
|
1959
1957
|
}
|
1960
1958
|
} else if ( (*p) >= 9 ) {
|
1961
1959
|
_widec = (short)(128 + ((*p) - -128));
|
1962
1960
|
if (
|
1963
|
-
#line
|
1961
|
+
#line 823 "parser.rl"
|
1964
1962
|
json->allow_trailing_comma ) _widec += 256;
|
1965
1963
|
}
|
1966
1964
|
} else if ( (*p) > 13 ) {
|
@@ -1968,19 +1966,19 @@ case 13:
|
|
1968
1966
|
if ( 47 <= (*p) && (*p) <= 47 ) {
|
1969
1967
|
_widec = (short)(128 + ((*p) - -128));
|
1970
1968
|
if (
|
1971
|
-
#line
|
1969
|
+
#line 823 "parser.rl"
|
1972
1970
|
json->allow_trailing_comma ) _widec += 256;
|
1973
1971
|
}
|
1974
1972
|
} else if ( (*p) >= 32 ) {
|
1975
1973
|
_widec = (short)(128 + ((*p) - -128));
|
1976
1974
|
if (
|
1977
|
-
#line
|
1975
|
+
#line 823 "parser.rl"
|
1978
1976
|
json->allow_trailing_comma ) _widec += 256;
|
1979
1977
|
}
|
1980
1978
|
} else {
|
1981
1979
|
_widec = (short)(128 + ((*p) - -128));
|
1982
1980
|
if (
|
1983
|
-
#line
|
1981
|
+
#line 823 "parser.rl"
|
1984
1982
|
json->allow_trailing_comma ) _widec += 256;
|
1985
1983
|
}
|
1986
1984
|
switch( _widec ) {
|
@@ -2019,13 +2017,13 @@ case 14:
|
|
2019
2017
|
if ( 47 <= (*p) && (*p) <= 47 ) {
|
2020
2018
|
_widec = (short)(128 + ((*p) - -128));
|
2021
2019
|
if (
|
2022
|
-
#line
|
2020
|
+
#line 823 "parser.rl"
|
2023
2021
|
json->allow_trailing_comma ) _widec += 256;
|
2024
2022
|
}
|
2025
2023
|
} else if ( (*p) >= 42 ) {
|
2026
2024
|
_widec = (short)(128 + ((*p) - -128));
|
2027
2025
|
if (
|
2028
|
-
#line
|
2026
|
+
#line 823 "parser.rl"
|
2029
2027
|
json->allow_trailing_comma ) _widec += 256;
|
2030
2028
|
}
|
2031
2029
|
switch( _widec ) {
|
@@ -2044,20 +2042,20 @@ case 15:
|
|
2044
2042
|
if ( (*p) <= 41 ) {
|
2045
2043
|
_widec = (short)(128 + ((*p) - -128));
|
2046
2044
|
if (
|
2047
|
-
#line
|
2045
|
+
#line 823 "parser.rl"
|
2048
2046
|
json->allow_trailing_comma ) _widec += 256;
|
2049
2047
|
}
|
2050
2048
|
} else if ( (*p) > 42 ) {
|
2051
2049
|
if ( 43 <= (*p) )
|
2052
2050
|
{ _widec = (short)(128 + ((*p) - -128));
|
2053
2051
|
if (
|
2054
|
-
#line
|
2052
|
+
#line 823 "parser.rl"
|
2055
2053
|
json->allow_trailing_comma ) _widec += 256;
|
2056
2054
|
}
|
2057
2055
|
} else {
|
2058
2056
|
_widec = (short)(128 + ((*p) - -128));
|
2059
2057
|
if (
|
2060
|
-
#line
|
2058
|
+
#line 823 "parser.rl"
|
2061
2059
|
json->allow_trailing_comma ) _widec += 256;
|
2062
2060
|
}
|
2063
2061
|
switch( _widec ) {
|
@@ -2080,13 +2078,13 @@ case 16:
|
|
2080
2078
|
if ( 42 <= (*p) && (*p) <= 42 ) {
|
2081
2079
|
_widec = (short)(128 + ((*p) - -128));
|
2082
2080
|
if (
|
2083
|
-
#line
|
2081
|
+
#line 823 "parser.rl"
|
2084
2082
|
json->allow_trailing_comma ) _widec += 256;
|
2085
2083
|
}
|
2086
2084
|
} else {
|
2087
2085
|
_widec = (short)(128 + ((*p) - -128));
|
2088
2086
|
if (
|
2089
|
-
#line
|
2087
|
+
#line 823 "parser.rl"
|
2090
2088
|
json->allow_trailing_comma ) _widec += 256;
|
2091
2089
|
}
|
2092
2090
|
} else if ( (*p) > 46 ) {
|
@@ -2094,19 +2092,19 @@ case 16:
|
|
2094
2092
|
if ( 48 <= (*p) )
|
2095
2093
|
{ _widec = (short)(128 + ((*p) - -128));
|
2096
2094
|
if (
|
2097
|
-
#line
|
2095
|
+
#line 823 "parser.rl"
|
2098
2096
|
json->allow_trailing_comma ) _widec += 256;
|
2099
2097
|
}
|
2100
2098
|
} else if ( (*p) >= 47 ) {
|
2101
2099
|
_widec = (short)(128 + ((*p) - -128));
|
2102
2100
|
if (
|
2103
|
-
#line
|
2101
|
+
#line 823 "parser.rl"
|
2104
2102
|
json->allow_trailing_comma ) _widec += 256;
|
2105
2103
|
}
|
2106
2104
|
} else {
|
2107
2105
|
_widec = (short)(128 + ((*p) - -128));
|
2108
2106
|
if (
|
2109
|
-
#line
|
2107
|
+
#line 823 "parser.rl"
|
2110
2108
|
json->allow_trailing_comma ) _widec += 256;
|
2111
2109
|
}
|
2112
2110
|
switch( _widec ) {
|
@@ -2130,20 +2128,20 @@ case 17:
|
|
2130
2128
|
if ( (*p) <= 9 ) {
|
2131
2129
|
_widec = (short)(128 + ((*p) - -128));
|
2132
2130
|
if (
|
2133
|
-
#line
|
2131
|
+
#line 823 "parser.rl"
|
2134
2132
|
json->allow_trailing_comma ) _widec += 256;
|
2135
2133
|
}
|
2136
2134
|
} else if ( (*p) > 10 ) {
|
2137
2135
|
if ( 11 <= (*p) )
|
2138
2136
|
{ _widec = (short)(128 + ((*p) - -128));
|
2139
2137
|
if (
|
2140
|
-
#line
|
2138
|
+
#line 823 "parser.rl"
|
2141
2139
|
json->allow_trailing_comma ) _widec += 256;
|
2142
2140
|
}
|
2143
2141
|
} else {
|
2144
2142
|
_widec = (short)(128 + ((*p) - -128));
|
2145
2143
|
if (
|
2146
|
-
#line
|
2144
|
+
#line 823 "parser.rl"
|
2147
2145
|
json->allow_trailing_comma ) _widec += 256;
|
2148
2146
|
}
|
2149
2147
|
switch( _widec ) {
|
@@ -2215,7 +2213,7 @@ case 21:
|
|
2215
2213
|
_out: {}
|
2216
2214
|
}
|
2217
2215
|
|
2218
|
-
#line
|
2216
|
+
#line 846 "parser.rl"
|
2219
2217
|
|
2220
2218
|
if(cs >= JSON_array_first_final) {
|
2221
2219
|
long count = json->stack->head - stack_head;
|
@@ -2409,7 +2407,7 @@ static VALUE json_string_unescape(JSON_Parser *json, char *string, char *stringE
|
|
2409
2407
|
}
|
2410
2408
|
|
2411
2409
|
|
2412
|
-
#line
|
2410
|
+
#line 2411 "parser.c"
|
2413
2411
|
enum {JSON_string_start = 1};
|
2414
2412
|
enum {JSON_string_first_final = 9};
|
2415
2413
|
enum {JSON_string_error = 0};
|
@@ -2417,7 +2415,7 @@ enum {JSON_string_error = 0};
|
|
2417
2415
|
enum {JSON_string_en_main = 1};
|
2418
2416
|
|
2419
2417
|
|
2420
|
-
#line
|
2418
|
+
#line 1069 "parser.rl"
|
2421
2419
|
|
2422
2420
|
|
2423
2421
|
static int
|
@@ -2438,15 +2436,15 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
|
|
2438
2436
|
VALUE match_string;
|
2439
2437
|
|
2440
2438
|
|
2441
|
-
#line
|
2439
|
+
#line 2440 "parser.c"
|
2442
2440
|
{
|
2443
2441
|
cs = JSON_string_start;
|
2444
2442
|
}
|
2445
2443
|
|
2446
|
-
#line
|
2444
|
+
#line 1089 "parser.rl"
|
2447
2445
|
json->memo = p;
|
2448
2446
|
|
2449
|
-
#line
|
2447
|
+
#line 2448 "parser.c"
|
2450
2448
|
{
|
2451
2449
|
if ( p == pe )
|
2452
2450
|
goto _test_eof;
|
@@ -2471,14 +2469,14 @@ case 2:
|
|
2471
2469
|
goto st0;
|
2472
2470
|
goto st2;
|
2473
2471
|
tr2:
|
2474
|
-
#line
|
2472
|
+
#line 1051 "parser.rl"
|
2475
2473
|
{
|
2476
2474
|
*result = json_string_fastpath(json, json->memo + 1, p, json->parsing_name, json->parsing_name || json-> freeze, json->parsing_name && json->symbolize_names);
|
2477
2475
|
{p = (( p + 1))-1;}
|
2478
2476
|
p--;
|
2479
2477
|
{p++; cs = 9; goto _out;}
|
2480
2478
|
}
|
2481
|
-
#line
|
2479
|
+
#line 1044 "parser.rl"
|
2482
2480
|
{
|
2483
2481
|
*result = json_string_unescape(json, json->memo + 1, p, json->parsing_name, json->parsing_name || json-> freeze, json->parsing_name && json->symbolize_names);
|
2484
2482
|
{p = (( p + 1))-1;}
|
@@ -2487,7 +2485,7 @@ tr2:
|
|
2487
2485
|
}
|
2488
2486
|
goto st9;
|
2489
2487
|
tr6:
|
2490
|
-
#line
|
2488
|
+
#line 1044 "parser.rl"
|
2491
2489
|
{
|
2492
2490
|
*result = json_string_unescape(json, json->memo + 1, p, json->parsing_name, json->parsing_name || json-> freeze, json->parsing_name && json->symbolize_names);
|
2493
2491
|
{p = (( p + 1))-1;}
|
@@ -2499,7 +2497,7 @@ st9:
|
|
2499
2497
|
if ( ++p == pe )
|
2500
2498
|
goto _test_eof9;
|
2501
2499
|
case 9:
|
2502
|
-
#line
|
2500
|
+
#line 2501 "parser.c"
|
2503
2501
|
goto st0;
|
2504
2502
|
st3:
|
2505
2503
|
if ( ++p == pe )
|
@@ -2587,7 +2585,7 @@ case 8:
|
|
2587
2585
|
_out: {}
|
2588
2586
|
}
|
2589
2587
|
|
2590
|
-
#line
|
2588
|
+
#line 1091 "parser.rl"
|
2591
2589
|
|
2592
2590
|
if (json->create_additions && RTEST(match_string = json->match_string)) {
|
2593
2591
|
VALUE klass;
|
@@ -2740,7 +2738,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|
2740
2738
|
}
|
2741
2739
|
|
2742
2740
|
|
2743
|
-
#line
|
2741
|
+
#line 2742 "parser.c"
|
2744
2742
|
enum {JSON_start = 1};
|
2745
2743
|
enum {JSON_first_final = 10};
|
2746
2744
|
enum {JSON_error = 0};
|
@@ -2748,7 +2746,7 @@ enum {JSON_error = 0};
|
|
2748
2746
|
enum {JSON_en_main = 1};
|
2749
2747
|
|
2750
2748
|
|
2751
|
-
#line
|
2749
|
+
#line 1257 "parser.rl"
|
2752
2750
|
|
2753
2751
|
|
2754
2752
|
/*
|
@@ -2777,16 +2775,16 @@ static VALUE cParser_parse(VALUE self)
|
|
2777
2775
|
json->stack = &stack;
|
2778
2776
|
|
2779
2777
|
|
2780
|
-
#line
|
2778
|
+
#line 2779 "parser.c"
|
2781
2779
|
{
|
2782
2780
|
cs = JSON_start;
|
2783
2781
|
}
|
2784
2782
|
|
2785
|
-
#line
|
2783
|
+
#line 1285 "parser.rl"
|
2786
2784
|
p = json->source;
|
2787
2785
|
pe = p + json->len;
|
2788
2786
|
|
2789
|
-
#line
|
2787
|
+
#line 2788 "parser.c"
|
2790
2788
|
{
|
2791
2789
|
if ( p == pe )
|
2792
2790
|
goto _test_eof;
|
@@ -2820,7 +2818,7 @@ st0:
|
|
2820
2818
|
cs = 0;
|
2821
2819
|
goto _out;
|
2822
2820
|
tr2:
|
2823
|
-
#line
|
2821
|
+
#line 1249 "parser.rl"
|
2824
2822
|
{
|
2825
2823
|
char *np = JSON_parse_value(json, p, pe, &result, 0);
|
2826
2824
|
if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
|
@@ -2830,7 +2828,7 @@ st10:
|
|
2830
2828
|
if ( ++p == pe )
|
2831
2829
|
goto _test_eof10;
|
2832
2830
|
case 10:
|
2833
|
-
#line
|
2831
|
+
#line 2832 "parser.c"
|
2834
2832
|
switch( (*p) ) {
|
2835
2833
|
case 13: goto st10;
|
2836
2834
|
case 32: goto st10;
|
@@ -2919,7 +2917,7 @@ case 9:
|
|
2919
2917
|
_out: {}
|
2920
2918
|
}
|
2921
2919
|
|
2922
|
-
#line
|
2920
|
+
#line 1288 "parser.rl"
|
2923
2921
|
|
2924
2922
|
if (json->stack_handle) {
|
2925
2923
|
rvalue_stack_eagerly_release(json->stack_handle);
|
@@ -2955,16 +2953,16 @@ static VALUE cParser_m_parse(VALUE klass, VALUE source, VALUE opts)
|
|
2955
2953
|
json->stack = &stack;
|
2956
2954
|
|
2957
2955
|
|
2958
|
-
#line
|
2956
|
+
#line 2957 "parser.c"
|
2959
2957
|
{
|
2960
2958
|
cs = JSON_start;
|
2961
2959
|
}
|
2962
2960
|
|
2963
|
-
#line
|
2961
|
+
#line 1323 "parser.rl"
|
2964
2962
|
p = json->source;
|
2965
2963
|
pe = p + json->len;
|
2966
2964
|
|
2967
|
-
#line
|
2965
|
+
#line 2966 "parser.c"
|
2968
2966
|
{
|
2969
2967
|
if ( p == pe )
|
2970
2968
|
goto _test_eof;
|
@@ -2998,7 +2996,7 @@ st0:
|
|
2998
2996
|
cs = 0;
|
2999
2997
|
goto _out;
|
3000
2998
|
tr2:
|
3001
|
-
#line
|
2999
|
+
#line 1249 "parser.rl"
|
3002
3000
|
{
|
3003
3001
|
char *np = JSON_parse_value(json, p, pe, &result, 0);
|
3004
3002
|
if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
|
@@ -3008,7 +3006,7 @@ st10:
|
|
3008
3006
|
if ( ++p == pe )
|
3009
3007
|
goto _test_eof10;
|
3010
3008
|
case 10:
|
3011
|
-
#line
|
3009
|
+
#line 3010 "parser.c"
|
3012
3010
|
switch( (*p) ) {
|
3013
3011
|
case 13: goto st10;
|
3014
3012
|
case 32: goto st10;
|
@@ -3097,7 +3095,7 @@ case 9:
|
|
3097
3095
|
_out: {}
|
3098
3096
|
}
|
3099
3097
|
|
3100
|
-
#line
|
3098
|
+
#line 1326 "parser.rl"
|
3101
3099
|
|
3102
3100
|
if (json->stack_handle) {
|
3103
3101
|
rvalue_stack_eagerly_release(json->stack_handle);
|
@@ -3122,8 +3120,10 @@ static void JSON_mark(void *ptr)
|
|
3122
3120
|
rb_gc_mark(json->match_string);
|
3123
3121
|
rb_gc_mark(json->stack_handle);
|
3124
3122
|
|
3125
|
-
|
3126
|
-
|
3123
|
+
long index;
|
3124
|
+
for (index = 0; index < json->name_cache.length; index++) {
|
3125
|
+
rb_gc_mark(json->name_cache.entries[index]);
|
3126
|
+
}
|
3127
3127
|
}
|
3128
3128
|
|
3129
3129
|
static void JSON_free(void *ptr)
|