[前][次][番号順一覧][スレッド一覧]

ruby-changes:46984

From: hsbt <ko1@a...>
Date: Fri, 16 Jun 2017 12:04:51 +0900 (JST)
Subject: [ruby-changes:46984] hsbt:r59099 (trunk): Merge json-2.1.0 from https://github.com/flori/json

hsbt	2017-06-16 12:04:46 +0900 (Fri, 16 Jun 2017)

  New Revision: 59099

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59099

  Log:
    Merge json-2.1.0 from https://github.com/flori/json
    
      https://github.com/flori/json/blob/master/CHANGES.md#2017-04-18-210

  Modified files:
    trunk/ext/json/json.gemspec
    trunk/ext/json/lib/json/version.rb
    trunk/ext/json/parser/parser.c
    trunk/ext/json/parser/parser.h
    trunk/ext/json/parser/parser.rl
    trunk/test/json/json_parser_test.rb
Index: ext/json/json.gemspec
===================================================================
Binary files ext/json/json.gemspec	(revision 59098) and ext/json/json.gemspec	(revision 59099) differ
Index: ext/json/parser/parser.rl
===================================================================
--- ext/json/parser/parser.rl	(revision 59098)
+++ ext/json/parser/parser.rl	(revision 59099)
@@ -92,8 +92,9 @@ static VALUE CNaN, CInfinity, CMinusInfi https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.rl#L92
 
 static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
           i_chr, i_max_nesting, i_allow_nan, i_symbolize_names,
