json 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of json might be problematic. Click here for more details.
- data/CHANGES +9 -0
- data/Rakefile +47 -53
- data/VERSION +1 -1
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +52 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +900 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +901 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +261 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +262 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +82 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +34 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +900 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +901 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +81 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +82 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +82 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +82 -0
- data/benchmarks/generator_benchmark.rb +162 -0
- data/benchmarks/parser_benchmark.rb +193 -0
- data/bin/edit_json.rb +0 -1
- data/bin/prettify_json.rb +0 -1
- data/doc-templates/main.txt +284 -0
- data/ext/json/ext/generator/extconf.rb +2 -0
- data/ext/json/ext/generator/generator.c +62 -18
- data/ext/json/ext/parser/extconf.rb +2 -0
- data/ext/json/ext/parser/parser.c +128 -81
- data/ext/json/ext/parser/parser.rl +31 -7
- data/ext/json/ext/parser/unicode.c +4 -4
- data/lib/json.rb +0 -221
- data/lib/json/add/core.rb +1 -1
- data/lib/json/editor.rb +11 -2
- data/lib/json/ext.rb +2 -0
- data/lib/json/pure.rb +2 -0
- data/lib/json/pure/generator.rb +77 -41
- data/lib/json/pure/parser.rb +6 -2
- data/lib/json/version.rb +1 -1
- data/tests/test_json.rb +7 -4
- data/tests/test_json_addition.rb +8 -5
- data/tests/test_json_fixtures.rb +6 -2
- data/tests/test_json_generate.rb +8 -2
- data/tests/test_json_rails.rb +30 -2
- data/tests/test_json_unicode.rb +8 -7
- data/tools/fuzz.rb +0 -1
- data/tools/server.rb +0 -1
- metadata +46 -9
- data/benchmarks/benchmark.txt +0 -133
- data/benchmarks/benchmark_generator.rb +0 -48
- data/benchmarks/benchmark_parser.rb +0 -26
- data/benchmarks/benchmark_rails.rb +0 -26
- data/tests/runner.rb +0 -25
@@ -1,11 +1,30 @@
|
|
1
|
+
|
1
2
|
#line 1 "parser.rl"
|
2
3
|
#include "ruby.h"
|
4
|
+
#include "unicode.h"
|
5
|
+
#if HAVE_RE_H
|
3
6
|
#include "re.h"
|
7
|
+
#endif
|
8
|
+
#if HAVE_RUBY_ST_H
|
9
|
+
#include "ruby/st.h"
|
10
|
+
#endif
|
11
|
+
#if HAVE_ST_H
|
4
12
|
#include "st.h"
|
5
|
-
#
|
13
|
+
#endif
|
6
14
|
|
7
15
|
#define EVIL 0x666
|
8
16
|
|
17
|
+
#ifndef RHASH_TBL
|
18
|
+
#define RHASH_TBL(hsh) (RHASH(hsh)->tbl)
|
19
|
+
#endif
|
20
|
+
|
21
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
22
|
+
#include "ruby/encoding.h"
|
23
|
+
#define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding())
|
24
|
+
#else
|
25
|
+
#define FORCE_UTF8(obj)
|
26
|
+
#endif
|
27
|
+
|
9
28
|
static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
|
10
29
|
static VALUE CNaN, CInfinity, CMinusInfinity;
|
11
30
|
|
@@ -36,18 +55,20 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
36
55
|
JSON_Parser *json; \
|
37
56
|
Data_Get_Struct(self, JSON_Parser, json);
|
38
57
|
|
39
|
-
#line 64 "parser.rl"
|
40
58
|
|
59
|
+
#line 82 "parser.rl"
|
41
60
|
|
42
61
|
|
43
|
-
|
62
|
+
|
63
|
+
#line 64 "parser.c"
|
44
64
|
static const int JSON_object_start = 1;
|
45
65
|
static const int JSON_object_first_final = 27;
|
46
66
|
static const int JSON_object_error = 0;
|
47
67
|
|
48
68
|
static const int JSON_object_en_main = 1;
|
49
69
|
|
50
|
-
|
70
|
+
|
71
|
+
#line 115 "parser.rl"
|
51
72
|
|
52
73
|
|
53
74
|
static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
@@ -62,13 +83,14 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
|
|
62
83
|
*result = rb_hash_new();
|
63
84
|
|
64
85
|
|
65
|
-
#line
|
86
|
+
#line 87 "parser.c"
|
66
87
|
{
|
67
88
|
cs = JSON_object_start;
|
68
89
|
}
|
69
|
-
|
90
|
+
|
91
|
+
#line 129 "parser.rl"
|
70
92
|
|
71
|
-
#line
|
93
|
+
#line 94 "parser.c"
|
72
94
|
{
|
73
95
|
if ( p == pe )
|
74
96
|
goto _test_eof;
|
@@ -96,7 +118,7 @@ case 2:
|
|
96
118
|
goto st2;
|
97
119
|
goto st0;
|
98
120
|
tr2:
|
99
|
-
#line
|
121
|
+
#line 101 "parser.rl"
|
100
122
|
{
|
101
123
|
char *np = JSON_parse_string(json, p, pe, &last_name);
|
102
124
|
if (np == NULL) { p--; {p++; cs = 3; goto _out;} } else {p = (( np))-1;}
|
@@ -106,7 +128,7 @@ st3:
|
|
106
128
|
if ( ++p == pe )
|
107
129
|
goto _test_eof3;
|
108
130
|
case 3:
|
109
|
-
#line
|
131
|
+
#line 132 "parser.c"
|
110
132
|
switch( (*p) ) {
|
111
133
|
case 13: goto st3;
|
112
134
|
case 32: goto st3;
|
@@ -173,7 +195,7 @@ case 8:
|
|
173
195
|
goto st8;
|
174
196
|
goto st0;
|
175
197
|
tr11:
|
176
|
-
#line
|
198
|
+
#line 90 "parser.rl"
|
177
199
|
{
|
178
200
|
VALUE v = Qnil;
|
179
201
|
char *np = JSON_parse_value(json, p, pe, &v);
|
@@ -189,7 +211,7 @@ st9:
|
|
189
211
|
if ( ++p == pe )
|
190
212
|
goto _test_eof9;
|
191
213
|
case 9:
|
192
|
-
#line
|
214
|
+
#line 215 "parser.c"
|
193
215
|
switch( (*p) ) {
|
194
216
|
case 13: goto st9;
|
195
217
|
case 32: goto st9;
|
@@ -278,14 +300,14 @@ case 18:
|
|
278
300
|
goto st9;
|
279
301
|
goto st18;
|
280
302
|
tr4:
|
281
|
-
#line
|
303
|
+
#line 106 "parser.rl"
|
282
304
|
{ p--; {p++; cs = 27; goto _out;} }
|
283
305
|
goto st27;
|
284
306
|
st27:
|
285
307
|
if ( ++p == pe )
|
286
308
|
goto _test_eof27;
|
287
309
|
case 27:
|
288
|
-
#line
|
310
|
+
#line 311 "parser.c"
|
289
311
|
goto st0;
|
290
312
|
st19:
|
291
313
|
if ( ++p == pe )
|
@@ -382,7 +404,8 @@ case 26:
|
|
382
404
|
_test_eof: {}
|
383
405
|
_out: {}
|
384
406
|
}
|
385
|
-
|
407
|
+
|
408
|
+
#line 130 "parser.rl"
|
386
409
|
|
387
410
|
if (cs >= JSON_object_first_final) {
|
388
411
|
if (RTEST(json->create_id)) {
|
@@ -401,14 +424,15 @@ case 26:
|
|
401
424
|
}
|
402
425
|
|
403
426
|
|
404
|
-
#line
|
427
|
+
#line 428 "parser.c"
|
405
428
|
static const int JSON_value_start = 1;
|
406
429
|
static const int JSON_value_first_final = 21;
|
407
430
|
static const int JSON_value_error = 0;
|
408
431
|
|
409
432
|
static const int JSON_value_en_main = 1;
|
410
433
|
|
411
|
-
|
434
|
+
|
435
|
+
#line 228 "parser.rl"
|
412
436
|
|
413
437
|
|
414
438
|
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
@@ -416,13 +440,14 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
416
440
|
int cs = EVIL;
|
417
441
|
|
418
442
|
|
419
|
-
#line
|
443
|
+
#line 444 "parser.c"
|
420
444
|
{
|
421
445
|
cs = JSON_value_start;
|
422
446
|
}
|
423
|
-
|
447
|
+
|
448
|
+
#line 235 "parser.rl"
|
424
449
|
|
425
|
-
#line
|
450
|
+
#line 451 "parser.c"
|
426
451
|
{
|
427
452
|
if ( p == pe )
|
428
453
|
goto _test_eof;
|
@@ -447,14 +472,14 @@ st0:
|
|
447
472
|
cs = 0;
|
448
473
|
goto _out;
|
449
474
|
tr0:
|
450
|
-
#line
|
475
|
+
#line 176 "parser.rl"
|
451
476
|
{
|
452
477
|
char *np = JSON_parse_string(json, p, pe, result);
|
453
478
|
if (np == NULL) { p--; {p++; cs = 21; goto _out;} } else {p = (( np))-1;}
|
454
479
|
}
|
455
480
|
goto st21;
|
456
481
|
tr2:
|
457
|
-
#line
|
482
|
+
#line 181 "parser.rl"
|
458
483
|
{
|
459
484
|
char *np;
|
460
485
|
if(pe > p + 9 && !strncmp(MinusInfinity, p, 9)) {
|
@@ -474,7 +499,7 @@ tr2:
|
|
474
499
|
}
|
475
500
|
goto st21;
|
476
501
|
tr5:
|
477
|
-
#line
|
502
|
+
#line 199 "parser.rl"
|
478
503
|
{
|
479
504
|
char *np;
|
480
505
|
json->current_nesting++;
|
@@ -484,7 +509,7 @@ tr5:
|
|
484
509
|
}
|
485
510
|
goto st21;
|
486
511
|
tr9:
|
487
|
-
#line
|
512
|
+
#line 207 "parser.rl"
|
488
513
|
{
|
489
514
|
char *np;
|
490
515
|
json->current_nesting++;
|
@@ -494,7 +519,7 @@ tr9:
|
|
494
519
|
}
|
495
520
|
goto st21;
|
496
521
|
tr16:
|
497
|
-
#line
|
522
|
+
#line 169 "parser.rl"
|
498
523
|
{
|
499
524
|
if (json->allow_nan) {
|
500
525
|
*result = CInfinity;
|
@@ -504,7 +529,7 @@ tr16:
|
|
504
529
|
}
|
505
530
|
goto st21;
|
506
531
|
tr18:
|
507
|
-
#line
|
532
|
+
#line 162 "parser.rl"
|
508
533
|
{
|
509
534
|
if (json->allow_nan) {
|
510
535
|
*result = CNaN;
|
@@ -514,19 +539,19 @@ tr18:
|
|
514
539
|
}
|
515
540
|
goto st21;
|
516
541
|
tr22:
|
517
|
-
#line
|
542
|
+
#line 156 "parser.rl"
|
518
543
|
{
|
519
544
|
*result = Qfalse;
|
520
545
|
}
|
521
546
|
goto st21;
|
522
547
|
tr25:
|
523
|
-
#line
|
548
|
+
#line 153 "parser.rl"
|
524
549
|
{
|
525
550
|
*result = Qnil;
|
526
551
|
}
|
527
552
|
goto st21;
|
528
553
|
tr28:
|
529
|
-
#line
|
554
|
+
#line 159 "parser.rl"
|
530
555
|
{
|
531
556
|
*result = Qtrue;
|
532
557
|
}
|
@@ -535,9 +560,9 @@ st21:
|
|
535
560
|
if ( ++p == pe )
|
536
561
|
goto _test_eof21;
|
537
562
|
case 21:
|
538
|
-
#line
|
563
|
+
#line 215 "parser.rl"
|
539
564
|
{ p--; {p++; cs = 21; goto _out;} }
|
540
|
-
#line
|
565
|
+
#line 566 "parser.c"
|
541
566
|
goto st0;
|
542
567
|
st2:
|
543
568
|
if ( ++p == pe )
|
@@ -697,7 +722,8 @@ case 20:
|
|
697
722
|
_test_eof: {}
|
698
723
|
_out: {}
|
699
724
|
}
|
700
|
-
|
725
|
+
|
726
|
+
#line 236 "parser.rl"
|
701
727
|
|
702
728
|
if (cs >= JSON_value_first_final) {
|
703
729
|
return p;
|
@@ -707,14 +733,15 @@ case 20:
|
|
707
733
|
}
|
708
734
|
|
709
735
|
|
710
|
-
#line
|
736
|
+
#line 737 "parser.c"
|
711
737
|
static const int JSON_integer_start = 1;
|
712
738
|
static const int JSON_integer_first_final = 5;
|
713
739
|
static const int JSON_integer_error = 0;
|
714
740
|
|
715
741
|
static const int JSON_integer_en_main = 1;
|
716
742
|
|
717
|
-
|
743
|
+
|
744
|
+
#line 252 "parser.rl"
|
718
745
|
|
719
746
|
|
720
747
|
static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
@@ -722,14 +749,15 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
|
|
722
749
|
int cs = EVIL;
|
723
750
|
|
724
751
|
|
725
|
-
#line
|
752
|
+
#line 753 "parser.c"
|
726
753
|
{
|
727
754
|
cs = JSON_integer_start;
|
728
755
|
}
|
729
|
-
|
756
|
+
|
757
|
+
#line 259 "parser.rl"
|
730
758
|
json->memo = p;
|
731
759
|
|
732
|
-
#line
|
760
|
+
#line 761 "parser.c"
|
733
761
|
{
|
734
762
|
if ( p == pe )
|
735
763
|
goto _test_eof;
|
@@ -763,14 +791,14 @@ case 3:
|
|
763
791
|
goto st0;
|
764
792
|
goto tr4;
|
765
793
|
tr4:
|
766
|
-
#line
|
794
|
+
#line 249 "parser.rl"
|
767
795
|
{ p--; {p++; cs = 5; goto _out;} }
|
768
796
|
goto st5;
|
769
797
|
st5:
|
770
798
|
if ( ++p == pe )
|
771
799
|
goto _test_eof5;
|
772
800
|
case 5:
|
773
|
-
#line
|
801
|
+
#line 802 "parser.c"
|
774
802
|
goto st0;
|
775
803
|
st4:
|
776
804
|
if ( ++p == pe )
|
@@ -788,7 +816,8 @@ case 4:
|
|
788
816
|
_test_eof: {}
|
789
817
|
_out: {}
|
790
818
|
}
|
791
|
-
|
819
|
+
|
820
|
+
#line 261 "parser.rl"
|
792
821
|
|
793
822
|
if (cs >= JSON_integer_first_final) {
|
794
823
|
long len = p - json->memo;
|
@@ -800,14 +829,15 @@ case 4:
|
|
800
829
|
}
|
801
830
|
|
802
831
|
|
803
|
-
#line
|
832
|
+
#line 833 "parser.c"
|
804
833
|
static const int JSON_float_start = 1;
|
805
834
|
static const int JSON_float_first_final = 10;
|
806
835
|
static const int JSON_float_error = 0;
|
807
836
|
|
808
837
|
static const int JSON_float_en_main = 1;
|
809
838
|
|
810
|
-
|
839
|
+
|
840
|
+
#line 283 "parser.rl"
|
811
841
|
|
812
842
|
|
813
843
|
static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
@@ -815,14 +845,15 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
815
845
|
int cs = EVIL;
|
816
846
|
|
817
847
|
|
818
|
-
#line
|
848
|
+
#line 849 "parser.c"
|
819
849
|
{
|
820
850
|
cs = JSON_float_start;
|
821
851
|
}
|
822
|
-
|
852
|
+
|
853
|
+
#line 290 "parser.rl"
|
823
854
|
json->memo = p;
|
824
855
|
|
825
|
-
#line
|
856
|
+
#line 857 "parser.c"
|
826
857
|
{
|
827
858
|
if ( p == pe )
|
828
859
|
goto _test_eof;
|
@@ -880,14 +911,14 @@ case 5:
|
|
880
911
|
goto st0;
|
881
912
|
goto tr7;
|
882
913
|
tr7:
|
883
|
-
#line
|
914
|
+
#line 277 "parser.rl"
|
884
915
|
{ p--; {p++; cs = 10; goto _out;} }
|
885
916
|
goto st10;
|
886
917
|
st10:
|
887
918
|
if ( ++p == pe )
|
888
919
|
goto _test_eof10;
|
889
920
|
case 10:
|
890
|
-
#line
|
921
|
+
#line 922 "parser.c"
|
891
922
|
goto st0;
|
892
923
|
st6:
|
893
924
|
if ( ++p == pe )
|
@@ -947,7 +978,8 @@ case 9:
|
|
947
978
|
_test_eof: {}
|
948
979
|
_out: {}
|
949
980
|
}
|
950
|
-
|
981
|
+
|
982
|
+
#line 292 "parser.rl"
|
951
983
|
|
952
984
|
if (cs >= JSON_float_first_final) {
|
953
985
|
long len = p - json->memo;
|
@@ -960,14 +992,15 @@ case 9:
|
|
960
992
|
|
961
993
|
|
962
994
|
|
963
|
-
#line
|
995
|
+
#line 996 "parser.c"
|
964
996
|
static const int JSON_array_start = 1;
|
965
997
|
static const int JSON_array_first_final = 17;
|
966
998
|
static const int JSON_array_error = 0;
|
967
999
|
|
968
1000
|
static const int JSON_array_en_main = 1;
|
969
1001
|
|
970
|
-
|
1002
|
+
|
1003
|
+
#line 328 "parser.rl"
|
971
1004
|
|
972
1005
|
|
973
1006
|
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
@@ -980,13 +1013,14 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
980
1013
|
*result = rb_ary_new();
|
981
1014
|
|
982
1015
|
|
983
|
-
#line
|
1016
|
+
#line 1017 "parser.c"
|
984
1017
|
{
|
985
1018
|
cs = JSON_array_start;
|
986
1019
|
}
|
987
|
-
|
1020
|
+
|
1021
|
+
#line 340 "parser.rl"
|
988
1022
|
|
989
|
-
#line
|
1023
|
+
#line 1024 "parser.c"
|
990
1024
|
{
|
991
1025
|
if ( p == pe )
|
992
1026
|
goto _test_eof;
|
@@ -1025,7 +1059,7 @@ case 2:
|
|
1025
1059
|
goto st2;
|
1026
1060
|
goto st0;
|
1027
1061
|
tr2:
|
1028
|
-
#line
|
1062
|
+
#line 309 "parser.rl"
|
1029
1063
|
{
|
1030
1064
|
VALUE v = Qnil;
|
1031
1065
|
char *np = JSON_parse_value(json, p, pe, &v);
|
@@ -1041,7 +1075,7 @@ st3:
|
|
1041
1075
|
if ( ++p == pe )
|
1042
1076
|
goto _test_eof3;
|
1043
1077
|
case 3:
|
1044
|
-
#line
|
1078
|
+
#line 1079 "parser.c"
|
1045
1079
|
switch( (*p) ) {
|
1046
1080
|
case 13: goto st3;
|
1047
1081
|
case 32: goto st3;
|
@@ -1141,14 +1175,14 @@ case 12:
|
|
1141
1175
|
goto st3;
|
1142
1176
|
goto st12;
|
1143
1177
|
tr4:
|
1144
|
-
#line
|
1178
|
+
#line 320 "parser.rl"
|
1145
1179
|
{ p--; {p++; cs = 17; goto _out;} }
|
1146
1180
|
goto st17;
|
1147
1181
|
st17:
|
1148
1182
|
if ( ++p == pe )
|
1149
1183
|
goto _test_eof17;
|
1150
1184
|
case 17:
|
1151
|
-
#line
|
1185
|
+
#line 1186 "parser.c"
|
1152
1186
|
goto st0;
|
1153
1187
|
st13:
|
1154
1188
|
if ( ++p == pe )
|
@@ -1203,7 +1237,8 @@ case 16:
|
|
1203
1237
|
_test_eof: {}
|
1204
1238
|
_out: {}
|
1205
1239
|
}
|
1206
|
-
|
1240
|
+
|
1241
|
+
#line 341 "parser.rl"
|
1207
1242
|
|
1208
1243
|
if(cs >= JSON_array_first_final) {
|
1209
1244
|
return p + 1;
|
@@ -1269,14 +1304,15 @@ static VALUE json_string_unescape(char *p, char *pe)
|
|
1269
1304
|
}
|
1270
1305
|
|
1271
1306
|
|
1272
|
-
#line
|
1307
|
+
#line 1308 "parser.c"
|
1273
1308
|
static const int JSON_string_start = 1;
|
1274
1309
|
static const int JSON_string_first_final = 8;
|
1275
1310
|
static const int JSON_string_error = 0;
|
1276
1311
|
|
1277
1312
|
static const int JSON_string_en_main = 1;
|
1278
1313
|
|
1279
|
-
|
1314
|
+
|
1315
|
+
#line 425 "parser.rl"
|
1280
1316
|
|
1281
1317
|
|
1282
1318
|
static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
@@ -1285,14 +1321,15 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
|
|
1285
1321
|
|
1286
1322
|
*result = rb_str_new("", 0);
|
1287
1323
|
|
1288
|
-
#line
|
1324
|
+
#line 1325 "parser.c"
|
1289
1325
|
{
|
1290
1326
|
cs = JSON_string_start;
|
1291
1327
|
}
|
1292
|
-
|
1328
|
+
|
1329
|
+
#line 433 "parser.rl"
|
1293
1330
|
json->memo = p;
|
1294
1331
|
|
1295
|
-
#line
|
1332
|
+
#line 1333 "parser.c"
|
1296
1333
|
{
|
1297
1334
|
if ( p == pe )
|
1298
1335
|
goto _test_eof;
|
@@ -1317,19 +1354,25 @@ case 2:
|
|
1317
1354
|
goto st0;
|
1318
1355
|
goto st2;
|
1319
1356
|
tr2:
|
1320
|
-
#line
|
1357
|
+
#line 411 "parser.rl"
|
1321
1358
|
{
|
1322
1359
|
*result = json_string_unescape(json->memo + 1, p);
|
1323
|
-
if (NIL_P(*result)) {
|
1324
|
-
|
1325
|
-
|
1360
|
+
if (NIL_P(*result)) {
|
1361
|
+
p--;
|
1362
|
+
{p++; cs = 8; goto _out;}
|
1363
|
+
} else {
|
1364
|
+
FORCE_UTF8(*result);
|
1365
|
+
{p = (( p + 1))-1;}
|
1366
|
+
}
|
1367
|
+
}
|
1368
|
+
#line 422 "parser.rl"
|
1326
1369
|
{ p--; {p++; cs = 8; goto _out;} }
|
1327
1370
|
goto st8;
|
1328
1371
|
st8:
|
1329
1372
|
if ( ++p == pe )
|
1330
1373
|
goto _test_eof8;
|
1331
1374
|
case 8:
|
1332
|
-
#line
|
1375
|
+
#line 1376 "parser.c"
|
1333
1376
|
goto st0;
|
1334
1377
|
st3:
|
1335
1378
|
if ( ++p == pe )
|
@@ -1404,7 +1447,8 @@ case 7:
|
|
1404
1447
|
_test_eof: {}
|
1405
1448
|
_out: {}
|
1406
1449
|
}
|
1407
|
-
|
1450
|
+
|
1451
|
+
#line 435 "parser.rl"
|
1408
1452
|
|
1409
1453
|
if (cs >= JSON_string_first_final) {
|
1410
1454
|
return p + 1;
|
@@ -1415,14 +1459,15 @@ case 7:
|
|
1415
1459
|
|
1416
1460
|
|
1417
1461
|
|
1418
|
-
#line
|
1462
|
+
#line 1463 "parser.c"
|
1419
1463
|
static const int JSON_start = 1;
|
1420
1464
|
static const int JSON_first_final = 10;
|
1421
1465
|
static const int JSON_error = 0;
|
1422
1466
|
|
1423
1467
|
static const int JSON_en_main = 1;
|
1424
1468
|
|
1425
|
-
|
1469
|
+
|
1470
|
+
#line 469 "parser.rl"
|
1426
1471
|
|
1427
1472
|
|
1428
1473
|
/*
|
@@ -1477,7 +1522,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|
1477
1522
|
rb_raise(rb_eArgError, "opts needs to be like a hash");
|
1478
1523
|
} else {
|
1479
1524
|
VALUE tmp = ID2SYM(i_max_nesting);
|
1480
|
-
if (st_lookup(
|
1525
|
+
if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
|
1481
1526
|
VALUE max_nesting = rb_hash_aref(opts, tmp);
|
1482
1527
|
if (RTEST(max_nesting)) {
|
1483
1528
|
Check_Type(max_nesting, T_FIXNUM);
|
@@ -1489,14 +1534,14 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|
1489
1534
|
json->max_nesting = 19;
|
1490
1535
|
}
|
1491
1536
|
tmp = ID2SYM(i_allow_nan);
|
1492
|
-
if (st_lookup(
|
1537
|
+
if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
|
1493
1538
|
VALUE allow_nan = rb_hash_aref(opts, tmp);
|
1494
1539
|
json->allow_nan = RTEST(allow_nan) ? 1 : 0;
|
1495
1540
|
} else {
|
1496
1541
|
json->allow_nan = 0;
|
1497
1542
|
}
|
1498
1543
|
tmp = ID2SYM(i_create_additions);
|
1499
|
-
if (st_lookup(
|
1544
|
+
if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
|
1500
1545
|
VALUE create_additions = rb_hash_aref(opts, tmp);
|
1501
1546
|
if (RTEST(create_additions)) {
|
1502
1547
|
json->create_id = rb_funcall(mJSON, i_create_id, 0);
|
@@ -1545,15 +1590,16 @@ static VALUE cParser_parse(VALUE self)
|
|
1545
1590
|
GET_STRUCT;
|
1546
1591
|
|
1547
1592
|
|
1548
|
-
#line
|
1593
|
+
#line 1594 "parser.c"
|
1549
1594
|
{
|
1550
1595
|
cs = JSON_start;
|
1551
1596
|
}
|
1552
|
-
|
1597
|
+
|
1598
|
+
#line 591 "parser.rl"
|
1553
1599
|
p = json->source;
|
1554
1600
|
pe = p + json->len;
|
1555
1601
|
|
1556
|
-
#line
|
1602
|
+
#line 1603 "parser.c"
|
1557
1603
|
{
|
1558
1604
|
if ( p == pe )
|
1559
1605
|
goto _test_eof;
|
@@ -1609,7 +1655,7 @@ case 5:
|
|
1609
1655
|
goto st1;
|
1610
1656
|
goto st5;
|
1611
1657
|
tr3:
|
1612
|
-
#line
|
1658
|
+
#line 458 "parser.rl"
|
1613
1659
|
{
|
1614
1660
|
char *np;
|
1615
1661
|
json->current_nesting = 1;
|
@@ -1618,7 +1664,7 @@ tr3:
|
|
1618
1664
|
}
|
1619
1665
|
goto st10;
|
1620
1666
|
tr4:
|
1621
|
-
#line
|
1667
|
+
#line 451 "parser.rl"
|
1622
1668
|
{
|
1623
1669
|
char *np;
|
1624
1670
|
json->current_nesting = 1;
|
@@ -1630,7 +1676,7 @@ st10:
|
|
1630
1676
|
if ( ++p == pe )
|
1631
1677
|
goto _test_eof10;
|
1632
1678
|
case 10:
|
1633
|
-
#line
|
1679
|
+
#line 1680 "parser.c"
|
1634
1680
|
switch( (*p) ) {
|
1635
1681
|
case 13: goto st10;
|
1636
1682
|
case 32: goto st10;
|
@@ -1686,7 +1732,8 @@ case 9:
|
|
1686
1732
|
_test_eof: {}
|
1687
1733
|
_out: {}
|
1688
1734
|
}
|
1689
|
-
|
1735
|
+
|
1736
|
+
#line 594 "parser.rl"
|
1690
1737
|
|
1691
1738
|
if (cs >= JSON_first_final && p == pe) {
|
1692
1739
|
return result;
|
@@ -1710,7 +1757,7 @@ static void JSON_mark(JSON_Parser *json)
|
|
1710
1757
|
|
1711
1758
|
static void JSON_free(JSON_Parser *json)
|
1712
1759
|
{
|
1713
|
-
|
1760
|
+
ruby_xfree(json);
|
1714
1761
|
}
|
1715
1762
|
|
1716
1763
|
static VALUE cJSON_parser_s_allocate(VALUE klass)
|