json_pure 1.0.0 → 1.4.6
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.
- data/CHANGES +155 -1
- data/COPYING +58 -0
- data/GPL +7 -7
- data/README +324 -45
- data/Rakefile +166 -124
- data/TODO +1 -1
- 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/generator2_benchmark.rb +222 -0
- data/benchmarks/generator_benchmark.rb +224 -0
- data/benchmarks/ohai.json +1216 -0
- data/benchmarks/ohai.ruby +1 -0
- data/benchmarks/parser2_benchmark.rb +251 -0
- data/benchmarks/parser_benchmark.rb +259 -0
- data/bin/edit_json.rb +1 -3
- data/bin/prettify_json.rb +75 -0
- data/data/index.html +5 -4
- data/data/prototype.js +2764 -1095
- data/ext/json/ext/generator/extconf.rb +14 -3
- data/ext/json/ext/generator/generator.c +1022 -334
- data/ext/json/ext/generator/generator.h +197 -0
- data/ext/json/ext/parser/extconf.rb +9 -3
- data/ext/json/ext/parser/parser.c +961 -577
- data/ext/json/ext/parser/parser.h +71 -0
- data/ext/json/ext/parser/parser.rl +400 -123
- data/install.rb +0 -0
- data/lib/json/add/core.rb +148 -0
- data/lib/json/add/rails.rb +58 -0
- data/lib/json/common.rb +254 -47
- data/lib/json/editor.rb +236 -72
- data/lib/json/ext.rb +2 -0
- data/lib/json/pure/generator.rb +235 -117
- data/lib/json/pure/parser.rb +124 -25
- data/lib/json/pure.rb +5 -3
- data/lib/json/version.rb +1 -1
- data/lib/json.rb +2 -197
- data/tests/fixtures/fail18.json +1 -0
- data/tests/test_json.rb +181 -22
- data/tests/test_json_addition.rb +84 -16
- data/tests/test_json_encoding.rb +68 -0
- data/tests/test_json_fixtures.rb +9 -5
- data/tests/test_json_generate.rb +114 -14
- data/tests/test_json_rails.rb +144 -0
- data/tests/test_json_unicode.rb +35 -14
- data/tools/fuzz.rb +13 -7
- data/tools/server.rb +0 -1
- metadata +156 -122
- data/benchmarks/benchmark.txt +0 -133
- data/benchmarks/benchmark_generator.rb +0 -44
- data/benchmarks/benchmark_parser.rb +0 -22
- data/benchmarks/benchmark_rails.rb +0 -26
- data/ext/json/ext/generator/Makefile +0 -149
- data/ext/json/ext/generator/unicode.c +0 -184
- data/ext/json/ext/generator/unicode.h +0 -40
- data/ext/json/ext/parser/Makefile +0 -149
- data/ext/json/ext/parser/unicode.c +0 -156
- data/ext/json/ext/parser/unicode.h +0 -44
- data/tests/fixtures/pass18.json +0 -1
- data/tests/runner.rb +0 -24
- /data/tests/fixtures/{fail15.json → pass15.json} +0 -0
- /data/tests/fixtures/{fail16.json → pass16.json} +0 -0
- /data/tests/fixtures/{fail17.json → pass17.json} +0 -0
- /data/tests/fixtures/{fail26.json → pass26.json} +0 -0
|
@@ -1,104 +1,164 @@
|
|
|
1
|
+
|
|
1
2
|
#line 1 "parser.rl"
|
|
2
|
-
|
|
3
|
+
#include "parser.h"
|
|
4
|
+
|
|
5
|
+
/* unicode */
|
|
6
|
+
|
|
7
|
+
static const char digit_values[256] = {
|
|
8
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
9
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
10
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
|
|
11
|
+
-1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
|
|
12
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
13
|
+
10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
14
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
15
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
16
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
17
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
18
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
19
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
20
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
21
|
+
-1, -1, -1, -1, -1, -1, -1
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
static UTF32 unescape_unicode(const unsigned char *p)
|
|
25
|
+
{
|
|
26
|
+
char b;
|
|
27
|
+
UTF32 result = 0;
|
|
28
|
+
b = digit_values[p[0]];
|
|
29
|
+
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
|
30
|
+
result = (result << 4) | b;
|
|
31
|
+
b = digit_values[p[1]];
|
|
32
|
+
result = (result << 4) | b;
|
|
33
|
+
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
|
34
|
+
b = digit_values[p[2]];
|
|
35
|
+
result = (result << 4) | b;
|
|
36
|
+
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
|
37
|
+
b = digit_values[p[3]];
|
|
38
|
+
result = (result << 4) | b;
|
|
39
|
+
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
3
42
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
43
|
+
static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
|
|
44
|
+
{
|
|
45
|
+
int len = 1;
|
|
46
|
+
if (ch <= 0x7F) {
|
|
47
|
+
buf[0] = (char) ch;
|
|
48
|
+
} else if (ch <= 0x07FF) {
|
|
49
|
+
buf[0] = (char) ((ch >> 6) | 0xC0);
|
|
50
|
+
buf[1] = (char) ((ch & 0x3F) | 0x80);
|
|
51
|
+
len++;
|
|
52
|
+
} else if (ch <= 0xFFFF) {
|
|
53
|
+
buf[0] = (char) ((ch >> 12) | 0xE0);
|
|
54
|
+
buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80);
|
|
55
|
+
buf[2] = (char) ((ch & 0x3F) | 0x80);
|
|
56
|
+
len += 2;
|
|
57
|
+
} else if (ch <= 0x1fffff) {
|
|
58
|
+
buf[0] =(char) ((ch >> 18) | 0xF0);
|
|
59
|
+
buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80);
|
|
60
|
+
buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80);
|
|
61
|
+
buf[3] =(char) ((ch & 0x3F) | 0x80);
|
|
62
|
+
len += 3;
|
|
63
|
+
} else {
|
|
64
|
+
buf[0] = '?';
|
|
65
|
+
}
|
|
66
|
+
return len;
|
|
67
|
+
}
|
|
7
68
|
|
|
8
|
-
#
|
|
9
|
-
|
|
69
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
|
70
|
+
static VALUE CEncoding_ASCII_8BIT, CEncoding_UTF_8, CEncoding_UTF_16BE,
|
|
71
|
+
CEncoding_UTF_16LE, CEncoding_UTF_32BE, CEncoding_UTF_32LE;
|
|
72
|
+
static ID i_encoding, i_encode, i_encode_bang, i_force_encoding;
|
|
73
|
+
#else
|
|
74
|
+
static ID i_iconv;
|
|
10
75
|
#endif
|
|
11
76
|
|
|
12
|
-
|
|
77
|
+
static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
|
|
78
|
+
static VALUE CNaN, CInfinity, CMinusInfinity;
|
|
13
79
|
|
|
14
|
-
static
|
|
80
|
+
static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
|
|
81
|
+
i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_object_class,
|
|
82
|
+
i_array_class, i_key_p, i_deep_const_get;
|
|
15
83
|
|
|
16
|
-
static ID i_json_creatable_p, i_json_create, i_create_id, i_chr;
|
|
17
84
|
|
|
18
|
-
|
|
19
|
-
VALUE Vsource;
|
|
20
|
-
char *source;
|
|
21
|
-
long len;
|
|
22
|
-
char *memo;
|
|
23
|
-
VALUE create_id;
|
|
24
|
-
} JSON_Parser;
|
|
85
|
+
#line 108 "parser.rl"
|
|
25
86
|
|
|
26
|
-
static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
|
27
|
-
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
|
28
|
-
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
|
29
|
-
static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
|
30
|
-
static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
|
31
|
-
static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
|
32
87
|
|
|
33
|
-
#define GET_STRUCT \
|
|
34
|
-
JSON_Parser *json; \
|
|
35
|
-
Data_Get_Struct(self, JSON_Parser, json);
|
|
36
|
-
|
|
37
|
-
#line 59 "parser.rl"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
#line 42 "parser.c"
|
|
42
|
-
static const int JSON_object_start = 0;
|
|
43
88
|
|
|
89
|
+
#line 90 "parser.c"
|
|
90
|
+
static const int JSON_object_start = 1;
|
|
44
91
|
static const int JSON_object_first_final = 27;
|
|
92
|
+
static const int JSON_object_error = 0;
|
|
45
93
|
|
|
46
|
-
static const int
|
|
94
|
+
static const int JSON_object_en_main = 1;
|
|
47
95
|
|
|
48
|
-
|
|
96
|
+
|
|
97
|
+
#line 143 "parser.rl"
|
|
49
98
|
|
|
50
99
|
|
|
51
100
|
static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
|
52
101
|
{
|
|
53
102
|
int cs = EVIL;
|
|
54
103
|
VALUE last_name = Qnil;
|
|
55
|
-
|
|
104
|
+
VALUE object_class = json->object_class;
|
|
105
|
+
|
|
106
|
+
if (json->max_nesting && json->current_nesting > json->max_nesting) {
|
|
107
|
+
rb_raise(eNestingError, "nesting of %d is too deep", json->current_nesting);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
*result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
|
|
56
111
|
|
|
57
112
|
|
|
58
|
-
#line
|
|
113
|
+
#line 114 "parser.c"
|
|
59
114
|
{
|
|
60
115
|
cs = JSON_object_start;
|
|
61
116
|
}
|
|
62
|
-
|
|
117
|
+
|
|
118
|
+
#line 158 "parser.rl"
|
|
63
119
|
|
|
64
|
-
#line
|
|
120
|
+
#line 121 "parser.c"
|
|
65
121
|
{
|
|
66
122
|
if ( p == pe )
|
|
67
|
-
goto
|
|
123
|
+
goto _test_eof;
|
|
68
124
|
switch ( cs )
|
|
69
125
|
{
|
|
70
|
-
case
|
|
126
|
+
case 1:
|
|
71
127
|
if ( (*p) == 123 )
|
|
72
128
|
goto st2;
|
|
73
|
-
goto
|
|
74
|
-
|
|
75
|
-
|
|
129
|
+
goto st0;
|
|
130
|
+
st0:
|
|
131
|
+
cs = 0;
|
|
132
|
+
goto _out;
|
|
76
133
|
st2:
|
|
77
134
|
if ( ++p == pe )
|
|
78
|
-
goto
|
|
135
|
+
goto _test_eof2;
|
|
79
136
|
case 2:
|
|
80
137
|
switch( (*p) ) {
|
|
81
138
|
case 13: goto st2;
|
|
82
139
|
case 32: goto st2;
|
|
83
|
-
case 34: goto
|
|
140
|
+
case 34: goto tr2;
|
|
84
141
|
case 47: goto st23;
|
|
85
|
-
case 125: goto
|
|
142
|
+
case 125: goto tr4;
|
|
86
143
|
}
|
|
87
144
|
if ( 9 <= (*p) && (*p) <= 10 )
|
|
88
145
|
goto st2;
|
|
89
|
-
goto
|
|
90
|
-
|
|
91
|
-
#line
|
|
146
|
+
goto st0;
|
|
147
|
+
tr2:
|
|
148
|
+
#line 127 "parser.rl"
|
|
92
149
|
{
|
|
93
|
-
char *np
|
|
94
|
-
|
|
150
|
+
char *np;
|
|
151
|
+
json->parsing_name = 1;
|
|
152
|
+
np = JSON_parse_string(json, p, pe, &last_name);
|
|
153
|
+
json->parsing_name = 0;
|
|
154
|
+
if (np == NULL) { p--; {p++; cs = 3; goto _out;} } else {p = (( np))-1;}
|
|
95
155
|
}
|
|
96
156
|
goto st3;
|
|
97
157
|
st3:
|
|
98
158
|
if ( ++p == pe )
|
|
99
|
-
goto
|
|
159
|
+
goto _test_eof3;
|
|
100
160
|
case 3:
|
|
101
|
-
#line
|
|
161
|
+
#line 161 "parser.c"
|
|
102
162
|
switch( (*p) ) {
|
|
103
163
|
case 13: goto st3;
|
|
104
164
|
case 32: goto st3;
|
|
@@ -107,26 +167,26 @@ case 3:
|
|
|
107
167
|
}
|
|
108
168
|
if ( 9 <= (*p) && (*p) <= 10 )
|
|
109
169
|
goto st3;
|
|
110
|
-
goto
|
|
170
|
+
goto st0;
|
|
111
171
|
st4:
|
|
112
172
|
if ( ++p == pe )
|
|
113
|
-
goto
|
|
173
|
+
goto _test_eof4;
|
|
114
174
|
case 4:
|
|
115
175
|
switch( (*p) ) {
|
|
116
176
|
case 42: goto st5;
|
|
117
177
|
case 47: goto st7;
|
|
118
178
|
}
|
|
119
|
-
goto
|
|
179
|
+
goto st0;
|
|
120
180
|
st5:
|
|
121
181
|
if ( ++p == pe )
|
|
122
|
-
goto
|
|
182
|
+
goto _test_eof5;
|
|
123
183
|
case 5:
|
|
124
184
|
if ( (*p) == 42 )
|
|
125
185
|
goto st6;
|
|
126
186
|
goto st5;
|
|
127
187
|
st6:
|
|
128
188
|
if ( ++p == pe )
|
|
129
|
-
goto
|
|
189
|
+
goto _test_eof6;
|
|
130
190
|
case 6:
|
|
131
191
|
switch( (*p) ) {
|
|
132
192
|
case 42: goto st6;
|
|
@@ -135,14 +195,14 @@ case 6:
|
|
|
135
195
|
goto st5;
|
|
136
196
|
st7:
|
|
137
197
|
if ( ++p == pe )
|
|
138
|
-
goto
|
|
198
|
+
goto _test_eof7;
|
|
139
199
|
case 7:
|
|
140
200
|
if ( (*p) == 10 )
|
|
141
201
|
goto st3;
|
|
142
202
|
goto st7;
|
|
143
203
|
st8:
|
|
144
204
|
if ( ++p == pe )
|
|
145
|
-
goto
|
|
205
|
+
goto _test_eof8;
|
|
146
206
|
case 8:
|
|
147
207
|
switch( (*p) ) {
|
|
148
208
|
case 13: goto st8;
|
|
@@ -150,6 +210,8 @@ case 8:
|
|
|
150
210
|
case 34: goto tr11;
|
|
151
211
|
case 45: goto tr11;
|
|
152
212
|
case 47: goto st19;
|
|
213
|
+
case 73: goto tr11;
|
|
214
|
+
case 78: goto tr11;
|
|
153
215
|
case 91: goto tr11;
|
|
154
216
|
case 102: goto tr11;
|
|
155
217
|
case 110: goto tr11;
|
|
@@ -161,14 +223,14 @@ case 8:
|
|
|
161
223
|
goto tr11;
|
|
162
224
|
} else if ( (*p) >= 9 )
|
|
163
225
|
goto st8;
|
|
164
|
-
goto
|
|
226
|
+
goto st0;
|
|
165
227
|
tr11:
|
|
166
|
-
#line
|
|
228
|
+
#line 116 "parser.rl"
|
|
167
229
|
{
|
|
168
230
|
VALUE v = Qnil;
|
|
169
231
|
char *np = JSON_parse_value(json, p, pe, &v);
|
|
170
232
|
if (np == NULL) {
|
|
171
|
-
goto
|
|
233
|
+
p--; {p++; cs = 9; goto _out;}
|
|
172
234
|
} else {
|
|
173
235
|
rb_hash_aset(*result, last_name, v);
|
|
174
236
|
{p = (( np))-1;}
|
|
@@ -177,51 +239,51 @@ tr11:
|
|
|
177
239
|
goto st9;
|
|
178
240
|
st9:
|
|
179
241
|
if ( ++p == pe )
|
|
180
|
-
goto
|
|
242
|
+
goto _test_eof9;
|
|
181
243
|
case 9:
|
|
182
|
-
#line
|
|
244
|
+
#line 244 "parser.c"
|
|
183
245
|
switch( (*p) ) {
|
|
184
246
|
case 13: goto st9;
|
|
185
247
|
case 32: goto st9;
|
|
186
248
|
case 44: goto st10;
|
|
187
249
|
case 47: goto st15;
|
|
188
|
-
case 125: goto
|
|
250
|
+
case 125: goto tr4;
|
|
189
251
|
}
|
|
190
252
|
if ( 9 <= (*p) && (*p) <= 10 )
|
|
191
253
|
goto st9;
|
|
192
|
-
goto
|
|
254
|
+
goto st0;
|
|
193
255
|
st10:
|
|
194
256
|
if ( ++p == pe )
|
|
195
|
-
goto
|
|
257
|
+
goto _test_eof10;
|
|
196
258
|
case 10:
|
|
197
259
|
switch( (*p) ) {
|
|
198
260
|
case 13: goto st10;
|
|
199
261
|
case 32: goto st10;
|
|
200
|
-
case 34: goto
|
|
262
|
+
case 34: goto tr2;
|
|
201
263
|
case 47: goto st11;
|
|
202
264
|
}
|
|
203
265
|
if ( 9 <= (*p) && (*p) <= 10 )
|
|
204
266
|
goto st10;
|
|
205
|
-
goto
|
|
267
|
+
goto st0;
|
|
206
268
|
st11:
|
|
207
269
|
if ( ++p == pe )
|
|
208
|
-
goto
|
|
270
|
+
goto _test_eof11;
|
|
209
271
|
case 11:
|
|
210
272
|
switch( (*p) ) {
|
|
211
273
|
case 42: goto st12;
|
|
212
274
|
case 47: goto st14;
|
|
213
275
|
}
|
|
214
|
-
goto
|
|
276
|
+
goto st0;
|
|
215
277
|
st12:
|
|
216
278
|
if ( ++p == pe )
|
|
217
|
-
goto
|
|
279
|
+
goto _test_eof12;
|
|
218
280
|
case 12:
|
|
219
281
|
if ( (*p) == 42 )
|
|
220
282
|
goto st13;
|
|
221
283
|
goto st12;
|
|
222
284
|
st13:
|
|
223
285
|
if ( ++p == pe )
|
|
224
|
-
goto
|
|
286
|
+
goto _test_eof13;
|
|
225
287
|
case 13:
|
|
226
288
|
switch( (*p) ) {
|
|
227
289
|
case 42: goto st13;
|
|
@@ -230,30 +292,30 @@ case 13:
|
|
|
230
292
|
goto st12;
|
|
231
293
|
st14:
|
|
232
294
|
if ( ++p == pe )
|
|
233
|
-
goto
|
|
295
|
+
goto _test_eof14;
|
|
234
296
|
case 14:
|
|
235
297
|
if ( (*p) == 10 )
|
|
236
298
|
goto st10;
|
|
237
299
|
goto st14;
|
|
238
300
|
st15:
|
|
239
301
|
if ( ++p == pe )
|
|
240
|
-
goto
|
|
302
|
+
goto _test_eof15;
|
|
241
303
|
case 15:
|
|
242
304
|
switch( (*p) ) {
|
|
243
305
|
case 42: goto st16;
|
|
244
306
|
case 47: goto st18;
|
|
245
307
|
}
|
|
246
|
-
goto
|
|
308
|
+
goto st0;
|
|
247
309
|
st16:
|
|
248
310
|
if ( ++p == pe )
|
|
249
|
-
goto
|
|
311
|
+
goto _test_eof16;
|
|
250
312
|
case 16:
|
|
251
313
|
if ( (*p) == 42 )
|
|
252
314
|
goto st17;
|
|
253
315
|
goto st16;
|
|
254
316
|
st17:
|
|
255
317
|
if ( ++p == pe )
|
|
256
|
-
goto
|
|
318
|
+
goto _test_eof17;
|
|
257
319
|
case 17:
|
|
258
320
|
switch( (*p) ) {
|
|
259
321
|
case 42: goto st17;
|
|
@@ -262,40 +324,40 @@ case 17:
|
|
|
262
324
|
goto st16;
|
|
263
325
|
st18:
|
|
264
326
|
if ( ++p == pe )
|
|
265
|
-
goto
|
|
327
|
+
goto _test_eof18;
|
|
266
328
|
case 18:
|
|
267
329
|
if ( (*p) == 10 )
|
|
268
330
|
goto st9;
|
|
269
331
|
goto st18;
|
|
270
|
-
|
|
271
|
-
#line
|
|
272
|
-
{ goto
|
|
332
|
+
tr4:
|
|
333
|
+
#line 134 "parser.rl"
|
|
334
|
+
{ p--; {p++; cs = 27; goto _out;} }
|
|
273
335
|
goto st27;
|
|
274
336
|
st27:
|
|
275
337
|
if ( ++p == pe )
|
|
276
|
-
goto
|
|
338
|
+
goto _test_eof27;
|
|
277
339
|
case 27:
|
|
278
|
-
#line
|
|
279
|
-
goto
|
|
340
|
+
#line 340 "parser.c"
|
|
341
|
+
goto st0;
|
|
280
342
|
st19:
|
|
281
343
|
if ( ++p == pe )
|
|
282
|
-
goto
|
|
344
|
+
goto _test_eof19;
|
|
283
345
|
case 19:
|
|
284
346
|
switch( (*p) ) {
|
|
285
347
|
case 42: goto st20;
|
|
286
348
|
case 47: goto st22;
|
|
287
349
|
}
|
|
288
|
-
goto
|
|
350
|
+
goto st0;
|
|
289
351
|
st20:
|
|
290
352
|
if ( ++p == pe )
|
|
291
|
-
goto
|
|
353
|
+
goto _test_eof20;
|
|
292
354
|
case 20:
|
|
293
355
|
if ( (*p) == 42 )
|
|
294
356
|
goto st21;
|
|
295
357
|
goto st20;
|
|
296
358
|
st21:
|
|
297
359
|
if ( ++p == pe )
|
|
298
|
-
goto
|
|
360
|
+
goto _test_eof21;
|
|
299
361
|
case 21:
|
|
300
362
|
switch( (*p) ) {
|
|
301
363
|
case 42: goto st21;
|
|
@@ -304,30 +366,30 @@ case 21:
|
|
|
304
366
|
goto st20;
|
|
305
367
|
st22:
|
|
306
368
|
if ( ++p == pe )
|
|
307
|
-
goto
|
|
369
|
+
goto _test_eof22;
|
|
308
370
|
case 22:
|
|
309
371
|
if ( (*p) == 10 )
|
|
310
372
|
goto st8;
|
|
311
373
|
goto st22;
|
|
312
374
|
st23:
|
|
313
375
|
if ( ++p == pe )
|
|
314
|
-
goto
|
|
376
|
+
goto _test_eof23;
|
|
315
377
|
case 23:
|
|
316
378
|
switch( (*p) ) {
|
|
317
379
|
case 42: goto st24;
|
|
318
380
|
case 47: goto st26;
|
|
319
381
|
}
|
|
320
|
-
goto
|
|
382
|
+
goto st0;
|
|
321
383
|
st24:
|
|
322
384
|
if ( ++p == pe )
|
|
323
|
-
goto
|
|
385
|
+
goto _test_eof24;
|
|
324
386
|
case 24:
|
|
325
387
|
if ( (*p) == 42 )
|
|
326
388
|
goto st25;
|
|
327
389
|
goto st24;
|
|
328
390
|
st25:
|
|
329
391
|
if ( ++p == pe )
|
|
330
|
-
goto
|
|
392
|
+
goto _test_eof25;
|
|
331
393
|
case 25:
|
|
332
394
|
switch( (*p) ) {
|
|
333
395
|
case 42: goto st25;
|
|
@@ -336,50 +398,53 @@ case 25:
|
|
|
336
398
|
goto st24;
|
|
337
399
|
st26:
|
|
338
400
|
if ( ++p == pe )
|
|
339
|
-
goto
|
|
401
|
+
goto _test_eof26;
|
|
340
402
|
case 26:
|
|
341
403
|
if ( (*p) == 10 )
|
|
342
404
|
goto st2;
|
|
343
405
|
goto st26;
|
|
344
406
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
407
|
+
_test_eof2: cs = 2; goto _test_eof;
|
|
408
|
+
_test_eof3: cs = 3; goto _test_eof;
|
|
409
|
+
_test_eof4: cs = 4; goto _test_eof;
|
|
410
|
+
_test_eof5: cs = 5; goto _test_eof;
|
|
411
|
+
_test_eof6: cs = 6; goto _test_eof;
|
|
412
|
+
_test_eof7: cs = 7; goto _test_eof;
|
|
413
|
+
_test_eof8: cs = 8; goto _test_eof;
|
|
414
|
+
_test_eof9: cs = 9; goto _test_eof;
|
|
415
|
+
_test_eof10: cs = 10; goto _test_eof;
|
|
416
|
+
_test_eof11: cs = 11; goto _test_eof;
|
|
417
|
+
_test_eof12: cs = 12; goto _test_eof;
|
|
418
|
+
_test_eof13: cs = 13; goto _test_eof;
|
|
419
|
+
_test_eof14: cs = 14; goto _test_eof;
|
|
420
|
+
_test_eof15: cs = 15; goto _test_eof;
|
|
421
|
+
_test_eof16: cs = 16; goto _test_eof;
|
|
422
|
+
_test_eof17: cs = 17; goto _test_eof;
|
|
423
|
+
_test_eof18: cs = 18; goto _test_eof;
|
|
424
|
+
_test_eof27: cs = 27; goto _test_eof;
|
|
425
|
+
_test_eof19: cs = 19; goto _test_eof;
|
|
426
|
+
_test_eof20: cs = 20; goto _test_eof;
|
|
427
|
+
_test_eof21: cs = 21; goto _test_eof;
|
|
428
|
+
_test_eof22: cs = 22; goto _test_eof;
|
|
429
|
+
_test_eof23: cs = 23; goto _test_eof;
|
|
430
|
+
_test_eof24: cs = 24; goto _test_eof;
|
|
431
|
+
_test_eof25: cs = 25; goto _test_eof;
|
|
432
|
+
_test_eof26: cs = 26; goto _test_eof;
|
|
433
|
+
|
|
434
|
+
_test_eof: {}
|
|
373
435
|
_out: {}
|
|
374
436
|
}
|
|
375
|
-
|
|
437
|
+
|
|
438
|
+
#line 159 "parser.rl"
|
|
376
439
|
|
|
377
440
|
if (cs >= JSON_object_first_final) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
441
|
+
if (RTEST(json->create_id)) {
|
|
442
|
+
VALUE klassname = rb_hash_aref(*result, json->create_id);
|
|
443
|
+
if (!NIL_P(klassname)) {
|
|
444
|
+
VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, klassname);
|
|
445
|
+
if RTEST(rb_funcall(klass, i_json_creatable_p, 0)) {
|
|
446
|
+
*result = rb_funcall(klass, i_json_create, 1, *result);
|
|
447
|
+
}
|
|
383
448
|
}
|
|
384
449
|
}
|
|
385
450
|
return p + 1;
|
|
@@ -389,14 +454,15 @@ case 26:
|
|
|
389
454
|
}
|
|
390
455
|
|
|
391
456
|
|
|
392
|
-
#line
|
|
393
|
-
static const int JSON_value_start =
|
|
457
|
+
#line 457 "parser.c"
|
|
458
|
+
static const int JSON_value_start = 1;
|
|
459
|
+
static const int JSON_value_first_final = 21;
|
|
460
|
+
static const int JSON_value_error = 0;
|
|
394
461
|
|
|
395
|
-
static const int
|
|
462
|
+
static const int JSON_value_en_main = 1;
|
|
396
463
|
|
|
397
|
-
static const int JSON_value_error = 1;
|
|
398
464
|
|
|
399
|
-
#line
|
|
465
|
+
#line 257 "parser.rl"
|
|
400
466
|
|
|
401
467
|
|
|
402
468
|
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
|
@@ -404,178 +470,290 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
|
404
470
|
int cs = EVIL;
|
|
405
471
|
|
|
406
472
|
|
|
407
|
-
#line
|
|
473
|
+
#line 473 "parser.c"
|
|
408
474
|
{
|
|
409
475
|
cs = JSON_value_start;
|
|
410
476
|
}
|
|
411
|
-
|
|
477
|
+
|
|
478
|
+
#line 264 "parser.rl"
|
|
412
479
|
|
|
413
|
-
#line
|
|
480
|
+
#line 480 "parser.c"
|
|
414
481
|
{
|
|
415
482
|
if ( p == pe )
|
|
416
|
-
goto
|
|
483
|
+
goto _test_eof;
|
|
417
484
|
switch ( cs )
|
|
418
485
|
{
|
|
419
|
-
case
|
|
486
|
+
case 1:
|
|
420
487
|
switch( (*p) ) {
|
|
421
|
-
case 34: goto
|
|
422
|
-
case 45: goto
|
|
423
|
-
case
|
|
424
|
-
case
|
|
425
|
-
case
|
|
426
|
-
case
|
|
427
|
-
case
|
|
488
|
+
case 34: goto tr0;
|
|
489
|
+
case 45: goto tr2;
|
|
490
|
+
case 73: goto st2;
|
|
491
|
+
case 78: goto st9;
|
|
492
|
+
case 91: goto tr5;
|
|
493
|
+
case 102: goto st11;
|
|
494
|
+
case 110: goto st15;
|
|
495
|
+
case 116: goto st18;
|
|
496
|
+
case 123: goto tr9;
|
|
428
497
|
}
|
|
429
498
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
430
|
-
goto
|
|
431
|
-
goto
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
*result = Qnil;
|
|
438
|
-
}
|
|
439
|
-
goto st12;
|
|
440
|
-
tr6:
|
|
441
|
-
#line 126 "parser.rl"
|
|
442
|
-
{
|
|
443
|
-
*result = Qfalse;
|
|
444
|
-
}
|
|
445
|
-
goto st12;
|
|
446
|
-
tr7:
|
|
447
|
-
#line 129 "parser.rl"
|
|
448
|
-
{
|
|
449
|
-
*result = Qtrue;
|
|
450
|
-
}
|
|
451
|
-
goto st12;
|
|
452
|
-
tr9:
|
|
453
|
-
#line 132 "parser.rl"
|
|
499
|
+
goto tr2;
|
|
500
|
+
goto st0;
|
|
501
|
+
st0:
|
|
502
|
+
cs = 0;
|
|
503
|
+
goto _out;
|
|
504
|
+
tr0:
|
|
505
|
+
#line 205 "parser.rl"
|
|
454
506
|
{
|
|
455
507
|
char *np = JSON_parse_string(json, p, pe, result);
|
|
456
|
-
if (np == NULL) goto
|
|
508
|
+
if (np == NULL) { p--; {p++; cs = 21; goto _out;} } else {p = (( np))-1;}
|
|
457
509
|
}
|
|
458
|
-
goto
|
|
459
|
-
|
|
460
|
-
#line
|
|
510
|
+
goto st21;
|
|
511
|
+
tr2:
|
|
512
|
+
#line 210 "parser.rl"
|
|
461
513
|
{
|
|
462
514
|
char *np;
|
|
515
|
+
if(pe > p + 9 && !strncmp(MinusInfinity, p, 9)) {
|
|
516
|
+
if (json->allow_nan) {
|
|
517
|
+
*result = CMinusInfinity;
|
|
518
|
+
{p = (( p + 10))-1;}
|
|
519
|
+
p--; {p++; cs = 21; goto _out;}
|
|
520
|
+
} else {
|
|
521
|
+
rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
463
524
|
np = JSON_parse_float(json, p, pe, result);
|
|
464
525
|
if (np != NULL) {p = (( np))-1;}
|
|
465
526
|
np = JSON_parse_integer(json, p, pe, result);
|
|
466
527
|
if (np != NULL) {p = (( np))-1;}
|
|
467
|
-
goto
|
|
528
|
+
p--; {p++; cs = 21; goto _out;}
|
|
468
529
|
}
|
|
469
|
-
goto
|
|
470
|
-
|
|
471
|
-
#line
|
|
530
|
+
goto st21;
|
|
531
|
+
tr5:
|
|
532
|
+
#line 228 "parser.rl"
|
|
472
533
|
{
|
|
473
|
-
char *np
|
|
474
|
-
|
|
534
|
+
char *np;
|
|
535
|
+
json->current_nesting++;
|
|
536
|
+
np = JSON_parse_array(json, p, pe, result);
|
|
537
|
+
json->current_nesting--;
|
|
538
|
+
if (np == NULL) { p--; {p++; cs = 21; goto _out;} } else {p = (( np))-1;}
|
|
475
539
|
}
|
|
476
|
-
goto
|
|
477
|
-
|
|
478
|
-
#line
|
|
540
|
+
goto st21;
|
|
541
|
+
tr9:
|
|
542
|
+
#line 236 "parser.rl"
|
|
479
543
|
{
|
|
480
|
-
char *np
|
|
481
|
-
|
|
544
|
+
char *np;
|
|
545
|
+
json->current_nesting++;
|
|
546
|
+
np = JSON_parse_object(json, p, pe, result);
|
|
547
|
+
json->current_nesting--;
|
|
548
|
+
if (np == NULL) { p--; {p++; cs = 21; goto _out;} } else {p = (( np))-1;}
|
|
482
549
|
}
|
|
483
|
-
goto
|
|
484
|
-
|
|
550
|
+
goto st21;
|
|
551
|
+
tr16:
|
|
552
|
+
#line 198 "parser.rl"
|
|
553
|
+
{
|
|
554
|
+
if (json->allow_nan) {
|
|
555
|
+
*result = CInfinity;
|
|
556
|
+
} else {
|
|
557
|
+
rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p - 8);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
goto st21;
|
|
561
|
+
tr18:
|
|
562
|
+
#line 191 "parser.rl"
|
|
563
|
+
{
|
|
564
|
+
if (json->allow_nan) {
|
|
565
|
+
*result = CNaN;
|
|
566
|
+
} else {
|
|
567
|
+
rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p - 2);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
goto st21;
|
|
571
|
+
tr22:
|
|
572
|
+
#line 185 "parser.rl"
|
|
573
|
+
{
|
|
574
|
+
*result = Qfalse;
|
|
575
|
+
}
|
|
576
|
+
goto st21;
|
|
577
|
+
tr25:
|
|
578
|
+
#line 182 "parser.rl"
|
|
579
|
+
{
|
|
580
|
+
*result = Qnil;
|
|
581
|
+
}
|
|
582
|
+
goto st21;
|
|
583
|
+
tr28:
|
|
584
|
+
#line 188 "parser.rl"
|
|
585
|
+
{
|
|
586
|
+
*result = Qtrue;
|
|
587
|
+
}
|
|
588
|
+
goto st21;
|
|
589
|
+
st21:
|
|
485
590
|
if ( ++p == pe )
|
|
486
|
-
goto
|
|
487
|
-
case
|
|
488
|
-
#line
|
|
489
|
-
{ goto
|
|
490
|
-
#line
|
|
491
|
-
goto
|
|
591
|
+
goto _test_eof21;
|
|
592
|
+
case 21:
|
|
593
|
+
#line 244 "parser.rl"
|
|
594
|
+
{ p--; {p++; cs = 21; goto _out;} }
|
|
595
|
+
#line 595 "parser.c"
|
|
596
|
+
goto st0;
|
|
492
597
|
st2:
|
|
493
598
|
if ( ++p == pe )
|
|
494
|
-
goto
|
|
599
|
+
goto _test_eof2;
|
|
495
600
|
case 2:
|
|
496
|
-
if ( (*p) ==
|
|
601
|
+
if ( (*p) == 110 )
|
|
497
602
|
goto st3;
|
|
498
|
-
goto
|
|
603
|
+
goto st0;
|
|
499
604
|
st3:
|
|
500
605
|
if ( ++p == pe )
|
|
501
|
-
goto
|
|
606
|
+
goto _test_eof3;
|
|
502
607
|
case 3:
|
|
503
|
-
if ( (*p) ==
|
|
608
|
+
if ( (*p) == 102 )
|
|
504
609
|
goto st4;
|
|
505
|
-
goto
|
|
610
|
+
goto st0;
|
|
506
611
|
st4:
|
|
507
612
|
if ( ++p == pe )
|
|
508
|
-
goto
|
|
613
|
+
goto _test_eof4;
|
|
509
614
|
case 4:
|
|
510
|
-
if ( (*p) ==
|
|
615
|
+
if ( (*p) == 105 )
|
|
511
616
|
goto st5;
|
|
512
|
-
goto
|
|
617
|
+
goto st0;
|
|
513
618
|
st5:
|
|
514
619
|
if ( ++p == pe )
|
|
515
|
-
goto
|
|
620
|
+
goto _test_eof5;
|
|
516
621
|
case 5:
|
|
517
|
-
if ( (*p) ==
|
|
518
|
-
goto
|
|
519
|
-
goto
|
|
622
|
+
if ( (*p) == 110 )
|
|
623
|
+
goto st6;
|
|
624
|
+
goto st0;
|
|
520
625
|
st6:
|
|
521
626
|
if ( ++p == pe )
|
|
522
|
-
goto
|
|
627
|
+
goto _test_eof6;
|
|
523
628
|
case 6:
|
|
524
|
-
if ( (*p) ==
|
|
629
|
+
if ( (*p) == 105 )
|
|
525
630
|
goto st7;
|
|
526
|
-
goto
|
|
631
|
+
goto st0;
|
|
527
632
|
st7:
|
|
528
633
|
if ( ++p == pe )
|
|
529
|
-
goto
|
|
634
|
+
goto _test_eof7;
|
|
530
635
|
case 7:
|
|
531
|
-
if ( (*p) ==
|
|
636
|
+
if ( (*p) == 116 )
|
|
532
637
|
goto st8;
|
|
533
|
-
goto
|
|
638
|
+
goto st0;
|
|
534
639
|
st8:
|
|
535
640
|
if ( ++p == pe )
|
|
536
|
-
goto
|
|
641
|
+
goto _test_eof8;
|
|
537
642
|
case 8:
|
|
538
|
-
if ( (*p) ==
|
|
539
|
-
goto
|
|
540
|
-
goto
|
|
643
|
+
if ( (*p) == 121 )
|
|
644
|
+
goto tr16;
|
|
645
|
+
goto st0;
|
|
541
646
|
st9:
|
|
542
647
|
if ( ++p == pe )
|
|
543
|
-
goto
|
|
648
|
+
goto _test_eof9;
|
|
544
649
|
case 9:
|
|
545
|
-
if ( (*p) ==
|
|
650
|
+
if ( (*p) == 97 )
|
|
546
651
|
goto st10;
|
|
547
|
-
goto
|
|
652
|
+
goto st0;
|
|
548
653
|
st10:
|
|
549
654
|
if ( ++p == pe )
|
|
550
|
-
goto
|
|
655
|
+
goto _test_eof10;
|
|
551
656
|
case 10:
|
|
552
|
-
if ( (*p) ==
|
|
553
|
-
goto
|
|
554
|
-
goto
|
|
657
|
+
if ( (*p) == 78 )
|
|
658
|
+
goto tr18;
|
|
659
|
+
goto st0;
|
|
555
660
|
st11:
|
|
556
661
|
if ( ++p == pe )
|
|
557
|
-
goto
|
|
662
|
+
goto _test_eof11;
|
|
558
663
|
case 11:
|
|
664
|
+
if ( (*p) == 97 )
|
|
665
|
+
goto st12;
|
|
666
|
+
goto st0;
|
|
667
|
+
st12:
|
|
668
|
+
if ( ++p == pe )
|
|
669
|
+
goto _test_eof12;
|
|
670
|
+
case 12:
|
|
671
|
+
if ( (*p) == 108 )
|
|
672
|
+
goto st13;
|
|
673
|
+
goto st0;
|
|
674
|
+
st13:
|
|
675
|
+
if ( ++p == pe )
|
|
676
|
+
goto _test_eof13;
|
|
677
|
+
case 13:
|
|
678
|
+
if ( (*p) == 115 )
|
|
679
|
+
goto st14;
|
|
680
|
+
goto st0;
|
|
681
|
+
st14:
|
|
682
|
+
if ( ++p == pe )
|
|
683
|
+
goto _test_eof14;
|
|
684
|
+
case 14:
|
|
685
|
+
if ( (*p) == 101 )
|
|
686
|
+
goto tr22;
|
|
687
|
+
goto st0;
|
|
688
|
+
st15:
|
|
689
|
+
if ( ++p == pe )
|
|
690
|
+
goto _test_eof15;
|
|
691
|
+
case 15:
|
|
692
|
+
if ( (*p) == 117 )
|
|
693
|
+
goto st16;
|
|
694
|
+
goto st0;
|
|
695
|
+
st16:
|
|
696
|
+
if ( ++p == pe )
|
|
697
|
+
goto _test_eof16;
|
|
698
|
+
case 16:
|
|
699
|
+
if ( (*p) == 108 )
|
|
700
|
+
goto st17;
|
|
701
|
+
goto st0;
|
|
702
|
+
st17:
|
|
703
|
+
if ( ++p == pe )
|
|
704
|
+
goto _test_eof17;
|
|
705
|
+
case 17:
|
|
706
|
+
if ( (*p) == 108 )
|
|
707
|
+
goto tr25;
|
|
708
|
+
goto st0;
|
|
709
|
+
st18:
|
|
710
|
+
if ( ++p == pe )
|
|
711
|
+
goto _test_eof18;
|
|
712
|
+
case 18:
|
|
713
|
+
if ( (*p) == 114 )
|
|
714
|
+
goto st19;
|
|
715
|
+
goto st0;
|
|
716
|
+
st19:
|
|
717
|
+
if ( ++p == pe )
|
|
718
|
+
goto _test_eof19;
|
|
719
|
+
case 19:
|
|
720
|
+
if ( (*p) == 117 )
|
|
721
|
+
goto st20;
|
|
722
|
+
goto st0;
|
|
723
|
+
st20:
|
|
724
|
+
if ( ++p == pe )
|
|
725
|
+
goto _test_eof20;
|
|
726
|
+
case 20:
|
|
559
727
|
if ( (*p) == 101 )
|
|
560
|
-
goto
|
|
561
|
-
goto
|
|
728
|
+
goto tr28;
|
|
729
|
+
goto st0;
|
|
562
730
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
731
|
+
_test_eof21: cs = 21; goto _test_eof;
|
|
732
|
+
_test_eof2: cs = 2; goto _test_eof;
|
|
733
|
+
_test_eof3: cs = 3; goto _test_eof;
|
|
734
|
+
_test_eof4: cs = 4; goto _test_eof;
|
|
735
|
+
_test_eof5: cs = 5; goto _test_eof;
|
|
736
|
+
_test_eof6: cs = 6; goto _test_eof;
|
|
737
|
+
_test_eof7: cs = 7; goto _test_eof;
|
|
738
|
+
_test_eof8: cs = 8; goto _test_eof;
|
|
739
|
+
_test_eof9: cs = 9; goto _test_eof;
|
|
740
|
+
_test_eof10: cs = 10; goto _test_eof;
|
|
741
|
+
_test_eof11: cs = 11; goto _test_eof;
|
|
742
|
+
_test_eof12: cs = 12; goto _test_eof;
|
|
743
|
+
_test_eof13: cs = 13; goto _test_eof;
|
|
744
|
+
_test_eof14: cs = 14; goto _test_eof;
|
|
745
|
+
_test_eof15: cs = 15; goto _test_eof;
|
|
746
|
+
_test_eof16: cs = 16; goto _test_eof;
|
|
747
|
+
_test_eof17: cs = 17; goto _test_eof;
|
|
748
|
+
_test_eof18: cs = 18; goto _test_eof;
|
|
749
|
+
_test_eof19: cs = 19; goto _test_eof;
|
|
750
|
+
_test_eof20: cs = 20; goto _test_eof;
|
|
751
|
+
|
|
752
|
+
_test_eof: {}
|
|
576
753
|
_out: {}
|
|
577
754
|
}
|
|
578
|
-
|
|
755
|
+
|
|
756
|
+
#line 265 "parser.rl"
|
|
579
757
|
|
|
580
758
|
if (cs >= JSON_value_first_final) {
|
|
581
759
|
return p;
|
|
@@ -585,14 +763,15 @@ case 11:
|
|
|
585
763
|
}
|
|
586
764
|
|
|
587
765
|
|
|
588
|
-
#line
|
|
589
|
-
static const int JSON_integer_start =
|
|
590
|
-
|
|
766
|
+
#line 766 "parser.c"
|
|
767
|
+
static const int JSON_integer_start = 1;
|
|
591
768
|
static const int JSON_integer_first_final = 5;
|
|
769
|
+
static const int JSON_integer_error = 0;
|
|
592
770
|
|
|
593
|
-
static const int
|
|
771
|
+
static const int JSON_integer_en_main = 1;
|
|
594
772
|
|
|
595
|
-
|
|
773
|
+
|
|
774
|
+
#line 281 "parser.rl"
|
|
596
775
|
|
|
597
776
|
|
|
598
777
|
static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
|
@@ -600,72 +779,75 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
|
|
|
600
779
|
int cs = EVIL;
|
|
601
780
|
|
|
602
781
|
|
|
603
|
-
#line
|
|
782
|
+
#line 782 "parser.c"
|
|
604
783
|
{
|
|
605
784
|
cs = JSON_integer_start;
|
|
606
785
|
}
|
|
607
|
-
|
|
786
|
+
|
|
787
|
+
#line 288 "parser.rl"
|
|
608
788
|
json->memo = p;
|
|
609
789
|
|
|
610
|
-
#line
|
|
790
|
+
#line 790 "parser.c"
|
|
611
791
|
{
|
|
612
792
|
if ( p == pe )
|
|
613
|
-
goto
|
|
793
|
+
goto _test_eof;
|
|
614
794
|
switch ( cs )
|
|
615
795
|
{
|
|
616
|
-
case
|
|
796
|
+
case 1:
|
|
617
797
|
switch( (*p) ) {
|
|
618
798
|
case 45: goto st2;
|
|
619
799
|
case 48: goto st3;
|
|
620
800
|
}
|
|
621
801
|
if ( 49 <= (*p) && (*p) <= 57 )
|
|
622
802
|
goto st4;
|
|
623
|
-
goto
|
|
624
|
-
|
|
625
|
-
|
|
803
|
+
goto st0;
|
|
804
|
+
st0:
|
|
805
|
+
cs = 0;
|
|
806
|
+
goto _out;
|
|
626
807
|
st2:
|
|
627
808
|
if ( ++p == pe )
|
|
628
|
-
goto
|
|
809
|
+
goto _test_eof2;
|
|
629
810
|
case 2:
|
|
630
811
|
if ( (*p) == 48 )
|
|
631
812
|
goto st3;
|
|
632
813
|
if ( 49 <= (*p) && (*p) <= 57 )
|
|
633
814
|
goto st4;
|
|
634
|
-
goto
|
|
815
|
+
goto st0;
|
|
635
816
|
st3:
|
|
636
817
|
if ( ++p == pe )
|
|
637
|
-
goto
|
|
818
|
+
goto _test_eof3;
|
|
638
819
|
case 3:
|
|
639
820
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
640
|
-
goto
|
|
821
|
+
goto st0;
|
|
641
822
|
goto tr4;
|
|
642
823
|
tr4:
|
|
643
|
-
#line
|
|
644
|
-
{ goto
|
|
824
|
+
#line 278 "parser.rl"
|
|
825
|
+
{ p--; {p++; cs = 5; goto _out;} }
|
|
645
826
|
goto st5;
|
|
646
827
|
st5:
|
|
647
828
|
if ( ++p == pe )
|
|
648
|
-
goto
|
|
829
|
+
goto _test_eof5;
|
|
649
830
|
case 5:
|
|
650
|
-
#line
|
|
651
|
-
goto
|
|
831
|
+
#line 831 "parser.c"
|
|
832
|
+
goto st0;
|
|
652
833
|
st4:
|
|
653
834
|
if ( ++p == pe )
|
|
654
|
-
goto
|
|
835
|
+
goto _test_eof4;
|
|
655
836
|
case 4:
|
|
656
837
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
657
838
|
goto st4;
|
|
658
839
|
goto tr4;
|
|
659
840
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
_out4: cs = 4; goto _out;
|
|
841
|
+
_test_eof2: cs = 2; goto _test_eof;
|
|
842
|
+
_test_eof3: cs = 3; goto _test_eof;
|
|
843
|
+
_test_eof5: cs = 5; goto _test_eof;
|
|
844
|
+
_test_eof4: cs = 4; goto _test_eof;
|
|
665
845
|
|
|
846
|
+
_test_eof: {}
|
|
666
847
|
_out: {}
|
|
667
848
|
}
|
|
668
|
-
|
|
849
|
+
|
|
850
|
+
#line 290 "parser.rl"
|
|
669
851
|
|
|
670
852
|
if (cs >= JSON_integer_first_final) {
|
|
671
853
|
long len = p - json->memo;
|
|
@@ -677,14 +859,15 @@ case 4:
|
|
|
677
859
|
}
|
|
678
860
|
|
|
679
861
|
|
|
680
|
-
#line
|
|
681
|
-
static const int JSON_float_start =
|
|
682
|
-
|
|
862
|
+
#line 862 "parser.c"
|
|
863
|
+
static const int JSON_float_start = 1;
|
|
683
864
|
static const int JSON_float_first_final = 10;
|
|
865
|
+
static const int JSON_float_error = 0;
|
|
684
866
|
|
|
685
|
-
static const int
|
|
867
|
+
static const int JSON_float_en_main = 1;
|
|
686
868
|
|
|
687
|
-
|
|
869
|
+
|
|
870
|
+
#line 312 "parser.rl"
|
|
688
871
|
|
|
689
872
|
|
|
690
873
|
static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
|
@@ -692,55 +875,60 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
|
692
875
|
int cs = EVIL;
|
|
693
876
|
|
|
694
877
|
|
|
695
|
-
#line
|
|
878
|
+
#line 878 "parser.c"
|
|
696
879
|
{
|
|
697
880
|
cs = JSON_float_start;
|
|
698
881
|
}
|
|
699
|
-
|
|
882
|
+
|
|
883
|
+
#line 319 "parser.rl"
|
|
700
884
|
json->memo = p;
|
|
701
885
|
|
|
702
|
-
#line
|
|
886
|
+
#line 886 "parser.c"
|
|
703
887
|
{
|
|
704
888
|
if ( p == pe )
|
|
705
|
-
goto
|
|
889
|
+
goto _test_eof;
|
|
706
890
|
switch ( cs )
|
|
707
891
|
{
|
|
708
|
-
case
|
|
892
|
+
case 1:
|
|
709
893
|
switch( (*p) ) {
|
|
710
894
|
case 45: goto st2;
|
|
711
895
|
case 48: goto st3;
|
|
712
896
|
}
|
|
713
897
|
if ( 49 <= (*p) && (*p) <= 57 )
|
|
714
898
|
goto st9;
|
|
715
|
-
goto
|
|
716
|
-
|
|
717
|
-
|
|
899
|
+
goto st0;
|
|
900
|
+
st0:
|
|
901
|
+
cs = 0;
|
|
902
|
+
goto _out;
|
|
718
903
|
st2:
|
|
719
904
|
if ( ++p == pe )
|
|
720
|
-
goto
|
|
905
|
+
goto _test_eof2;
|
|
721
906
|
case 2:
|
|
722
907
|
if ( (*p) == 48 )
|
|
723
908
|
goto st3;
|
|
724
909
|
if ( 49 <= (*p) && (*p) <= 57 )
|
|
725
910
|
goto st9;
|
|
726
|
-
goto
|
|
911
|
+
goto st0;
|
|
727
912
|
st3:
|
|
728
913
|
if ( ++p == pe )
|
|
729
|
-
goto
|
|
914
|
+
goto _test_eof3;
|
|
730
915
|
case 3:
|
|
731
|
-
|
|
732
|
-
goto st4;
|
|
733
|
-
|
|
916
|
+
switch( (*p) ) {
|
|
917
|
+
case 46: goto st4;
|
|
918
|
+
case 69: goto st6;
|
|
919
|
+
case 101: goto st6;
|
|
920
|
+
}
|
|
921
|
+
goto st0;
|
|
734
922
|
st4:
|
|
735
923
|
if ( ++p == pe )
|
|
736
|
-
goto
|
|
924
|
+
goto _test_eof4;
|
|
737
925
|
case 4:
|
|
738
926
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
739
927
|
goto st5;
|
|
740
|
-
goto
|
|
928
|
+
goto st0;
|
|
741
929
|
st5:
|
|
742
930
|
if ( ++p == pe )
|
|
743
|
-
goto
|
|
931
|
+
goto _test_eof5;
|
|
744
932
|
case 5:
|
|
745
933
|
switch( (*p) ) {
|
|
746
934
|
case 69: goto st6;
|
|
@@ -750,21 +938,21 @@ case 5:
|
|
|
750
938
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
751
939
|
goto st5;
|
|
752
940
|
} else if ( (*p) >= 45 )
|
|
753
|
-
goto
|
|
754
|
-
goto
|
|
755
|
-
|
|
756
|
-
#line
|
|
757
|
-
{ goto
|
|
941
|
+
goto st0;
|
|
942
|
+
goto tr7;
|
|
943
|
+
tr7:
|
|
944
|
+
#line 306 "parser.rl"
|
|
945
|
+
{ p--; {p++; cs = 10; goto _out;} }
|
|
758
946
|
goto st10;
|
|
759
947
|
st10:
|
|
760
948
|
if ( ++p == pe )
|
|
761
|
-
goto
|
|
949
|
+
goto _test_eof10;
|
|
762
950
|
case 10:
|
|
763
|
-
#line
|
|
764
|
-
goto
|
|
951
|
+
#line 951 "parser.c"
|
|
952
|
+
goto st0;
|
|
765
953
|
st6:
|
|
766
954
|
if ( ++p == pe )
|
|
767
|
-
goto
|
|
955
|
+
goto _test_eof6;
|
|
768
956
|
case 6:
|
|
769
957
|
switch( (*p) ) {
|
|
770
958
|
case 43: goto st7;
|
|
@@ -772,31 +960,31 @@ case 6:
|
|
|
772
960
|
}
|
|
773
961
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
774
962
|
goto st8;
|
|
775
|
-
goto
|
|
963
|
+
goto st0;
|
|
776
964
|
st7:
|
|
777
965
|
if ( ++p == pe )
|
|
778
|
-
goto
|
|
966
|
+
goto _test_eof7;
|
|
779
967
|
case 7:
|
|
780
968
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
781
969
|
goto st8;
|
|
782
|
-
goto
|
|
970
|
+
goto st0;
|
|
783
971
|
st8:
|
|
784
972
|
if ( ++p == pe )
|
|
785
|
-
goto
|
|
973
|
+
goto _test_eof8;
|
|
786
974
|
case 8:
|
|
787
975
|
switch( (*p) ) {
|
|
788
|
-
case 69: goto
|
|
789
|
-
case 101: goto
|
|
976
|
+
case 69: goto st0;
|
|
977
|
+
case 101: goto st0;
|
|
790
978
|
}
|
|
791
979
|
if ( (*p) > 46 ) {
|
|
792
980
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
793
981
|
goto st8;
|
|
794
982
|
} else if ( (*p) >= 45 )
|
|
795
|
-
goto
|
|
796
|
-
goto
|
|
983
|
+
goto st0;
|
|
984
|
+
goto tr7;
|
|
797
985
|
st9:
|
|
798
986
|
if ( ++p == pe )
|
|
799
|
-
goto
|
|
987
|
+
goto _test_eof9;
|
|
800
988
|
case 9:
|
|
801
989
|
switch( (*p) ) {
|
|
802
990
|
case 46: goto st4;
|
|
@@ -805,22 +993,23 @@ case 9:
|
|
|
805
993
|
}
|
|
806
994
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
807
995
|
goto st9;
|
|
808
|
-
goto
|
|
996
|
+
goto st0;
|
|
809
997
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
998
|
+
_test_eof2: cs = 2; goto _test_eof;
|
|
999
|
+
_test_eof3: cs = 3; goto _test_eof;
|
|
1000
|
+
_test_eof4: cs = 4; goto _test_eof;
|
|
1001
|
+
_test_eof5: cs = 5; goto _test_eof;
|
|
1002
|
+
_test_eof10: cs = 10; goto _test_eof;
|
|
1003
|
+
_test_eof6: cs = 6; goto _test_eof;
|
|
1004
|
+
_test_eof7: cs = 7; goto _test_eof;
|
|
1005
|
+
_test_eof8: cs = 8; goto _test_eof;
|
|
1006
|
+
_test_eof9: cs = 9; goto _test_eof;
|
|
1007
|
+
|
|
1008
|
+
_test_eof: {}
|
|
821
1009
|
_out: {}
|
|
822
1010
|
}
|
|
823
|
-
|
|
1011
|
+
|
|
1012
|
+
#line 321 "parser.rl"
|
|
824
1013
|
|
|
825
1014
|
if (cs >= JSON_float_first_final) {
|
|
826
1015
|
long len = p - json->memo;
|
|
@@ -833,70 +1022,80 @@ case 9:
|
|
|
833
1022
|
|
|
834
1023
|
|
|
835
1024
|
|
|
836
|
-
#line
|
|
837
|
-
static const int JSON_array_start =
|
|
838
|
-
|
|
1025
|
+
#line 1025 "parser.c"
|
|
1026
|
+
static const int JSON_array_start = 1;
|
|
839
1027
|
static const int JSON_array_first_final = 17;
|
|
1028
|
+
static const int JSON_array_error = 0;
|
|
840
1029
|
|
|
841
|
-
static const int
|
|
1030
|
+
static const int JSON_array_en_main = 1;
|
|
842
1031
|
|
|
843
|
-
|
|
1032
|
+
|
|
1033
|
+
#line 357 "parser.rl"
|
|
844
1034
|
|
|
845
1035
|
|
|
846
1036
|
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
|
847
1037
|
{
|
|
848
1038
|
int cs = EVIL;
|
|
849
|
-
|
|
1039
|
+
VALUE array_class = json->array_class;
|
|
1040
|
+
|
|
1041
|
+
if (json->max_nesting && json->current_nesting > json->max_nesting) {
|
|
1042
|
+
rb_raise(eNestingError, "nesting of %d is too deep", json->current_nesting);
|
|
1043
|
+
}
|
|
1044
|
+
*result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
|
|
850
1045
|
|
|
851
1046
|
|
|
852
|
-
#line
|
|
1047
|
+
#line 1047 "parser.c"
|
|
853
1048
|
{
|
|
854
1049
|
cs = JSON_array_start;
|
|
855
1050
|
}
|
|
856
|
-
|
|
1051
|
+
|
|
1052
|
+
#line 370 "parser.rl"
|
|
857
1053
|
|
|
858
|
-
#line
|
|
1054
|
+
#line 1054 "parser.c"
|
|
859
1055
|
{
|
|
860
1056
|
if ( p == pe )
|
|
861
|
-
goto
|
|
1057
|
+
goto _test_eof;
|
|
862
1058
|
switch ( cs )
|
|
863
1059
|
{
|
|
864
|
-
case
|
|
1060
|
+
case 1:
|
|
865
1061
|
if ( (*p) == 91 )
|
|
866
1062
|
goto st2;
|
|
867
|
-
goto
|
|
868
|
-
|
|
869
|
-
|
|
1063
|
+
goto st0;
|
|
1064
|
+
st0:
|
|
1065
|
+
cs = 0;
|
|
1066
|
+
goto _out;
|
|
870
1067
|
st2:
|
|
871
1068
|
if ( ++p == pe )
|
|
872
|
-
goto
|
|
1069
|
+
goto _test_eof2;
|
|
873
1070
|
case 2:
|
|
874
1071
|
switch( (*p) ) {
|
|
875
1072
|
case 13: goto st2;
|
|
876
1073
|
case 32: goto st2;
|
|
877
|
-
case 34: goto
|
|
878
|
-
case 45: goto
|
|
1074
|
+
case 34: goto tr2;
|
|
1075
|
+
case 45: goto tr2;
|
|
879
1076
|
case 47: goto st13;
|
|
880
|
-
case
|
|
881
|
-
case
|
|
882
|
-
case
|
|
883
|
-
case
|
|
884
|
-
case
|
|
885
|
-
case
|
|
1077
|
+
case 73: goto tr2;
|
|
1078
|
+
case 78: goto tr2;
|
|
1079
|
+
case 91: goto tr2;
|
|
1080
|
+
case 93: goto tr4;
|
|
1081
|
+
case 102: goto tr2;
|
|
1082
|
+
case 110: goto tr2;
|
|
1083
|
+
case 116: goto tr2;
|
|
1084
|
+
case 123: goto tr2;
|
|
886
1085
|
}
|
|
887
1086
|
if ( (*p) > 10 ) {
|
|
888
1087
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
889
|
-
goto
|
|
1088
|
+
goto tr2;
|
|
890
1089
|
} else if ( (*p) >= 9 )
|
|
891
1090
|
goto st2;
|
|
892
|
-
goto
|
|
893
|
-
|
|
894
|
-
#line
|
|
1091
|
+
goto st0;
|
|
1092
|
+
tr2:
|
|
1093
|
+
#line 338 "parser.rl"
|
|
895
1094
|
{
|
|
896
1095
|
VALUE v = Qnil;
|
|
897
1096
|
char *np = JSON_parse_value(json, p, pe, &v);
|
|
898
1097
|
if (np == NULL) {
|
|
899
|
-
goto
|
|
1098
|
+
p--; {p++; cs = 3; goto _out;}
|
|
900
1099
|
} else {
|
|
901
1100
|
rb_ary_push(*result, v);
|
|
902
1101
|
{p = (( np))-1;}
|
|
@@ -905,60 +1104,62 @@ tr8:
|
|
|
905
1104
|
goto st3;
|
|
906
1105
|
st3:
|
|
907
1106
|
if ( ++p == pe )
|
|
908
|
-
goto
|
|
1107
|
+
goto _test_eof3;
|
|
909
1108
|
case 3:
|
|
910
|
-
#line
|
|
1109
|
+
#line 1109 "parser.c"
|
|
911
1110
|
switch( (*p) ) {
|
|
912
1111
|
case 13: goto st3;
|
|
913
1112
|
case 32: goto st3;
|
|
914
1113
|
case 44: goto st4;
|
|
915
1114
|
case 47: goto st9;
|
|
916
|
-
case 93: goto
|
|
1115
|
+
case 93: goto tr4;
|
|
917
1116
|
}
|
|
918
1117
|
if ( 9 <= (*p) && (*p) <= 10 )
|
|
919
1118
|
goto st3;
|
|
920
|
-
goto
|
|
1119
|
+
goto st0;
|
|
921
1120
|
st4:
|
|
922
1121
|
if ( ++p == pe )
|
|
923
|
-
goto
|
|
1122
|
+
goto _test_eof4;
|
|
924
1123
|
case 4:
|
|
925
1124
|
switch( (*p) ) {
|
|
926
1125
|
case 13: goto st4;
|
|
927
1126
|
case 32: goto st4;
|
|
928
|
-
case 34: goto
|
|
929
|
-
case 45: goto
|
|
1127
|
+
case 34: goto tr2;
|
|
1128
|
+
case 45: goto tr2;
|
|
930
1129
|
case 47: goto st5;
|
|
931
|
-
case
|
|
932
|
-
case
|
|
933
|
-
case
|
|
934
|
-
case
|
|
935
|
-
case
|
|
1130
|
+
case 73: goto tr2;
|
|
1131
|
+
case 78: goto tr2;
|
|
1132
|
+
case 91: goto tr2;
|
|
1133
|
+
case 102: goto tr2;
|
|
1134
|
+
case 110: goto tr2;
|
|
1135
|
+
case 116: goto tr2;
|
|
1136
|
+
case 123: goto tr2;
|
|
936
1137
|
}
|
|
937
1138
|
if ( (*p) > 10 ) {
|
|
938
1139
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
939
|
-
goto
|
|
1140
|
+
goto tr2;
|
|
940
1141
|
} else if ( (*p) >= 9 )
|
|
941
1142
|
goto st4;
|
|
942
|
-
goto
|
|
1143
|
+
goto st0;
|
|
943
1144
|
st5:
|
|
944
1145
|
if ( ++p == pe )
|
|
945
|
-
goto
|
|
1146
|
+
goto _test_eof5;
|
|
946
1147
|
case 5:
|
|
947
1148
|
switch( (*p) ) {
|
|
948
1149
|
case 42: goto st6;
|
|
949
1150
|
case 47: goto st8;
|
|
950
1151
|
}
|
|
951
|
-
goto
|
|
1152
|
+
goto st0;
|
|
952
1153
|
st6:
|
|
953
1154
|
if ( ++p == pe )
|
|
954
|
-
goto
|
|
1155
|
+
goto _test_eof6;
|
|
955
1156
|
case 6:
|
|
956
1157
|
if ( (*p) == 42 )
|
|
957
1158
|
goto st7;
|
|
958
1159
|
goto st6;
|
|
959
1160
|
st7:
|
|
960
1161
|
if ( ++p == pe )
|
|
961
|
-
goto
|
|
1162
|
+
goto _test_eof7;
|
|
962
1163
|
case 7:
|
|
963
1164
|
switch( (*p) ) {
|
|
964
1165
|
case 42: goto st7;
|
|
@@ -967,30 +1168,30 @@ case 7:
|
|
|
967
1168
|
goto st6;
|
|
968
1169
|
st8:
|
|
969
1170
|
if ( ++p == pe )
|
|
970
|
-
goto
|
|
1171
|
+
goto _test_eof8;
|
|
971
1172
|
case 8:
|
|
972
1173
|
if ( (*p) == 10 )
|
|
973
1174
|
goto st4;
|
|
974
1175
|
goto st8;
|
|
975
1176
|
st9:
|
|
976
1177
|
if ( ++p == pe )
|
|
977
|
-
goto
|
|
1178
|
+
goto _test_eof9;
|
|
978
1179
|
case 9:
|
|
979
1180
|
switch( (*p) ) {
|
|
980
1181
|
case 42: goto st10;
|
|
981
1182
|
case 47: goto st12;
|
|
982
1183
|
}
|
|
983
|
-
goto
|
|
1184
|
+
goto st0;
|
|
984
1185
|
st10:
|
|
985
1186
|
if ( ++p == pe )
|
|
986
|
-
goto
|
|
1187
|
+
goto _test_eof10;
|
|
987
1188
|
case 10:
|
|
988
1189
|
if ( (*p) == 42 )
|
|
989
1190
|
goto st11;
|
|
990
1191
|
goto st10;
|
|
991
1192
|
st11:
|
|
992
1193
|
if ( ++p == pe )
|
|
993
|
-
goto
|
|
1194
|
+
goto _test_eof11;
|
|
994
1195
|
case 11:
|
|
995
1196
|
switch( (*p) ) {
|
|
996
1197
|
case 42: goto st11;
|
|
@@ -999,40 +1200,40 @@ case 11:
|
|
|
999
1200
|
goto st10;
|
|
1000
1201
|
st12:
|
|
1001
1202
|
if ( ++p == pe )
|
|
1002
|
-
goto
|
|
1203
|
+
goto _test_eof12;
|
|
1003
1204
|
case 12:
|
|
1004
1205
|
if ( (*p) == 10 )
|
|
1005
1206
|
goto st3;
|
|
1006
1207
|
goto st12;
|
|
1007
|
-
|
|
1008
|
-
#line
|
|
1009
|
-
{ goto
|
|
1208
|
+
tr4:
|
|
1209
|
+
#line 349 "parser.rl"
|
|
1210
|
+
{ p--; {p++; cs = 17; goto _out;} }
|
|
1010
1211
|
goto st17;
|
|
1011
1212
|
st17:
|
|
1012
1213
|
if ( ++p == pe )
|
|
1013
|
-
goto
|
|
1214
|
+
goto _test_eof17;
|
|
1014
1215
|
case 17:
|
|
1015
|
-
#line
|
|
1016
|
-
goto
|
|
1216
|
+
#line 1216 "parser.c"
|
|
1217
|
+
goto st0;
|
|
1017
1218
|
st13:
|
|
1018
1219
|
if ( ++p == pe )
|
|
1019
|
-
goto
|
|
1220
|
+
goto _test_eof13;
|
|
1020
1221
|
case 13:
|
|
1021
1222
|
switch( (*p) ) {
|
|
1022
1223
|
case 42: goto st14;
|
|
1023
1224
|
case 47: goto st16;
|
|
1024
1225
|
}
|
|
1025
|
-
goto
|
|
1226
|
+
goto st0;
|
|
1026
1227
|
st14:
|
|
1027
1228
|
if ( ++p == pe )
|
|
1028
|
-
goto
|
|
1229
|
+
goto _test_eof14;
|
|
1029
1230
|
case 14:
|
|
1030
1231
|
if ( (*p) == 42 )
|
|
1031
1232
|
goto st15;
|
|
1032
1233
|
goto st14;
|
|
1033
1234
|
st15:
|
|
1034
1235
|
if ( ++p == pe )
|
|
1035
|
-
goto
|
|
1236
|
+
goto _test_eof15;
|
|
1036
1237
|
case 15:
|
|
1037
1238
|
switch( (*p) ) {
|
|
1038
1239
|
case 42: goto st15;
|
|
@@ -1041,174 +1242,196 @@ case 15:
|
|
|
1041
1242
|
goto st14;
|
|
1042
1243
|
st16:
|
|
1043
1244
|
if ( ++p == pe )
|
|
1044
|
-
goto
|
|
1245
|
+
goto _test_eof16;
|
|
1045
1246
|
case 16:
|
|
1046
1247
|
if ( (*p) == 10 )
|
|
1047
1248
|
goto st2;
|
|
1048
1249
|
goto st16;
|
|
1049
1250
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1251
|
+
_test_eof2: cs = 2; goto _test_eof;
|
|
1252
|
+
_test_eof3: cs = 3; goto _test_eof;
|
|
1253
|
+
_test_eof4: cs = 4; goto _test_eof;
|
|
1254
|
+
_test_eof5: cs = 5; goto _test_eof;
|
|
1255
|
+
_test_eof6: cs = 6; goto _test_eof;
|
|
1256
|
+
_test_eof7: cs = 7; goto _test_eof;
|
|
1257
|
+
_test_eof8: cs = 8; goto _test_eof;
|
|
1258
|
+
_test_eof9: cs = 9; goto _test_eof;
|
|
1259
|
+
_test_eof10: cs = 10; goto _test_eof;
|
|
1260
|
+
_test_eof11: cs = 11; goto _test_eof;
|
|
1261
|
+
_test_eof12: cs = 12; goto _test_eof;
|
|
1262
|
+
_test_eof17: cs = 17; goto _test_eof;
|
|
1263
|
+
_test_eof13: cs = 13; goto _test_eof;
|
|
1264
|
+
_test_eof14: cs = 14; goto _test_eof;
|
|
1265
|
+
_test_eof15: cs = 15; goto _test_eof;
|
|
1266
|
+
_test_eof16: cs = 16; goto _test_eof;
|
|
1267
|
+
|
|
1268
|
+
_test_eof: {}
|
|
1068
1269
|
_out: {}
|
|
1069
1270
|
}
|
|
1070
|
-
|
|
1271
|
+
|
|
1272
|
+
#line 371 "parser.rl"
|
|
1071
1273
|
|
|
1072
1274
|
if(cs >= JSON_array_first_final) {
|
|
1073
1275
|
return p + 1;
|
|
1074
1276
|
} else {
|
|
1075
|
-
rb_raise(eParserError, "unexpected token at '%s'", p);
|
|
1277
|
+
rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p);
|
|
1278
|
+
return NULL;
|
|
1076
1279
|
}
|
|
1077
1280
|
}
|
|
1078
1281
|
|
|
1079
|
-
static VALUE
|
|
1282
|
+
static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
|
|
1080
1283
|
{
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1284
|
+
char *p = string, *pe = string, *unescape;
|
|
1285
|
+
int unescape_len;
|
|
1286
|
+
|
|
1287
|
+
while (pe < stringEnd) {
|
|
1288
|
+
if (*pe == '\\') {
|
|
1289
|
+
unescape = (char *) "?";
|
|
1290
|
+
unescape_len = 1;
|
|
1291
|
+
if (pe > p) rb_str_buf_cat(result, p, pe - p);
|
|
1292
|
+
switch (*++pe) {
|
|
1293
|
+
case 'n':
|
|
1294
|
+
unescape = (char *) "\n";
|
|
1295
|
+
break;
|
|
1296
|
+
case 'r':
|
|
1297
|
+
unescape = (char *) "\r";
|
|
1298
|
+
break;
|
|
1299
|
+
case 't':
|
|
1300
|
+
unescape = (char *) "\t";
|
|
1301
|
+
break;
|
|
1088
1302
|
case '"':
|
|
1303
|
+
unescape = (char *) "\"";
|
|
1304
|
+
break;
|
|
1089
1305
|
case '\\':
|
|
1090
|
-
|
|
1091
|
-
p++;
|
|
1306
|
+
unescape = (char *) "\\";
|
|
1092
1307
|
break;
|
|
1093
1308
|
case 'b':
|
|
1094
|
-
|
|
1095
|
-
p++;
|
|
1309
|
+
unescape = (char *) "\b";
|
|
1096
1310
|
break;
|
|
1097
1311
|
case 'f':
|
|
1098
|
-
|
|
1099
|
-
p++;
|
|
1100
|
-
break;
|
|
1101
|
-
case 'n':
|
|
1102
|
-
rb_str_buf_cat2(result, "\n");
|
|
1103
|
-
p++;
|
|
1104
|
-
break;
|
|
1105
|
-
case 'r':
|
|
1106
|
-
rb_str_buf_cat2(result, "\r");
|
|
1107
|
-
p++;
|
|
1108
|
-
break;
|
|
1109
|
-
case 't':
|
|
1110
|
-
rb_str_buf_cat2(result, "\t");
|
|
1111
|
-
p++;
|
|
1312
|
+
unescape = (char *) "\f";
|
|
1112
1313
|
break;
|
|
1113
1314
|
case 'u':
|
|
1114
|
-
if (
|
|
1315
|
+
if (pe > stringEnd - 4) {
|
|
1115
1316
|
return Qnil;
|
|
1116
1317
|
} else {
|
|
1117
|
-
|
|
1318
|
+
char buf[4];
|
|
1319
|
+
UTF32 ch = unescape_unicode((unsigned char *) ++pe);
|
|
1320
|
+
pe += 3;
|
|
1321
|
+
if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {
|
|
1322
|
+
pe++;
|
|
1323
|
+
if (pe > stringEnd - 6) return Qnil;
|
|
1324
|
+
if (pe[0] == '\\' && pe[1] == 'u') {
|
|
1325
|
+
UTF32 sur = unescape_unicode((unsigned char *) pe + 2);
|
|
1326
|
+
ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16)
|
|
1327
|
+
| (sur & 0x3FF));
|
|
1328
|
+
pe += 5;
|
|
1329
|
+
} else {
|
|
1330
|
+
unescape = (char *) "?";
|
|
1331
|
+
break;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
unescape_len = convert_UTF32_to_UTF8(buf, ch);
|
|
1335
|
+
unescape = buf;
|
|
1118
1336
|
}
|
|
1119
1337
|
break;
|
|
1338
|
+
default:
|
|
1339
|
+
p = pe;
|
|
1340
|
+
continue;
|
|
1120
1341
|
}
|
|
1342
|
+
rb_str_buf_cat(result, unescape, unescape_len);
|
|
1343
|
+
p = ++pe;
|
|
1121
1344
|
} else {
|
|
1122
|
-
|
|
1123
|
-
while (*q != '\\' && q < pe) q++;
|
|
1124
|
-
rb_str_buf_cat(result, p, q - p);
|
|
1125
|
-
p = q;
|
|
1345
|
+
pe++;
|
|
1126
1346
|
}
|
|
1127
1347
|
}
|
|
1348
|
+
rb_str_buf_cat(result, p, pe - p);
|
|
1128
1349
|
return result;
|
|
1129
1350
|
}
|
|
1130
1351
|
|
|
1131
1352
|
|
|
1132
|
-
#line
|
|
1133
|
-
static const int JSON_string_start =
|
|
1134
|
-
|
|
1353
|
+
#line 1353 "parser.c"
|
|
1354
|
+
static const int JSON_string_start = 1;
|
|
1135
1355
|
static const int JSON_string_first_final = 8;
|
|
1356
|
+
static const int JSON_string_error = 0;
|
|
1136
1357
|
|
|
1137
|
-
static const int
|
|
1358
|
+
static const int JSON_string_en_main = 1;
|
|
1138
1359
|
|
|
1139
|
-
|
|
1360
|
+
|
|
1361
|
+
#line 470 "parser.rl"
|
|
1140
1362
|
|
|
1141
1363
|
|
|
1142
1364
|
static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
|
1143
1365
|
{
|
|
1144
1366
|
int cs = EVIL;
|
|
1145
1367
|
|
|
1146
|
-
*result =
|
|
1368
|
+
*result = rb_str_buf_new(0);
|
|
1147
1369
|
|
|
1148
|
-
#line
|
|
1370
|
+
#line 1370 "parser.c"
|
|
1149
1371
|
{
|
|
1150
1372
|
cs = JSON_string_start;
|
|
1151
1373
|
}
|
|
1152
|
-
|
|
1374
|
+
|
|
1375
|
+
#line 478 "parser.rl"
|
|
1153
1376
|
json->memo = p;
|
|
1154
1377
|
|
|
1155
|
-
#line
|
|
1378
|
+
#line 1378 "parser.c"
|
|
1156
1379
|
{
|
|
1157
1380
|
if ( p == pe )
|
|
1158
|
-
goto
|
|
1381
|
+
goto _test_eof;
|
|
1159
1382
|
switch ( cs )
|
|
1160
1383
|
{
|
|
1161
|
-
case
|
|
1384
|
+
case 1:
|
|
1162
1385
|
if ( (*p) == 34 )
|
|
1163
1386
|
goto st2;
|
|
1164
|
-
goto
|
|
1165
|
-
|
|
1166
|
-
|
|
1387
|
+
goto st0;
|
|
1388
|
+
st0:
|
|
1389
|
+
cs = 0;
|
|
1390
|
+
goto _out;
|
|
1167
1391
|
st2:
|
|
1168
1392
|
if ( ++p == pe )
|
|
1169
|
-
goto
|
|
1393
|
+
goto _test_eof2;
|
|
1170
1394
|
case 2:
|
|
1171
1395
|
switch( (*p) ) {
|
|
1172
|
-
case 34: goto
|
|
1396
|
+
case 34: goto tr2;
|
|
1173
1397
|
case 92: goto st3;
|
|
1174
1398
|
}
|
|
1175
1399
|
if ( 0 <= (*p) && (*p) <= 31 )
|
|
1176
|
-
goto
|
|
1400
|
+
goto st0;
|
|
1177
1401
|
goto st2;
|
|
1178
|
-
|
|
1179
|
-
#line
|
|
1402
|
+
tr2:
|
|
1403
|
+
#line 456 "parser.rl"
|
|
1180
1404
|
{
|
|
1181
|
-
*result =
|
|
1182
|
-
if (NIL_P(*result))
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1405
|
+
*result = json_string_unescape(*result, json->memo + 1, p);
|
|
1406
|
+
if (NIL_P(*result)) {
|
|
1407
|
+
p--;
|
|
1408
|
+
{p++; cs = 8; goto _out;}
|
|
1409
|
+
} else {
|
|
1410
|
+
FORCE_UTF8(*result);
|
|
1411
|
+
{p = (( p + 1))-1;}
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
#line 467 "parser.rl"
|
|
1415
|
+
{ p--; {p++; cs = 8; goto _out;} }
|
|
1186
1416
|
goto st8;
|
|
1187
1417
|
st8:
|
|
1188
1418
|
if ( ++p == pe )
|
|
1189
|
-
goto
|
|
1419
|
+
goto _test_eof8;
|
|
1190
1420
|
case 8:
|
|
1191
|
-
#line
|
|
1192
|
-
goto
|
|
1421
|
+
#line 1421 "parser.c"
|
|
1422
|
+
goto st0;
|
|
1193
1423
|
st3:
|
|
1194
1424
|
if ( ++p == pe )
|
|
1195
|
-
goto
|
|
1425
|
+
goto _test_eof3;
|
|
1196
1426
|
case 3:
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
case 102: goto st2;
|
|
1203
|
-
case 110: goto st2;
|
|
1204
|
-
case 114: goto st2;
|
|
1205
|
-
case 116: goto st2;
|
|
1206
|
-
case 117: goto st4;
|
|
1207
|
-
}
|
|
1208
|
-
goto st1;
|
|
1427
|
+
if ( (*p) == 117 )
|
|
1428
|
+
goto st4;
|
|
1429
|
+
if ( 0 <= (*p) && (*p) <= 31 )
|
|
1430
|
+
goto st0;
|
|
1431
|
+
goto st2;
|
|
1209
1432
|
st4:
|
|
1210
1433
|
if ( ++p == pe )
|
|
1211
|
-
goto
|
|
1434
|
+
goto _test_eof4;
|
|
1212
1435
|
case 4:
|
|
1213
1436
|
if ( (*p) < 65 ) {
|
|
1214
1437
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
@@ -1218,10 +1441,10 @@ case 4:
|
|
|
1218
1441
|
goto st5;
|
|
1219
1442
|
} else
|
|
1220
1443
|
goto st5;
|
|
1221
|
-
goto
|
|
1444
|
+
goto st0;
|
|
1222
1445
|
st5:
|
|
1223
1446
|
if ( ++p == pe )
|
|
1224
|
-
goto
|
|
1447
|
+
goto _test_eof5;
|
|
1225
1448
|
case 5:
|
|
1226
1449
|
if ( (*p) < 65 ) {
|
|
1227
1450
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
@@ -1231,10 +1454,10 @@ case 5:
|
|
|
1231
1454
|
goto st6;
|
|
1232
1455
|
} else
|
|
1233
1456
|
goto st6;
|
|
1234
|
-
goto
|
|
1457
|
+
goto st0;
|
|
1235
1458
|
st6:
|
|
1236
1459
|
if ( ++p == pe )
|
|
1237
|
-
goto
|
|
1460
|
+
goto _test_eof6;
|
|
1238
1461
|
case 6:
|
|
1239
1462
|
if ( (*p) < 65 ) {
|
|
1240
1463
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
@@ -1244,10 +1467,10 @@ case 6:
|
|
|
1244
1467
|
goto st7;
|
|
1245
1468
|
} else
|
|
1246
1469
|
goto st7;
|
|
1247
|
-
goto
|
|
1470
|
+
goto st0;
|
|
1248
1471
|
st7:
|
|
1249
1472
|
if ( ++p == pe )
|
|
1250
|
-
goto
|
|
1473
|
+
goto _test_eof7;
|
|
1251
1474
|
case 7:
|
|
1252
1475
|
if ( (*p) < 65 ) {
|
|
1253
1476
|
if ( 48 <= (*p) && (*p) <= 57 )
|
|
@@ -1257,21 +1480,25 @@ case 7:
|
|
|
1257
1480
|
goto st2;
|
|
1258
1481
|
} else
|
|
1259
1482
|
goto st2;
|
|
1260
|
-
goto
|
|
1483
|
+
goto st0;
|
|
1261
1484
|
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1485
|
+
_test_eof2: cs = 2; goto _test_eof;
|
|
1486
|
+
_test_eof8: cs = 8; goto _test_eof;
|
|
1487
|
+
_test_eof3: cs = 3; goto _test_eof;
|
|
1488
|
+
_test_eof4: cs = 4; goto _test_eof;
|
|
1489
|
+
_test_eof5: cs = 5; goto _test_eof;
|
|
1490
|
+
_test_eof6: cs = 6; goto _test_eof;
|
|
1491
|
+
_test_eof7: cs = 7; goto _test_eof;
|
|
1492
|
+
|
|
1493
|
+
_test_eof: {}
|
|
1271
1494
|
_out: {}
|
|
1272
1495
|
}
|
|
1273
|
-
#line 360 "parser.rl"
|
|
1274
1496
|
|
|
1497
|
+
#line 480 "parser.rl"
|
|
1498
|
+
|
|
1499
|
+
if (json->symbolize_names && json->parsing_name) {
|
|
1500
|
+
*result = rb_str_intern(*result);
|
|
1501
|
+
}
|
|
1275
1502
|
if (cs >= JSON_string_first_final) {
|
|
1276
1503
|
return p + 1;
|
|
1277
1504
|
} else {
|
|
@@ -1281,14 +1508,15 @@ case 7:
|
|
|
1281
1508
|
|
|
1282
1509
|
|
|
1283
1510
|
|
|
1284
|
-
#line
|
|
1285
|
-
static const int JSON_start =
|
|
1286
|
-
|
|
1511
|
+
#line 1511 "parser.c"
|
|
1512
|
+
static const int JSON_start = 1;
|
|
1287
1513
|
static const int JSON_first_final = 10;
|
|
1514
|
+
static const int JSON_error = 0;
|
|
1515
|
+
|
|
1516
|
+
static const int JSON_en_main = 1;
|
|
1288
1517
|
|
|
1289
|
-
static const int JSON_error = 1;
|
|
1290
1518
|
|
|
1291
|
-
#line
|
|
1519
|
+
#line 517 "parser.rl"
|
|
1292
1520
|
|
|
1293
1521
|
|
|
1294
1522
|
/*
|
|
@@ -1303,38 +1531,156 @@ static const int JSON_error = 1;
|
|
|
1303
1531
|
*
|
|
1304
1532
|
*/
|
|
1305
1533
|
|
|
1306
|
-
|
|
1307
|
-
* call-seq: new(source)
|
|
1308
|
-
*
|
|
1309
|
-
* Creates a new JSON::Ext::Parser instance for the string _source_.
|
|
1310
|
-
*/
|
|
1311
|
-
static VALUE cParser_initialize(VALUE self, VALUE source)
|
|
1534
|
+
static VALUE convert_encoding(VALUE source)
|
|
1312
1535
|
{
|
|
1313
|
-
char *ptr;
|
|
1314
|
-
long len;
|
|
1315
|
-
GET_STRUCT;
|
|
1316
|
-
source = StringValue(source);
|
|
1317
|
-
ptr = RSTRING(source)->ptr;
|
|
1318
|
-
len = RSTRING(source)->len;
|
|
1536
|
+
char *ptr = RSTRING_PTR(source);
|
|
1537
|
+
long len = RSTRING_LEN(source);
|
|
1319
1538
|
if (len < 2) {
|
|
1320
1539
|
rb_raise(eParserError, "A JSON text must at least contain two octets!");
|
|
1321
1540
|
}
|
|
1322
|
-
|
|
1323
|
-
|
|
1541
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
|
1542
|
+
{
|
|
1543
|
+
VALUE encoding = rb_funcall(source, i_encoding, 0);
|
|
1544
|
+
if (encoding == CEncoding_ASCII_8BIT) {
|
|
1545
|
+
if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
|
|
1546
|
+
source = rb_str_dup(source);
|
|
1547
|
+
rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_32BE);
|
|
1548
|
+
source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8);
|
|
1549
|
+
} else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
|
|
1550
|
+
source = rb_str_dup(source);
|
|
1551
|
+
rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_16BE);
|
|
1552
|
+
source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8);
|
|
1553
|
+
} else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
|
|
1554
|
+
source = rb_str_dup(source);
|
|
1555
|
+
rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_32LE);
|
|
1556
|
+
source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8);
|
|
1557
|
+
} else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
|
|
1558
|
+
source = rb_str_dup(source);
|
|
1559
|
+
rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_16LE);
|
|
1560
|
+
source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8);
|
|
1561
|
+
} else {
|
|
1562
|
+
FORCE_UTF8(source);
|
|
1563
|
+
}
|
|
1564
|
+
} else {
|
|
1565
|
+
source = rb_funcall(source, i_encode, 1, CEncoding_UTF_8);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
#else
|
|
1324
1569
|
if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
|
|
1325
|
-
|
|
1570
|
+
source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-32be"), source);
|
|
1326
1571
|
} else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
|
|
1327
|
-
|
|
1572
|
+
source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-16be"), source);
|
|
1328
1573
|
} else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
|
|
1329
|
-
|
|
1574
|
+
source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-32le"), source);
|
|
1330
1575
|
} else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
|
|
1331
|
-
|
|
1576
|
+
source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-16le"), source);
|
|
1332
1577
|
}
|
|
1333
|
-
|
|
1578
|
+
#endif
|
|
1579
|
+
return source;
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
/*
|
|
1583
|
+
* call-seq: new(source, opts => {})
|
|
1584
|
+
*
|
|
1585
|
+
* Creates a new JSON::Ext::Parser instance for the string _source_.
|
|
1586
|
+
*
|
|
1587
|
+
* Creates a new JSON::Ext::Parser instance for the string _source_.
|
|
1588
|
+
*
|
|
1589
|
+
* It will be configured by the _opts_ hash. _opts_ can have the following
|
|
1590
|
+
* keys:
|
|
1591
|
+
*
|
|
1592
|
+
* _opts_ can have the following keys:
|
|
1593
|
+
* * *max_nesting*: The maximum depth of nesting allowed in the parsed data
|
|
1594
|
+
* structures. Disable depth checking with :max_nesting => false|nil|0, it
|
|
1595
|
+
* defaults to 19.
|
|
1596
|
+
* * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
|
|
1597
|
+
* defiance of RFC 4627 to be parsed by the Parser. This option defaults to
|
|
1598
|
+
* false.
|
|
1599
|
+
* * *symbolize_names*: If set to true, returns symbols for the names
|
|
1600
|
+
* (keys) in a JSON object. Otherwise strings are returned, which is also
|
|
1601
|
+
* the default.
|
|
1602
|
+
* * *create_additions*: If set to false, the Parser doesn't create
|
|
1603
|
+
* additions even if a matchin class and create_id was found. This option
|
|
1604
|
+
* defaults to true.
|
|
1605
|
+
* * *object_class*: Defaults to Hash
|
|
1606
|
+
* * *array_class*: Defaults to Array
|
|
1607
|
+
*/
|
|
1608
|
+
static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|
1609
|
+
{
|
|
1610
|
+
char *ptr;
|
|
1611
|
+
long len;
|
|
1612
|
+
VALUE source, opts;
|
|
1613
|
+
GET_PARSER;
|
|
1614
|
+
rb_scan_args(argc, argv, "11", &source, &opts);
|
|
1615
|
+
source = convert_encoding(StringValue(source));
|
|
1616
|
+
ptr = RSTRING_PTR(source);
|
|
1617
|
+
len = RSTRING_LEN(source);
|
|
1618
|
+
if (!NIL_P(opts)) {
|
|
1619
|
+
opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
|
|
1620
|
+
if (NIL_P(opts)) {
|
|
1621
|
+
rb_raise(rb_eArgError, "opts needs to be like a hash");
|
|
1622
|
+
} else {
|
|
1623
|
+
VALUE tmp = ID2SYM(i_max_nesting);
|
|
1624
|
+
if (option_given_p(opts, tmp)) {
|
|
1625
|
+
VALUE max_nesting = rb_hash_aref(opts, tmp);
|
|
1626
|
+
if (RTEST(max_nesting)) {
|
|
1627
|
+
Check_Type(max_nesting, T_FIXNUM);
|
|
1628
|
+
json->max_nesting = FIX2INT(max_nesting);
|
|
1629
|
+
} else {
|
|
1630
|
+
json->max_nesting = 0;
|
|
1631
|
+
}
|
|
1632
|
+
} else {
|
|
1633
|
+
json->max_nesting = 19;
|
|
1634
|
+
}
|
|
1635
|
+
tmp = ID2SYM(i_allow_nan);
|
|
1636
|
+
if (option_given_p(opts, tmp)) {
|
|
1637
|
+
VALUE allow_nan = rb_hash_aref(opts, tmp);
|
|
1638
|
+
json->allow_nan = RTEST(allow_nan) ? 1 : 0;
|
|
1639
|
+
} else {
|
|
1640
|
+
json->allow_nan = 0;
|
|
1641
|
+
}
|
|
1642
|
+
tmp = ID2SYM(i_symbolize_names);
|
|
1643
|
+
if (option_given_p(opts, tmp)) {
|
|
1644
|
+
VALUE symbolize_names = rb_hash_aref(opts, tmp);
|
|
1645
|
+
json->symbolize_names = RTEST(symbolize_names) ? 1 : 0;
|
|
1646
|
+
} else {
|
|
1647
|
+
json->symbolize_names = 0;
|
|
1648
|
+
}
|
|
1649
|
+
tmp = ID2SYM(i_create_additions);
|
|
1650
|
+
if (option_given_p(opts, tmp)) {
|
|
1651
|
+
VALUE create_additions = rb_hash_aref(opts, tmp);
|
|
1652
|
+
if (RTEST(create_additions)) {
|
|
1653
|
+
json->create_id = rb_funcall(mJSON, i_create_id, 0);
|
|
1654
|
+
} else {
|
|
1655
|
+
json->create_id = Qnil;
|
|
1656
|
+
}
|
|
1657
|
+
} else {
|
|
1658
|
+
json->create_id = rb_funcall(mJSON, i_create_id, 0);
|
|
1659
|
+
}
|
|
1660
|
+
tmp = ID2SYM(i_object_class);
|
|
1661
|
+
if (option_given_p(opts, tmp)) {
|
|
1662
|
+
json->object_class = rb_hash_aref(opts, tmp);
|
|
1663
|
+
} else {
|
|
1664
|
+
json->object_class = Qnil;
|
|
1665
|
+
}
|
|
1666
|
+
tmp = ID2SYM(i_array_class);
|
|
1667
|
+
if (option_given_p(opts, tmp)) {
|
|
1668
|
+
json->array_class = rb_hash_aref(opts, tmp);
|
|
1669
|
+
} else {
|
|
1670
|
+
json->array_class = Qnil;
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
} else {
|
|
1674
|
+
json->max_nesting = 19;
|
|
1675
|
+
json->allow_nan = 0;
|
|
1676
|
+
json->create_id = rb_funcall(mJSON, i_create_id, 0);
|
|
1677
|
+
json->object_class = Qnil;
|
|
1678
|
+
json->array_class = Qnil;
|
|
1679
|
+
}
|
|
1680
|
+
json->current_nesting = 0;
|
|
1334
1681
|
json->len = len;
|
|
1335
1682
|
json->source = ptr;
|
|
1336
1683
|
json->Vsource = source;
|
|
1337
|
-
json->create_id = rb_funcall(mJSON, i_create_id, 0);
|
|
1338
1684
|
return self;
|
|
1339
1685
|
}
|
|
1340
1686
|
|
|
@@ -1346,93 +1692,99 @@ static VALUE cParser_initialize(VALUE self, VALUE source)
|
|
|
1346
1692
|
*/
|
|
1347
1693
|
static VALUE cParser_parse(VALUE self)
|
|
1348
1694
|
{
|
|
1349
|
-
GET_STRUCT;
|
|
1350
1695
|
char *p, *pe;
|
|
1351
1696
|
int cs = EVIL;
|
|
1352
1697
|
VALUE result = Qnil;
|
|
1698
|
+
GET_PARSER;
|
|
1353
1699
|
|
|
1354
1700
|
|
|
1355
|
-
#line
|
|
1701
|
+
#line 1701 "parser.c"
|
|
1356
1702
|
{
|
|
1357
1703
|
cs = JSON_start;
|
|
1358
1704
|
}
|
|
1359
|
-
|
|
1705
|
+
|
|
1706
|
+
#line 698 "parser.rl"
|
|
1360
1707
|
p = json->source;
|
|
1361
1708
|
pe = p + json->len;
|
|
1362
1709
|
|
|
1363
|
-
#line
|
|
1710
|
+
#line 1710 "parser.c"
|
|
1364
1711
|
{
|
|
1365
1712
|
if ( p == pe )
|
|
1366
|
-
goto
|
|
1713
|
+
goto _test_eof;
|
|
1367
1714
|
switch ( cs )
|
|
1368
1715
|
{
|
|
1369
|
-
|
|
1716
|
+
st1:
|
|
1370
1717
|
if ( ++p == pe )
|
|
1371
|
-
goto
|
|
1372
|
-
case
|
|
1718
|
+
goto _test_eof1;
|
|
1719
|
+
case 1:
|
|
1373
1720
|
switch( (*p) ) {
|
|
1374
|
-
case 13: goto
|
|
1375
|
-
case 32: goto
|
|
1721
|
+
case 13: goto st1;
|
|
1722
|
+
case 32: goto st1;
|
|
1376
1723
|
case 47: goto st2;
|
|
1377
|
-
case 91: goto
|
|
1378
|
-
case 123: goto
|
|
1724
|
+
case 91: goto tr3;
|
|
1725
|
+
case 123: goto tr4;
|
|
1379
1726
|
}
|
|
1380
1727
|
if ( 9 <= (*p) && (*p) <= 10 )
|
|
1381
|
-
goto
|
|
1382
|
-
goto
|
|
1383
|
-
|
|
1384
|
-
|
|
1728
|
+
goto st1;
|
|
1729
|
+
goto st0;
|
|
1730
|
+
st0:
|
|
1731
|
+
cs = 0;
|
|
1732
|
+
goto _out;
|
|
1385
1733
|
st2:
|
|
1386
1734
|
if ( ++p == pe )
|
|
1387
|
-
goto
|
|
1735
|
+
goto _test_eof2;
|
|
1388
1736
|
case 2:
|
|
1389
1737
|
switch( (*p) ) {
|
|
1390
1738
|
case 42: goto st3;
|
|
1391
1739
|
case 47: goto st5;
|
|
1392
1740
|
}
|
|
1393
|
-
goto
|
|
1741
|
+
goto st0;
|
|
1394
1742
|
st3:
|
|
1395
1743
|
if ( ++p == pe )
|
|
1396
|
-
goto
|
|
1744
|
+
goto _test_eof3;
|
|
1397
1745
|
case 3:
|
|
1398
1746
|
if ( (*p) == 42 )
|
|
1399
1747
|
goto st4;
|
|
1400
1748
|
goto st3;
|
|
1401
1749
|
st4:
|
|
1402
1750
|
if ( ++p == pe )
|
|
1403
|
-
goto
|
|
1751
|
+
goto _test_eof4;
|
|
1404
1752
|
case 4:
|
|
1405
1753
|
switch( (*p) ) {
|
|
1406
1754
|
case 42: goto st4;
|
|
1407
|
-
case 47: goto
|
|
1755
|
+
case 47: goto st1;
|
|
1408
1756
|
}
|
|
1409
1757
|
goto st3;
|
|
1410
1758
|
st5:
|
|
1411
1759
|
if ( ++p == pe )
|
|
1412
|
-
goto
|
|
1760
|
+
goto _test_eof5;
|
|
1413
1761
|
case 5:
|
|
1414
1762
|
if ( (*p) == 10 )
|
|
1415
|
-
goto
|
|
1763
|
+
goto st1;
|
|
1416
1764
|
goto st5;
|
|
1417
|
-
|
|
1418
|
-
#line
|
|
1765
|
+
tr3:
|
|
1766
|
+
#line 506 "parser.rl"
|
|
1419
1767
|
{
|
|
1420
|
-
char *np
|
|
1421
|
-
|
|
1768
|
+
char *np;
|
|
1769
|
+
json->current_nesting = 1;
|
|
1770
|
+
np = JSON_parse_array(json, p, pe, &result);
|
|
1771
|
+
if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
|
|
1422
1772
|
}
|
|
1423
1773
|
goto st10;
|
|
1424
|
-
|
|
1425
|
-
#line
|
|
1774
|
+
tr4:
|
|
1775
|
+
#line 499 "parser.rl"
|
|
1426
1776
|
{
|
|
1427
|
-
char *np
|
|
1428
|
-
|
|
1777
|
+
char *np;
|
|
1778
|
+
json->current_nesting = 1;
|
|
1779
|
+
np = JSON_parse_object(json, p, pe, &result);
|
|
1780
|
+
if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
|
|
1429
1781
|
}
|
|
1430
1782
|
goto st10;
|
|
1431
1783
|
st10:
|
|
1432
1784
|
if ( ++p == pe )
|
|
1433
|
-
goto
|
|
1785
|
+
goto _test_eof10;
|
|
1434
1786
|
case 10:
|
|
1435
|
-
#line
|
|
1787
|
+
#line 1787 "parser.c"
|
|
1436
1788
|
switch( (*p) ) {
|
|
1437
1789
|
case 13: goto st10;
|
|
1438
1790
|
case 32: goto st10;
|
|
@@ -1440,26 +1792,26 @@ case 10:
|
|
|
1440
1792
|
}
|
|
1441
1793
|
if ( 9 <= (*p) && (*p) <= 10 )
|
|
1442
1794
|
goto st10;
|
|
1443
|
-
goto
|
|
1795
|
+
goto st0;
|
|
1444
1796
|
st6:
|
|
1445
1797
|
if ( ++p == pe )
|
|
1446
|
-
goto
|
|
1798
|
+
goto _test_eof6;
|
|
1447
1799
|
case 6:
|
|
1448
1800
|
switch( (*p) ) {
|
|
1449
1801
|
case 42: goto st7;
|
|
1450
1802
|
case 47: goto st9;
|
|
1451
1803
|
}
|
|
1452
|
-
goto
|
|
1804
|
+
goto st0;
|
|
1453
1805
|
st7:
|
|
1454
1806
|
if ( ++p == pe )
|
|
1455
|
-
goto
|
|
1807
|
+
goto _test_eof7;
|
|
1456
1808
|
case 7:
|
|
1457
1809
|
if ( (*p) == 42 )
|
|
1458
1810
|
goto st8;
|
|
1459
1811
|
goto st7;
|
|
1460
1812
|
st8:
|
|
1461
1813
|
if ( ++p == pe )
|
|
1462
|
-
goto
|
|
1814
|
+
goto _test_eof8;
|
|
1463
1815
|
case 8:
|
|
1464
1816
|
switch( (*p) ) {
|
|
1465
1817
|
case 42: goto st8;
|
|
@@ -1468,32 +1820,34 @@ case 8:
|
|
|
1468
1820
|
goto st7;
|
|
1469
1821
|
st9:
|
|
1470
1822
|
if ( ++p == pe )
|
|
1471
|
-
goto
|
|
1823
|
+
goto _test_eof9;
|
|
1472
1824
|
case 9:
|
|
1473
1825
|
if ( (*p) == 10 )
|
|
1474
1826
|
goto st10;
|
|
1475
1827
|
goto st9;
|
|
1476
1828
|
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1829
|
+
_test_eof1: cs = 1; goto _test_eof;
|
|
1830
|
+
_test_eof2: cs = 2; goto _test_eof;
|
|
1831
|
+
_test_eof3: cs = 3; goto _test_eof;
|
|
1832
|
+
_test_eof4: cs = 4; goto _test_eof;
|
|
1833
|
+
_test_eof5: cs = 5; goto _test_eof;
|
|
1834
|
+
_test_eof10: cs = 10; goto _test_eof;
|
|
1835
|
+
_test_eof6: cs = 6; goto _test_eof;
|
|
1836
|
+
_test_eof7: cs = 7; goto _test_eof;
|
|
1837
|
+
_test_eof8: cs = 8; goto _test_eof;
|
|
1838
|
+
_test_eof9: cs = 9; goto _test_eof;
|
|
1839
|
+
|
|
1840
|
+
_test_eof: {}
|
|
1489
1841
|
_out: {}
|
|
1490
1842
|
}
|
|
1491
|
-
|
|
1843
|
+
|
|
1844
|
+
#line 701 "parser.rl"
|
|
1492
1845
|
|
|
1493
1846
|
if (cs >= JSON_first_final && p == pe) {
|
|
1494
1847
|
return result;
|
|
1495
1848
|
} else {
|
|
1496
|
-
rb_raise(eParserError, "unexpected token at '%s'", p);
|
|
1849
|
+
rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p);
|
|
1850
|
+
return Qnil;
|
|
1497
1851
|
}
|
|
1498
1852
|
}
|
|
1499
1853
|
|
|
@@ -1508,11 +1862,13 @@ static void JSON_mark(JSON_Parser *json)
|
|
|
1508
1862
|
{
|
|
1509
1863
|
rb_gc_mark_maybe(json->Vsource);
|
|
1510
1864
|
rb_gc_mark_maybe(json->create_id);
|
|
1865
|
+
rb_gc_mark_maybe(json->object_class);
|
|
1866
|
+
rb_gc_mark_maybe(json->array_class);
|
|
1511
1867
|
}
|
|
1512
1868
|
|
|
1513
1869
|
static void JSON_free(JSON_Parser *json)
|
|
1514
1870
|
{
|
|
1515
|
-
|
|
1871
|
+
ruby_xfree(json);
|
|
1516
1872
|
}
|
|
1517
1873
|
|
|
1518
1874
|
static VALUE cJSON_parser_s_allocate(VALUE klass)
|
|
@@ -1529,23 +1885,51 @@ static VALUE cJSON_parser_s_allocate(VALUE klass)
|
|
|
1529
1885
|
*/
|
|
1530
1886
|
static VALUE cParser_source(VALUE self)
|
|
1531
1887
|
{
|
|
1532
|
-
|
|
1888
|
+
GET_PARSER;
|
|
1533
1889
|
return rb_str_dup(json->Vsource);
|
|
1534
1890
|
}
|
|
1535
1891
|
|
|
1536
1892
|
void Init_parser()
|
|
1537
1893
|
{
|
|
1894
|
+
rb_require("json/common");
|
|
1538
1895
|
mJSON = rb_define_module("JSON");
|
|
1539
1896
|
mExt = rb_define_module_under(mJSON, "Ext");
|
|
1540
1897
|
cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
|
|
1541
1898
|
eParserError = rb_path2class("JSON::ParserError");
|
|
1899
|
+
eNestingError = rb_path2class("JSON::NestingError");
|
|
1542
1900
|
rb_define_alloc_func(cParser, cJSON_parser_s_allocate);
|
|
1543
|
-
rb_define_method(cParser, "initialize", cParser_initialize, 1);
|
|
1901
|
+
rb_define_method(cParser, "initialize", cParser_initialize, -1);
|
|
1544
1902
|
rb_define_method(cParser, "parse", cParser_parse, 0);
|
|
1545
1903
|
rb_define_method(cParser, "source", cParser_source, 0);
|
|
1546
1904
|
|
|
1905
|
+
CNaN = rb_const_get(mJSON, rb_intern("NaN"));
|
|
1906
|
+
CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
|
|
1907
|
+
CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
|
|
1908
|
+
|
|
1547
1909
|
i_json_creatable_p = rb_intern("json_creatable?");
|
|
1548
1910
|
i_json_create = rb_intern("json_create");
|
|
1549
1911
|
i_create_id = rb_intern("create_id");
|
|
1912
|
+
i_create_additions = rb_intern("create_additions");
|
|
1550
1913
|
i_chr = rb_intern("chr");
|
|
1914
|
+
i_max_nesting = rb_intern("max_nesting");
|
|
1915
|
+
i_allow_nan = rb_intern("allow_nan");
|
|
1916
|
+
i_symbolize_names = rb_intern("symbolize_names");
|
|
1917
|
+
i_object_class = rb_intern("object_class");
|
|
1918
|
+
i_array_class = rb_intern("array_class");
|
|
1919
|
+
i_key_p = rb_intern("key?");
|
|
1920
|
+
i_deep_const_get = rb_intern("deep_const_get");
|
|
1921
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
|
1922
|
+
CEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8"));
|
|
1923
|
+
CEncoding_UTF_16BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16be"));
|
|
1924
|
+
CEncoding_UTF_16LE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16le"));
|
|
1925
|
+
CEncoding_UTF_32BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-32be"));
|
|
1926
|
+
CEncoding_UTF_32LE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-32le"));
|
|
1927
|
+
CEncoding_ASCII_8BIT = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("ascii-8bit"));
|
|
1928
|
+
i_encoding = rb_intern("encoding");
|
|
1929
|
+
i_encode = rb_intern("encode");
|
|
1930
|
+
i_encode_bang = rb_intern("encode!");
|
|
1931
|
+
i_force_encoding = rb_intern("force_encoding");
|
|
1932
|
+
#else
|
|
1933
|
+
i_iconv = rb_intern("iconv");
|
|
1934
|
+
#endif
|
|
1551
1935
|
}
|