-          i_object_class, i_array_class, i_key_p, i_deep_const_get, i_match,
-          i_match_string, i_aset, i_aref, i_leftshift;
+          i_object_class, i_array_class, i_decimal_class, i_key_p,
+          i_deep_const_get, i_match, i_match_string, i_aset, i_aref,
+          i_leftshift, i_new;
 
 %%{
     machine JSON_common;
@@ -351,7 +352,13 @@ static char *JSON_parse_float(JSON_Parse https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.rl#L352
         fbuffer_clear(json->fbuffer);
         fbuffer_append(json->fbuffer, json->memo, len);
         fbuffer_append_char(json->fbuffer, '\0');
-        *result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
+        if (NIL_P(json->decimal_class)) {
+          *result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
+        } else {
+          VALUE text;
+          text = rb_str_new2(FBUFFER_PTR(json->fbuffer));
+          *result = rb_funcall(json->decimal_class, i_new, 1, text);
+        }
         return p + 1;
     } else {
         return NULL;
@@ -684,6 +691,12 @@ static VALUE cParser_initialize(int argc https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.rl#L691
             } else {
                 json->array_class = Qnil;
             }
+            tmp = ID2SYM(i_decimal_class);
+            if (option_given_p(opts, tmp)) {
+                json->decimal_class = rb_hash_aref(opts, tmp);
+            } else {
+                json->decimal_class = Qnil;
+            }
             tmp = ID2SYM(i_match_string);
             if (option_given_p(opts, tmp)) {
                 VALUE match_string = rb_hash_aref(opts, tmp);
@@ -701,6 +714,7 @@ static VALUE cParser_initialize(int argc https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.rl#L714
         json->create_id = rb_funcall(mJSON, i_create_id, 0);
         json->object_class = Qnil;
         json->array_class = Qnil;
+        json->decimal_class = Qnil;
     }
     source = convert_encoding(StringValue(source));
     StringValue(source);
@@ -760,6 +774,7 @@ static void JSON_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.rl#L774
     rb_gc_mark_maybe(json->create_id);
     rb_gc_mark_maybe(json->object_class);
     rb_gc_mark_maybe(json->array_class);
+    rb_gc_mark_maybe(json->decimal_class);
     rb_gc_mark_maybe(json->match_string);
 }
 
@@ -834,6 +849,7 @@ void Init_parser(void) https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.rl#L849
     i_symbolize_names = rb_intern("symbolize_names");
     i_object_class = rb_intern("object_class");
     i_array_class = rb_intern("array_class");
+    i_decimal_class = rb_intern("decimal_class");
     i_match = rb_intern("match");
     i_match_string = rb_intern("match_string");
     i_key_p = rb_intern("key?");
@@ -841,6 +857,7 @@ void Init_parser(void) https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.rl#L857
     i_aset = rb_intern("[]=");
     i_aref = rb_intern("[]");
     i_leftshift = rb_intern("<<");
+    i_new = rb_intern("new");
 }
 
 /*
Index: ext/json/parser/parser.c
===================================================================
--- ext/json/parser/parser.c	(revision 59098)
+++ ext/json/parser/parser.c	(revision 59099)
@@ -94,15 +94,16 @@ static VALUE CNaN, CInfinity, CMinusInfi https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L94
 
 static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
           i_chr, i_max_nesting, i_allow_nan, i_symbolize_names,
-          i_object_class, i_array_class, i_key_p, i_deep_const_get, i_match,
-          i_match_string, i_aset, i_aref, i_leftshift;
+          i_object_class, i_array_class, i_decimal_class, i_key_p,
+          i_deep_const_get, i_match, i_match_string, i_aset, i_aref,
+          i_leftshift, i_new;
 
 
-#line 124 "parser.rl"
+#line 125 "parser.rl"
 
 
 
-#line 106 "parser.c"
+#line 107 "parser.c"
 enum {JSON_object_start = 1};
 enum {JSON_object_first_final = 27};
 enum {JSON_object_error = 0};
@@ -110,7 +111,7 @@ enum {JSON_object_error = 0}; https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L111
 enum {JSON_object_en_main = 1};
 
 
-#line 165 "parser.rl"
+#line 166 "parser.rl"
 
 
 static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -126,14 +127,14 @@ static char *JSON_parse_object(JSON_Pars https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L127
     *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
 
 
-#line 130 "parser.c"
+#line 131 "parser.c"
 	{
 	cs = JSON_object_start;
 	}
 
-#line 180 "parser.rl"
+#line 181 "parser.rl"
 
-#line 137 "parser.c"
+#line 138 "parser.c"
 	{
 	if ( p == pe )
 		goto _test_eof;
@@ -161,7 +162,7 @@ case 2: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L162
 		goto st2;
 	goto st0;
 tr2:
-#line 147 "parser.rl"
+#line 148 "parser.rl"
 	{
         char *np;
         json->parsing_name = 1;
@@ -174,7 +175,7 @@ st3: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L175
 	if ( ++p == pe )
 		goto _test_eof3;
 case 3:
-#line 178 "parser.c"
+#line 179 "parser.c"
 	switch( (*p) ) {
 		case 13: goto st3;
 		case 32: goto st3;
@@ -241,7 +242,7 @@ case 8: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L242
 		goto st8;
 	goto st0;
 tr11:
-#line 132 "parser.rl"
+#line 133 "parser.rl"
 	{
         VALUE v = Qnil;
         char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
@@ -261,7 +262,7 @@ st9: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L262
 	if ( ++p == pe )
 		goto _test_eof9;
 case 9:
-#line 265 "parser.c"
+#line 266 "parser.c"
 	switch( (*p) ) {
 		case 13: goto st9;
 		case 32: goto st9;
@@ -350,14 +351,14 @@ case 18: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L351
 		goto st9;
 	goto st18;
 tr4:
-#line 155 "parser.rl"
+#line 156 "parser.rl"
 	{ p--; {p++; cs = 27; goto _out;} }
 	goto st27;
 st27:
 	if ( ++p == pe )
 		goto _test_eof27;
 case 27:
-#line 361 "parser.c"
+#line 362 "parser.c"
 	goto st0;
 st19:
 	if ( ++p == pe )
@@ -455,7 +456,7 @@ case 26: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L456
 	_out: {}
 	}
 
-#line 181 "parser.rl"
+#line 182 "parser.rl"
 
     if (cs >= JSON_object_first_final) {
         if (json->create_additions) {
@@ -480,7 +481,7 @@ case 26: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L481
 
 
 
-#line 484 "parser.c"
+#line 485 "parser.c"
 enum {JSON_value_start = 1};
 enum {JSON_value_first_final = 29};
 enum {JSON_value_error = 0};
@@ -488,7 +489,7 @@ enum {JSON_value_error = 0}; https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L489
 enum {JSON_value_en_main = 1};
 
 
-#line 281 "parser.rl"
+#line 282 "parser.rl"
 
 
 static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -496,14 +497,14 @@ static char *JSON_parse_value(JSON_Parse https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L497
     int cs = EVIL;
 
 
-#line 500 "parser.c"
+#line 501 "parser.c"
 	{
 	cs = JSON_value_start;
 	}
 
-#line 288 "parser.rl"
+#line 289 "parser.rl"
 
-#line 507 "parser.c"
+#line 508 "parser.c"
 	{
 	if ( p == pe )
 		goto _test_eof;
@@ -537,14 +538,14 @@ st0: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L538
 cs = 0;
 	goto _out;
 tr2:
-#line 233 "parser.rl"
+#line 234 "parser.rl"
 	{
         char *np = JSON_parse_string(json, p, pe, result);
         if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;}
     }
 	goto st29;
 tr3:
-#line 238 "parser.rl"
+#line 239 "parser.rl"
 	{
         char *np;
         if(pe > p + 8 && !strncmp(MinusInfinity, p, 9)) {
@@ -564,7 +565,7 @@ tr3: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L565
     }
 	goto st29;
 tr7:
-#line 256 "parser.rl"
+#line 257 "parser.rl"
 	{
         char *np;
         np = JSON_parse_array(json, p, pe, result, current_nesting + 1);
@@ -572,7 +573,7 @@ tr7: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L573
     }
 	goto st29;
 tr11:
-#line 262 "parser.rl"
+#line 263 "parser.rl"
 	{
         char *np;
         np =  JSON_parse_object(json, p, pe, result, current_nesting + 1);
@@ -580,7 +581,7 @@ tr11: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L581
     }
 	goto st29;
 tr25:
-#line 226 "parser.rl"
+#line 227 "parser.rl"
 	{
         if (json->allow_nan) {
             *result = CInfinity;
@@ -590,7 +591,7 @@ tr25: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L591
     }
 	goto st29;
 tr27:
-#line 219 "parser.rl"
+#line 220 "parser.rl"
 	{
         if (json->allow_nan) {
             *result = CNaN;
@@ -600,19 +601,19 @@ tr27: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L601
     }
 	goto st29;
 tr31:
-#line 213 "parser.rl"
+#line 214 "parser.rl"
 	{
         *result = Qfalse;
     }
 	goto st29;
 tr34:
-#line 210 "parser.rl"
+#line 211 "parser.rl"
 	{
         *result = Qnil;
     }
 	goto st29;
 tr37:
-#line 216 "parser.rl"
+#line 217 "parser.rl"
 	{
         *result = Qtrue;
     }
@@ -621,9 +622,9 @@ st29: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L622
 	if ( ++p == pe )
 		goto _test_eof29;
 case 29:
-#line 268 "parser.rl"
+#line 269 "parser.rl"
 	{ p--; {p++; cs = 29; goto _out;} }
-#line 627 "parser.c"
+#line 628 "parser.c"
 	switch( (*p) ) {
 		case 13: goto st29;
 		case 32: goto st29;
@@ -864,7 +865,7 @@ case 28: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L865
 	_out: {}
 	}
 
-#line 289 "parser.rl"
+#line 290 "parser.rl"
 
     if (cs >= JSON_value_first_final) {
         return p;
@@ -874,7 +875,7 @@ case 28: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L875
 }
 
 
-#line 878 "parser.c"
+#line 879 "parser.c"
 enum {JSON_integer_start = 1};
 enum {JSON_integer_first_final = 3};
 enum {JSON_integer_error = 0};
@@ -882,7 +883,7 @@ enum {JSON_integer_error = 0}; https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L883
 enum {JSON_integer_en_main = 1};
 
 
-#line 305 "parser.rl"
+#line 306 "parser.rl"
 
 
 static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
@@ -890,15 +891,15 @@ static char *JSON_parse_integer(JSON_Par https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L891
     int cs = EVIL;
 
 
-#line 894 "parser.c"
+#line 895 "parser.c"
 	{
 	cs = JSON_integer_start;
 	}
 
-#line 312 "parser.rl"
+#line 313 "parser.rl"
     json->memo = p;
 
-#line 902 "parser.c"
+#line 903 "parser.c"
 	{
 	if ( p == pe )
 		goto _test_eof;
@@ -932,14 +933,14 @@ case 3: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L933
 		goto st0;
 	goto tr4;
 tr4:
-#line 302 "parser.rl"
+#line 303 "parser.rl"
 	{ p--; {p++; cs = 4; goto _out;} }
 	goto st4;
 st4:
 	if ( ++p == pe )
 		goto _test_eof4;
 case 4:
-#line 943 "parser.c"
+#line 944 "parser.c"
 	goto st0;
 st5:
 	if ( ++p == pe )
@@ -958,7 +959,7 @@ case 5: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L959
 	_out: {}
 	}
 
-#line 314 "parser.rl"
+#line 315 "parser.rl"
 
     if (cs >= JSON_integer_first_final) {
         long len = p - json->memo;
@@ -973,7 +974,7 @@ case 5: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L974
 }
 
 
-#line 977 "parser.c"
+#line 978 "parser.c"
 enum {JSON_float_start = 1};
 enum {JSON_float_first_final = 8};
 enum {JSON_float_error = 0};
@@ -981,7 +982,7 @@ enum {JSON_float_error = 0}; https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L982
 enum {JSON_float_en_main = 1};
 
 
-#line 339 "parser.rl"
+#line 340 "parser.rl"
 
 
 static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
@@ -989,15 +990,15 @@ static char *JSON_parse_float(JSON_Parse https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L990
     int cs = EVIL;
 
 
-#line 993 "parser.c"
+#line 994 "parser.c"
 	{
 	cs = JSON_float_start;
 	}
 
-#line 346 "parser.rl"
+#line 347 "parser.rl"
     json->memo = p;
 
-#line 1001 "parser.c"
+#line 1002 "parser.c"
 	{
 	if ( p == pe )
 		goto _test_eof;
@@ -1055,14 +1056,14 @@ case 8: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1056
 		goto st0;
 	goto tr9;
 tr9:
-#line 333 "parser.rl"
+#line 334 "parser.rl"
 	{ p--; {p++; cs = 9; goto _out;} }
 	goto st9;
 st9:
 	if ( ++p == pe )
 		goto _test_eof9;
 case 9:
-#line 1066 "parser.c"
+#line 1067 "parser.c"
 	goto st0;
 st5:
 	if ( ++p == pe )
@@ -1123,14 +1124,20 @@ case 7: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1124
 	_out: {}
 	}
 
-#line 348 "parser.rl"
+#line 349 "parser.rl"
 
     if (cs >= JSON_float_first_final) {
         long len = p - json->memo;
         fbuffer_clear(json->fbuffer);
         fbuffer_append(json->fbuffer, json->memo, len);
         fbuffer_append_char(json->fbuffer, '\0');
-        *result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
+        if (NIL_P(json->decimal_class)) {
+          *result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
+        } else {
+          VALUE text;
+          text = rb_str_new2(FBUFFER_PTR(json->fbuffer));
+          *result = rb_funcall(json->decimal_class, i_new, 1, text);
+        }
         return p + 1;
     } else {
         return NULL;
@@ -1139,7 +1146,7 @@ case 7: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1146
 
 
 
-#line 1143 "parser.c"
+#line 1150 "parser.c"
 enum {JSON_array_start = 1};
 enum {JSON_array_first_final = 17};
 enum {JSON_array_error = 0};
@@ -1147,7 +1154,7 @@ enum {JSON_array_error = 0}; https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1154
 enum {JSON_array_en_main = 1};
 
 
-#line 391 "parser.rl"
+#line 398 "parser.rl"
 
 
 static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -1161,14 +1168,14 @@ static char *JSON_parse_array(JSON_Parse https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1168
     *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
 
 
-#line 1165 "parser.c"
+#line 1172 "parser.c"
 	{
 	cs = JSON_array_start;
 	}
 
-#line 404 "parser.rl"
+#line 411 "parser.rl"
 
-#line 1172 "parser.c"
+#line 1179 "parser.c"
 	{
 	if ( p == pe )
 		goto _test_eof;
@@ -1207,7 +1214,7 @@ case 2: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1214
 		goto st2;
 	goto st0;
 tr2:
-#line 368 "parser.rl"
+#line 375 "parser.rl"
 	{
         VALUE v = Qnil;
         char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
@@ -1227,7 +1234,7 @@ st3: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1234
 	if ( ++p == pe )
 		goto _test_eof3;
 case 3:
-#line 1231 "parser.c"
+#line 1238 "parser.c"
 	switch( (*p) ) {
 		case 13: goto st3;
 		case 32: goto st3;
@@ -1327,14 +1334,14 @@ case 12: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1334
 		goto st3;
 	goto st12;
 tr4:
-#line 383 "parser.rl"
+#line 390 "parser.rl"
 	{ p--; {p++; cs = 17; goto _out;} }
 	goto st17;
 st17:
 	if ( ++p == pe )
 		goto _test_eof17;
 case 17:
-#line 1338 "parser.c"
+#line 1345 "parser.c"
 	goto st0;
 st13:
 	if ( ++p == pe )
@@ -1390,7 +1397,7 @@ case 16: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1397
 	_out: {}
 	}
 
-#line 405 "parser.rl"
+#line 412 "parser.rl"
 
     if(cs >= JSON_array_first_final) {
         return p + 1;
@@ -1479,7 +1486,7 @@ static VALUE json_string_unescape(VALUE https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1486
 }
 
 
-#line 1483 "parser.c"
+#line 1490 "parser.c"
 enum {JSON_string_start = 1};
 enum {JSON_string_first_final = 8};
 enum {JSON_string_error = 0};
@@ -1487,7 +1494,7 @@ enum {JSON_string_error = 0}; https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1494
 enum {JSON_string_en_main = 1};
 
 
-#line 512 "parser.rl"
+#line 519 "parser.rl"
 
 
 static int
@@ -1509,15 +1516,15 @@ static char *JSON_parse_string(JSON_Pars https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1516
 
     *result = rb_str_buf_new(0);
 
-#line 1513 "parser.c"
+#line 1520 "parser.c"
 	{
 	cs = JSON_string_start;
 	}
 
-#line 533 "parser.rl"
+#line 540 "parser.rl"
     json->memo = p;
 
-#line 1521 "parser.c"
+#line 1528 "parser.c"
 	{
 	if ( p == pe )
 		goto _test_eof;
@@ -1542,7 +1549,7 @@ case 2: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1549
 		goto st0;
 	goto st2;
 tr2:
-#line 498 "parser.rl"
+#line 505 "parser.rl"
 	{
         *result = json_string_unescape(*result, json->memo + 1, p);
         if (NIL_P(*result)) {
@@ -1553,14 +1560,14 @@ tr2: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1560
             {p = (( p + 1))-1;}
         }
     }
-#line 509 "parser.rl"
+#line 516 "parser.rl"
 	{ p--; {p++; cs = 8; goto _out;} }
 	goto st8;
 st8:
 	if ( ++p == pe )
 		goto _test_eof8;
 case 8:
-#line 1564 "parser.c"
+#line 1571 "parser.c"
 	goto st0;
 st3:
 	if ( ++p == pe )
@@ -1636,7 +1643,7 @@ case 7: https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1643
 	_out: {}
 	}
 
-#line 535 "parser.rl"
+#line 542 "parser.rl"
 
     if (json->create_additions && RTEST(match_string = json->match_string)) {
           VALUE klass;
@@ -1789,6 +1796,12 @@ static VALUE cParser_initialize(int argc https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1796
             } else {
                 json->array_class = Qnil;
             }
+            tmp = ID2SYM(i_decimal_class);
+            if (option_given_p(opts, tmp)) {
+                json->decimal_class = rb_hash_aref(opts, tmp);
+            } else {
+                json->decimal_class = Qnil;
+            }
             tmp = ID2SYM(i_match_string);
             if (option_given_p(opts, tmp)) {
                 VALUE match_string = rb_hash_aref(opts, tmp);
@@ -1806,6 +1819,7 @@ static VALUE cParser_initialize(int argc https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1819
         json->create_id = rb_funcall(mJSON, i_create_id, 0);
         json->object_class = Qnil;
         json->array_class = Qnil;
+        json->decimal_class = Qnil;
     }
     source = convert_encoding(StringValue(source));
     StringValue(source);
@@ -1816,7 +1830,7 @@ static VALUE cParser_initialize(int argc https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1830
 }
 
 
-#line 1820 "parser.c"
+#line 1834 "parser.c"
 enum {JSON_start = 1};
 enum {JSON_first_final = 10};
 enum {JSON_error = 0};
@@ -1824,7 +1838,7 @@ enum {JSON_error = 0}; https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1838
 enum {JSON_en_main = 1};
 
 
-#line 728 "parser.rl"
+#line 742 "parser.rl"
 
 
 /*
@@ -1841,16 +1855,16 @@ static VALUE cParser_parse(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/json/parser/parser.c#L1855
   GET_PARSER;
 
 
-#line 1845 "parser.c"
+#line 1859 "parser.c"
 	{
 	cs = JSON_start;
 	}
 
-#line 744 "parser.rl"
+#line 758 "parser.rl"
   p = json->source;
   pe = p + json->len;
 
-#line 1854 "parser.c"
+#line 1868 "parser.c"
 	{
 	if ( p == pe )
 		goto _ (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]