json 2.1.0 → 2.3.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.
@@ -1,4 +1,4 @@
1
-
1
+ /* This file is automatically generated from parser.rl by using ragel */
2
2
  #line 1 "parser.rl"
3
3
  #include "../fbuffer/fbuffer.h"
4
4
  #include "parser.h"
@@ -27,7 +27,7 @@ enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
27
27
 
28
28
  /* unicode */
29
29
 
30
- static const char digit_values[256] = {
30
+ static const signed char digit_values[256] = {
31
31
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
32
32
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
33
33
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
@@ -46,7 +46,7 @@ static const char digit_values[256] = {
46
46
 
47
47
  static UTF32 unescape_unicode(const unsigned char *p)
48
48
  {
49
- char b;
49
+ signed char b;
50
50
  UTF32 result = 0;
51
51
  b = digit_values[p[0]];
52
52
  if (b < 0) return UNI_REPLACEMENT_CHAR;
@@ -91,19 +91,20 @@ static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
91
91
 
92
92
  static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
93
93
  static VALUE CNaN, CInfinity, CMinusInfinity;
94
+ static VALUE cBigDecimal = Qundef;
94
95
 
95
96
  static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
96
97
  i_chr, i_max_nesting, i_allow_nan, i_symbolize_names,
97
98
  i_object_class, i_array_class, i_decimal_class, i_key_p,
98
99
  i_deep_const_get, i_match, i_match_string, i_aset, i_aref,
99
- i_leftshift, i_new;
100
+ i_leftshift, i_new, i_BigDecimal;
100
101
 
101
102
 
102
- #line 125 "parser.rl"
103
+ #line 126 "parser.rl"
103
104
 
104
105
 
105
106
 
106
- #line 107 "parser.c"
107
+ #line 108 "parser.c"
107
108
  enum {JSON_object_start = 1};
108
109
  enum {JSON_object_first_final = 27};
109
110
  enum {JSON_object_error = 0};
@@ -111,7 +112,7 @@ enum {JSON_object_error = 0};
111
112
  enum {JSON_object_en_main = 1};
112
113
 
113
114
 
114
- #line 166 "parser.rl"
115
+ #line 168 "parser.rl"
115
116
 
116
117
 
117
118
  static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -127,14 +128,14 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
127
128
  *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
128
129
 
129
130
 
130
- #line 131 "parser.c"
131
+ #line 132 "parser.c"
131
132
  {
132
133
  cs = JSON_object_start;
133
134
  }
134
135
 
135
- #line 181 "parser.rl"
136
+ #line 183 "parser.rl"
136
137
 
137
- #line 138 "parser.c"
138
+ #line 139 "parser.c"
138
139
  {
139
140
  if ( p == pe )
140
141
  goto _test_eof;
@@ -162,7 +163,7 @@ case 2:
162
163
  goto st2;
163
164
  goto st0;
164
165
  tr2:
165
- #line 148 "parser.rl"
166
+ #line 150 "parser.rl"
166
167
  {
167
168
  char *np;
168
169
  json->parsing_name = 1;
@@ -175,7 +176,7 @@ st3:
175
176
  if ( ++p == pe )
176
177
  goto _test_eof3;
177
178
  case 3:
178
- #line 179 "parser.c"
179
+ #line 180 "parser.c"
179
180
  switch( (*p) ) {
180
181
  case 13: goto st3;
181
182
  case 32: goto st3;
@@ -242,7 +243,7 @@ case 8:
242
243
  goto st8;
243
244
  goto st0;
244
245
  tr11:
245
- #line 133 "parser.rl"
246
+ #line 134 "parser.rl"
246
247
  {
247
248
  VALUE v = Qnil;
248
249
  char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
@@ -250,6 +251,7 @@ tr11:
250
251
  p--; {p++; cs = 9; goto _out;}
251
252
  } else {
252
253
  if (NIL_P(json->object_class)) {
254
+ OBJ_FREEZE(last_name);
253
255
  rb_hash_aset(*result, last_name, v);
254
256
  } else {
255
257
  rb_funcall(*result, i_aset, 2, last_name, v);
@@ -262,7 +264,7 @@ st9:
262
264
  if ( ++p == pe )
263
265
  goto _test_eof9;
264
266
  case 9:
265
- #line 266 "parser.c"
267
+ #line 268 "parser.c"
266
268
  switch( (*p) ) {
267
269
  case 13: goto st9;
268
270
  case 32: goto st9;
@@ -351,14 +353,14 @@ case 18:
351
353
  goto st9;
352
354
  goto st18;
353
355
  tr4:
354
- #line 156 "parser.rl"
356
+ #line 158 "parser.rl"
355
357
  { p--; {p++; cs = 27; goto _out;} }
356
358
  goto st27;
357
359
  st27:
358
360
  if ( ++p == pe )
359
361
  goto _test_eof27;
360
362
  case 27:
361
- #line 362 "parser.c"
363
+ #line 364 "parser.c"
362
364
  goto st0;
363
365
  st19:
364
366
  if ( ++p == pe )
@@ -456,7 +458,7 @@ case 26:
456
458
  _out: {}
457
459
  }
458
460
 
459
- #line 182 "parser.rl"
461
+ #line 184 "parser.rl"
460
462
 
461
463
  if (cs >= JSON_object_first_final) {
462
464
  if (json->create_additions) {
@@ -481,7 +483,7 @@ case 26:
481
483
 
482
484
 
483
485
 
484
- #line 485 "parser.c"
486
+ #line 487 "parser.c"
485
487
  enum {JSON_value_start = 1};
486
488
  enum {JSON_value_first_final = 29};
487
489
  enum {JSON_value_error = 0};
@@ -489,7 +491,7 @@ enum {JSON_value_error = 0};
489
491
  enum {JSON_value_en_main = 1};
490
492
 
491
493
 
492
- #line 282 "parser.rl"
494
+ #line 284 "parser.rl"
493
495
 
494
496
 
495
497
  static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -497,14 +499,14 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
497
499
  int cs = EVIL;
498
500
 
499
501
 
500
- #line 501 "parser.c"
502
+ #line 503 "parser.c"
501
503
  {
502
504
  cs = JSON_value_start;
503
505
  }
504
506
 
505
- #line 289 "parser.rl"
507
+ #line 291 "parser.rl"
506
508
 
507
- #line 508 "parser.c"
509
+ #line 510 "parser.c"
508
510
  {
509
511
  if ( p == pe )
510
512
  goto _test_eof;
@@ -538,14 +540,14 @@ st0:
538
540
  cs = 0;
539
541
  goto _out;
540
542
  tr2:
541
- #line 234 "parser.rl"
543
+ #line 236 "parser.rl"
542
544
  {
543
545
  char *np = JSON_parse_string(json, p, pe, result);
544
546
  if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;}
545
547
  }
546
548
  goto st29;
547
549
  tr3:
548
- #line 239 "parser.rl"
550
+ #line 241 "parser.rl"
549
551
  {
550
552
  char *np;
551
553
  if(pe > p + 8 && !strncmp(MinusInfinity, p, 9)) {
@@ -565,7 +567,7 @@ tr3:
565
567
  }
566
568
  goto st29;
567
569
  tr7:
568
- #line 257 "parser.rl"
570
+ #line 259 "parser.rl"
569
571
  {
570
572
  char *np;
571
573
  np = JSON_parse_array(json, p, pe, result, current_nesting + 1);
@@ -573,7 +575,7 @@ tr7:
573
575
  }
574
576
  goto st29;
575
577
  tr11:
576
- #line 263 "parser.rl"
578
+ #line 265 "parser.rl"
577
579
  {
578
580
  char *np;
579
581
  np = JSON_parse_object(json, p, pe, result, current_nesting + 1);
@@ -581,7 +583,7 @@ tr11:
581
583
  }
582
584
  goto st29;
583
585
  tr25:
584
- #line 227 "parser.rl"
586
+ #line 229 "parser.rl"
585
587
  {
586
588
  if (json->allow_nan) {
587
589
  *result = CInfinity;
@@ -591,7 +593,7 @@ tr25:
591
593
  }
592
594
  goto st29;
593
595
  tr27:
594
- #line 220 "parser.rl"
596
+ #line 222 "parser.rl"
595
597
  {
596
598
  if (json->allow_nan) {
597
599
  *result = CNaN;
@@ -601,19 +603,19 @@ tr27:
601
603
  }
602
604
  goto st29;
603
605
  tr31:
604
- #line 214 "parser.rl"
606
+ #line 216 "parser.rl"
605
607
  {
606
608
  *result = Qfalse;
607
609
  }
608
610
  goto st29;
609
611
  tr34:
610
- #line 211 "parser.rl"
612
+ #line 213 "parser.rl"
611
613
  {
612
614
  *result = Qnil;
613
615
  }
614
616
  goto st29;
615
617
  tr37:
616
- #line 217 "parser.rl"
618
+ #line 219 "parser.rl"
617
619
  {
618
620
  *result = Qtrue;
619
621
  }
@@ -622,9 +624,9 @@ st29:
622
624
  if ( ++p == pe )
623
625
  goto _test_eof29;
624
626
  case 29:
625
- #line 269 "parser.rl"
627
+ #line 271 "parser.rl"
626
628
  { p--; {p++; cs = 29; goto _out;} }
627
- #line 628 "parser.c"
629
+ #line 630 "parser.c"
628
630
  switch( (*p) ) {
629
631
  case 13: goto st29;
630
632
  case 32: goto st29;
@@ -865,7 +867,7 @@ case 28:
865
867
  _out: {}
866
868
  }
867
869
 
868
- #line 290 "parser.rl"
870
+ #line 292 "parser.rl"
869
871
 
870
872
  if (cs >= JSON_value_first_final) {
871
873
  return p;
@@ -875,7 +877,7 @@ case 28:
875
877
  }
876
878
 
877
879
 
878
- #line 879 "parser.c"
880
+ #line 881 "parser.c"
879
881
  enum {JSON_integer_start = 1};
880
882
  enum {JSON_integer_first_final = 3};
881
883
  enum {JSON_integer_error = 0};
@@ -883,7 +885,7 @@ enum {JSON_integer_error = 0};
883
885
  enum {JSON_integer_en_main = 1};
884
886
 
885
887
 
886
- #line 306 "parser.rl"
888
+ #line 308 "parser.rl"
887
889
 
888
890
 
889
891
  static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
@@ -891,15 +893,15 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
891
893
  int cs = EVIL;
892
894
 
893
895
 
894
- #line 895 "parser.c"
896
+ #line 897 "parser.c"
895
897
  {
896
898
  cs = JSON_integer_start;
897
899
  }
898
900
 
899
- #line 313 "parser.rl"
901
+ #line 315 "parser.rl"
900
902
  json->memo = p;
901
903
 
902
- #line 903 "parser.c"
904
+ #line 905 "parser.c"
903
905
  {
904
906
  if ( p == pe )
905
907
  goto _test_eof;
@@ -933,14 +935,14 @@ case 3:
933
935
  goto st0;
934
936
  goto tr4;
935
937
  tr4:
936
- #line 303 "parser.rl"
938
+ #line 305 "parser.rl"
937
939
  { p--; {p++; cs = 4; goto _out;} }
938
940
  goto st4;
939
941
  st4:
940
942
  if ( ++p == pe )
941
943
  goto _test_eof4;
942
944
  case 4:
943
- #line 944 "parser.c"
945
+ #line 946 "parser.c"
944
946
  goto st0;
945
947
  st5:
946
948
  if ( ++p == pe )
@@ -959,7 +961,7 @@ case 5:
959
961
  _out: {}
960
962
  }
961
963
 
962
- #line 315 "parser.rl"
964
+ #line 317 "parser.rl"
963
965
 
964
966
  if (cs >= JSON_integer_first_final) {
965
967
  long len = p - json->memo;
@@ -974,7 +976,7 @@ case 5:
974
976
  }
975
977
 
976
978
 
977
- #line 978 "parser.c"
979
+ #line 980 "parser.c"
978
980
  enum {JSON_float_start = 1};
979
981
  enum {JSON_float_first_final = 8};
980
982
  enum {JSON_float_error = 0};
@@ -982,23 +984,36 @@ enum {JSON_float_error = 0};
982
984
  enum {JSON_float_en_main = 1};
983
985
 
984
986
 
985
- #line 340 "parser.rl"
987
+ #line 342 "parser.rl"
986
988
 
987
989
 
990
+ static int is_bigdecimal_class(VALUE obj)
991
+ {
992
+ if (cBigDecimal == Qundef) {
993
+ if (rb_const_defined(rb_cObject, i_BigDecimal)) {
994
+ cBigDecimal = rb_const_get_at(rb_cObject, i_BigDecimal);
995
+ }
996
+ else {
997
+ return 0;
998
+ }
999
+ }
1000
+ return obj == cBigDecimal;
1001
+ }
1002
+
988
1003
  static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
989
1004
  {
990
1005
  int cs = EVIL;
991
1006
 
992
1007
 
993
- #line 994 "parser.c"
1008
+ #line 1009 "parser.c"
994
1009
  {
995
1010
  cs = JSON_float_start;
996
1011
  }
997
1012
 
998
- #line 347 "parser.rl"
1013
+ #line 362 "parser.rl"
999
1014
  json->memo = p;
1000
1015
 
1001
- #line 1002 "parser.c"
1016
+ #line 1017 "parser.c"
1002
1017
  {
1003
1018
  if ( p == pe )
1004
1019
  goto _test_eof;
@@ -1056,14 +1071,14 @@ case 8:
1056
1071
  goto st0;
1057
1072
  goto tr9;
1058
1073
  tr9:
1059
- #line 334 "parser.rl"
1074
+ #line 336 "parser.rl"
1060
1075
  { p--; {p++; cs = 9; goto _out;} }
1061
1076
  goto st9;
1062
1077
  st9:
1063
1078
  if ( ++p == pe )
1064
1079
  goto _test_eof9;
1065
1080
  case 9:
1066
- #line 1067 "parser.c"
1081
+ #line 1082 "parser.c"
1067
1082
  goto st0;
1068
1083
  st5:
1069
1084
  if ( ++p == pe )
@@ -1124,7 +1139,7 @@ case 7:
1124
1139
  _out: {}
1125
1140
  }
1126
1141
 
1127
- #line 349 "parser.rl"
1142
+ #line 364 "parser.rl"
1128
1143
 
1129
1144
  if (cs >= JSON_float_first_final) {
1130
1145
  long len = p - json->memo;
@@ -1136,7 +1151,11 @@ case 7:
1136
1151
  } else {
1137
1152
  VALUE text;
1138
1153
  text = rb_str_new2(FBUFFER_PTR(json->fbuffer));
1139
- *result = rb_funcall(json->decimal_class, i_new, 1, text);
1154
+ if (is_bigdecimal_class(json->decimal_class)) {
1155
+ *result = rb_funcall(Qnil, i_BigDecimal, 1, text);
1156
+ } else {
1157
+ *result = rb_funcall(json->decimal_class, i_new, 1, text);
1158
+ }
1140
1159
  }
1141
1160
  return p + 1;
1142
1161
  } else {
@@ -1146,7 +1165,7 @@ case 7:
1146
1165
 
1147
1166
 
1148
1167
 
1149
- #line 1150 "parser.c"
1168
+ #line 1169 "parser.c"
1150
1169
  enum {JSON_array_start = 1};
1151
1170
  enum {JSON_array_first_final = 17};
1152
1171
  enum {JSON_array_error = 0};
@@ -1154,7 +1173,7 @@ enum {JSON_array_error = 0};
1154
1173
  enum {JSON_array_en_main = 1};
1155
1174
 
1156
1175
 
1157
- #line 398 "parser.rl"
1176
+ #line 417 "parser.rl"
1158
1177
 
1159
1178
 
1160
1179
  static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -1168,14 +1187,14 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
1168
1187
  *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
1169
1188
 
1170
1189
 
1171
- #line 1172 "parser.c"
1190
+ #line 1191 "parser.c"
1172
1191
  {
1173
1192
  cs = JSON_array_start;
1174
1193
  }
1175
1194
 
1176
- #line 411 "parser.rl"
1195
+ #line 430 "parser.rl"
1177
1196
 
1178
- #line 1179 "parser.c"
1197
+ #line 1198 "parser.c"
1179
1198
  {
1180
1199
  if ( p == pe )
1181
1200
  goto _test_eof;
@@ -1214,7 +1233,7 @@ case 2:
1214
1233
  goto st2;
1215
1234
  goto st0;
1216
1235
  tr2:
1217
- #line 375 "parser.rl"
1236
+ #line 394 "parser.rl"
1218
1237
  {
1219
1238
  VALUE v = Qnil;
1220
1239
  char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
@@ -1234,7 +1253,7 @@ st3:
1234
1253
  if ( ++p == pe )
1235
1254
  goto _test_eof3;
1236
1255
  case 3:
1237
- #line 1238 "parser.c"
1256
+ #line 1257 "parser.c"
1238
1257
  switch( (*p) ) {
1239
1258
  case 13: goto st3;
1240
1259
  case 32: goto st3;
@@ -1334,14 +1353,14 @@ case 12:
1334
1353
  goto st3;
1335
1354
  goto st12;
1336
1355
  tr4:
1337
- #line 390 "parser.rl"
1356
+ #line 409 "parser.rl"
1338
1357
  { p--; {p++; cs = 17; goto _out;} }
1339
1358
  goto st17;
1340
1359
  st17:
1341
1360
  if ( ++p == pe )
1342
1361
  goto _test_eof17;
1343
1362
  case 17:
1344
- #line 1345 "parser.c"
1363
+ #line 1364 "parser.c"
1345
1364
  goto st0;
1346
1365
  st13:
1347
1366
  if ( ++p == pe )
@@ -1397,7 +1416,7 @@ case 16:
1397
1416
  _out: {}
1398
1417
  }
1399
1418
 
1400
- #line 412 "parser.rl"
1419
+ #line 431 "parser.rl"
1401
1420
 
1402
1421
  if(cs >= JSON_array_first_final) {
1403
1422
  return p + 1;
@@ -1486,7 +1505,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
1486
1505
  }
1487
1506
 
1488
1507
 
1489
- #line 1490 "parser.c"
1508
+ #line 1509 "parser.c"
1490
1509
  enum {JSON_string_start = 1};
1491
1510
  enum {JSON_string_first_final = 8};
1492
1511
  enum {JSON_string_error = 0};
@@ -1494,7 +1513,7 @@ enum {JSON_string_error = 0};
1494
1513
  enum {JSON_string_en_main = 1};
1495
1514
 
1496
1515
 
1497
- #line 519 "parser.rl"
1516
+ #line 538 "parser.rl"
1498
1517
 
1499
1518
 
1500
1519
  static int
@@ -1516,15 +1535,15 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
1516
1535
 
1517
1536
  *result = rb_str_buf_new(0);
1518
1537
 
1519
- #line 1520 "parser.c"
1538
+ #line 1539 "parser.c"
1520
1539
  {
1521
1540
  cs = JSON_string_start;
1522
1541
  }
1523
1542
 
1524
- #line 540 "parser.rl"
1543
+ #line 559 "parser.rl"
1525
1544
  json->memo = p;
1526
1545
 
1527
- #line 1528 "parser.c"
1546
+ #line 1547 "parser.c"
1528
1547
  {
1529
1548
  if ( p == pe )
1530
1549
  goto _test_eof;
@@ -1545,11 +1564,11 @@ case 2:
1545
1564
  case 34: goto tr2;
1546
1565
  case 92: goto st3;
1547
1566
  }
1548
- if ( 0 <= (*p) && (*p) <= 31 )
1567
+ if ( 0 <= (signed char)(*p) && (*p) <= 31 )
1549
1568
  goto st0;
1550
1569
  goto st2;
1551
1570
  tr2:
1552
- #line 505 "parser.rl"
1571
+ #line 524 "parser.rl"
1553
1572
  {
1554
1573
  *result = json_string_unescape(*result, json->memo + 1, p);
1555
1574
  if (NIL_P(*result)) {
@@ -1560,14 +1579,14 @@ tr2:
1560
1579
  {p = (( p + 1))-1;}
1561
1580
  }
1562
1581
  }
1563
- #line 516 "parser.rl"
1582
+ #line 535 "parser.rl"
1564
1583
  { p--; {p++; cs = 8; goto _out;} }
1565
1584
  goto st8;
1566
1585
  st8:
1567
1586
  if ( ++p == pe )
1568
1587
  goto _test_eof8;
1569
1588
  case 8:
1570
- #line 1571 "parser.c"
1589
+ #line 1590 "parser.c"
1571
1590
  goto st0;
1572
1591
  st3:
1573
1592
  if ( ++p == pe )
@@ -1575,7 +1594,7 @@ st3:
1575
1594
  case 3:
1576
1595
  if ( (*p) == 117 )
1577
1596
  goto st4;
1578
- if ( 0 <= (*p) && (*p) <= 31 )
1597
+ if ( 0 <= (signed char)(*p) && (*p) <= 31 )
1579
1598
  goto st0;
1580
1599
  goto st2;
1581
1600
  st4:
@@ -1643,7 +1662,7 @@ case 7:
1643
1662
  _out: {}
1644
1663
  }
1645
1664
 
1646
- #line 542 "parser.rl"
1665
+ #line 561 "parser.rl"
1647
1666
 
1648
1667
  if (json->create_additions && RTEST(match_string = json->match_string)) {
1649
1668
  VALUE klass;
@@ -1658,7 +1677,7 @@ case 7:
1658
1677
 
1659
1678
  if (json->symbolize_names && json->parsing_name) {
1660
1679
  *result = rb_str_intern(*result);
1661
- } else {
1680
+ } else if (RB_TYPE_P(*result, T_STRING)) {
1662
1681
  rb_str_resize(*result, RSTRING_LEN(*result));
1663
1682
  }
1664
1683
  if (cs >= JSON_string_first_final) {
@@ -1815,7 +1834,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
1815
1834
  } else {
1816
1835
  json->max_nesting = 100;
1817
1836
  json->allow_nan = 0;
1818
- json->create_additions = 1;
1837
+ json->create_additions = 0;
1819
1838
  json->create_id = rb_funcall(mJSON, i_create_id, 0);
1820
1839
  json->object_class = Qnil;
1821
1840
  json->array_class = Qnil;
@@ -1830,7 +1849,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
1830
1849
  }
1831
1850
 
1832
1851
 
1833
- #line 1834 "parser.c"
1852
+ #line 1853 "parser.c"
1834
1853
  enum {JSON_start = 1};
1835
1854
  enum {JSON_first_final = 10};
1836
1855
  enum {JSON_error = 0};
@@ -1838,7 +1857,7 @@ enum {JSON_error = 0};
1838
1857
  enum {JSON_en_main = 1};
1839
1858
 
1840
1859
 
1841
- #line 742 "parser.rl"
1860
+ #line 761 "parser.rl"
1842
1861
 
1843
1862
 
1844
1863
  /*
@@ -1855,16 +1874,16 @@ static VALUE cParser_parse(VALUE self)
1855
1874
  GET_PARSER;
1856
1875
 
1857
1876
 
1858
- #line 1859 "parser.c"
1877
+ #line 1878 "parser.c"
1859
1878
  {
1860
1879
  cs = JSON_start;
1861
1880
  }
1862
1881
 
1863
- #line 758 "parser.rl"
1882
+ #line 777 "parser.rl"
1864
1883
  p = json->source;
1865
1884
  pe = p + json->len;
1866
1885
 
1867
- #line 1868 "parser.c"
1886
+ #line 1887 "parser.c"
1868
1887
  {
1869
1888
  if ( p == pe )
1870
1889
  goto _test_eof;
@@ -1898,7 +1917,7 @@ st0:
1898
1917
  cs = 0;
1899
1918
  goto _out;
1900
1919
  tr2:
1901
- #line 734 "parser.rl"
1920
+ #line 753 "parser.rl"
1902
1921
  {
1903
1922
  char *np = JSON_parse_value(json, p, pe, &result, 0);
1904
1923
  if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
@@ -1908,7 +1927,7 @@ st10:
1908
1927
  if ( ++p == pe )
1909
1928
  goto _test_eof10;
1910
1929
  case 10:
1911
- #line 1912 "parser.c"
1930
+ #line 1931 "parser.c"
1912
1931
  switch( (*p) ) {
1913
1932
  case 13: goto st10;
1914
1933
  case 32: goto st10;
@@ -1997,7 +2016,7 @@ case 9:
1997
2016
  _out: {}
1998
2017
  }
1999
2018
 
2000
- #line 761 "parser.rl"
2019
+ #line 780 "parser.rl"
2001
2020
 
2002
2021
  if (cs >= JSON_first_final && p == pe) {
2003
2022
  return result;
@@ -2064,20 +2083,28 @@ static VALUE cParser_source(VALUE self)
2064
2083
 
2065
2084
  void Init_parser(void)
2066
2085
  {
2086
+ #undef rb_intern
2067
2087
  rb_require("json/common");
2068
2088
  mJSON = rb_define_module("JSON");
2069
2089
  mExt = rb_define_module_under(mJSON, "Ext");
2070
2090
  cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
2071
2091
  eParserError = rb_path2class("JSON::ParserError");
2072
2092
  eNestingError = rb_path2class("JSON::NestingError");
2093
+ rb_gc_register_mark_object(eParserError);
2094
+ rb_gc_register_mark_object(eNestingError);
2073
2095
  rb_define_alloc_func(cParser, cJSON_parser_s_allocate);
2074
2096
  rb_define_method(cParser, "initialize", cParser_initialize, -1);
2075
2097
  rb_define_method(cParser, "parse", cParser_parse, 0);
2076
2098
  rb_define_method(cParser, "source", cParser_source, 0);
2077
2099
 
2078
2100
  CNaN = rb_const_get(mJSON, rb_intern("NaN"));
2101
+ rb_gc_register_mark_object(CNaN);
2102
+
2079
2103
  CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
2104
+ rb_gc_register_mark_object(CInfinity);
2105
+
2080
2106
  CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
2107
+ rb_gc_register_mark_object(CMinusInfinity);
2081
2108
 
2082
2109
  i_json_creatable_p = rb_intern("json_creatable?");
2083
2110
  i_json_create = rb_intern("json_create");
@@ -2098,6 +2125,7 @@ void Init_parser(void)
2098
2125
  i_aref = rb_intern("[]");
2099
2126
  i_leftshift = rb_intern("<<");
2100
2127
  i_new = rb_intern("new");
2128
+ i_BigDecimal = rb_intern("BigDecimal");
2101
2129
  }
2102
2130
 
2103
2131
  /*