diff options
-rw-r--r-- | ext/json/ext/generator/generator.c | 40 | ||||
-rw-r--r-- | ext/json/ext/generator/generator.h | 7 | ||||
-rw-r--r-- | ext/json/ext/parser/parser.c | 308 | ||||
-rw-r--r-- | ext/json/ext/parser/parser.rl | 80 | ||||
-rw-r--r-- | json.gemspec | bin | 4869 -> 4886 bytes | |||
-rw-r--r-- | json_pure.gemspec | 6 |
6 files changed, 265 insertions, 176 deletions
diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c index a135e28..faa4fdf 100644 --- a/ext/json/ext/generator/generator.c +++ b/ext/json/ext/generator/generator.c @@ -7,7 +7,13 @@ static ID i_encoding, i_encode; #endif static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject, - mHash, mArray, mFixnum, mBignum, mFloat, mString, mString_Extend, + mHash, mArray, +#ifdef RUBY_INTEGER_UNIFICATION + mInteger, +#else + mFixnum, mBignum, +#endif + mFloat, mString, mString_Extend, mTrueClass, mFalseClass, mNilClass, eGeneratorError, eNestingError, CRegexp_MULTILINE, CJSON_SAFE_STATE_PROTOTYPE, i_SAFE_STATE_PROTOTYPE; @@ -342,6 +348,18 @@ static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) { GENERATE_JSON(array); } +#ifdef RUBY_INTEGER_UNIFICATION +/* + * call-seq: to_json(*) + * + * Returns a JSON string representation for this Integer number. + */ +static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self) +{ + GENERATE_JSON(integer); +} + +#else /* * call-seq: to_json(*) * @@ -361,6 +379,7 @@ static VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self) { GENERATE_JSON(bignum); } +#endif /* * call-seq: to_json(*) @@ -825,6 +844,16 @@ static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_S fbuffer_append_str(buffer, tmp); } +#ifdef RUBY_INTEGER_UNIFICATION +static void generate_json_integer(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) +{ + if (FIXNUM_P(obj)) + generate_json_fixnum(buffer, Vstate, state, obj); + else + generate_json_bignum(buffer, Vstate, state, obj); +} +#endif + static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) { double value = RFLOAT_VALUE(obj); @@ -858,9 +887,9 @@ static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *s generate_json_false(buffer, Vstate, state, obj); } else if (obj == Qtrue) { generate_json_true(buffer, Vstate, state, obj); - } else if (klass == rb_cFixnum) { + } else if (FIXNUM_P(obj)) { generate_json_fixnum(buffer, Vstate, state, obj); - } else if (klass == rb_cBignum) { + } else if (RB_TYPE_P(obj, T_BIGNUM)) { generate_json_bignum(buffer, Vstate, state, obj); } else if (klass == rb_cFloat) { generate_json_float(buffer, Vstate, state, obj); @@ -1402,10 +1431,15 @@ void Init_generator(void) rb_define_method(mHash, "to_json", mHash_to_json, -1); mArray = rb_define_module_under(mGeneratorMethods, "Array"); rb_define_method(mArray, "to_json", mArray_to_json, -1); +#ifdef RUBY_INTEGER_UNIFICATION + mInteger = rb_define_module_under(mGeneratorMethods, "Integer"); + rb_define_method(mInteger, "to_json", mInteger_to_json, -1); +#else mFixnum = rb_define_module_under(mGeneratorMethods, "Fixnum"); rb_define_method(mFixnum, "to_json", mFixnum_to_json, -1); mBignum = rb_define_module_under(mGeneratorMethods, "Bignum"); rb_define_method(mBignum, "to_json", mBignum_to_json, -1); +#endif mFloat = rb_define_module_under(mGeneratorMethods, "Float"); rb_define_method(mFloat, "to_json", mFloat_to_json, -1); mString = rb_define_module_under(mGeneratorMethods, "String"); diff --git a/ext/json/ext/generator/generator.h b/ext/json/ext/generator/generator.h index 298c0a4..eb4557f 100644 --- a/ext/json/ext/generator/generator.h +++ b/ext/json/ext/generator/generator.h @@ -99,8 +99,12 @@ typedef struct JSON_Generator_StateStruct { static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self); static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self); +#ifdef RUBY_INTEGER_UNIFICATION +static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self); +#else static VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self); static VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self); +#endif static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self); static VALUE mString_included_s(VALUE self, VALUE modul); static VALUE mString_to_json(int argc, VALUE *argv, VALUE self); @@ -122,6 +126,9 @@ static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_S static void generate_json_null(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); static void generate_json_false(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); static void generate_json_true(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +#ifdef RUBY_INTEGER_UNIFICATION +static void generate_json_integer(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +#endif static void generate_json_fixnum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index 9c9d76a..592e729 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -3,6 +3,28 @@ #include "../fbuffer/fbuffer.h" #include "parser.h" +#if defined HAVE_RUBY_ENCODING_H +# define EXC_ENCODING UTF_8, +# ifndef HAVE_RB_ENC_RAISE +static void +enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...) +{ + va_list args; + VALUE mesg; + + va_start(args, fmt); + mesg = rb_enc_vsprintf(enc, fmt, args); + va_end(args); + + rb_exc_raise(rb_exc_new3(exc, mesg)); +} +# define rb_enc_raise enc_raise +# endif +#else +# define EXC_ENCODING /* nothing */ +# define rb_enc_raise rb_raise +#endif + /* unicode */ static const char digit_values[256] = { @@ -68,9 +90,7 @@ static int convert_UTF32_to_UTF8(char *buf, UTF32 ch) } #ifdef HAVE_RUBY_ENCODING_H -static VALUE CEncoding_ASCII_8BIT, CEncoding_UTF_8, CEncoding_UTF_16BE, - CEncoding_UTF_16LE, CEncoding_UTF_32BE, CEncoding_UTF_32LE; -static ID i_encoding, i_encode; +static rb_encoding *UTF_8, *UTF_16BE, *UTF_16LE, *UTF_32BE, *UTF_32LE; #else static ID i_iconv; #endif @@ -84,19 +104,19 @@ static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, i_match_string, i_aset, i_aref, i_leftshift; -#line 110 "parser.rl" +#line 130 "parser.rl" -#line 92 "parser.c" -enum {JSON_object_start = 1}; -enum {JSON_object_first_final = 27}; -enum {JSON_object_error = 0}; +#line 112 "parser.c" +static const int JSON_object_start = 1; +static const int JSON_object_first_final = 27; +static const int JSON_object_error = 0; -enum {JSON_object_en_main = 1}; +static const int JSON_object_en_main = 1; -#line 151 "parser.rl" +#line 171 "parser.rl" static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -112,14 +132,14 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class); -#line 116 "parser.c" +#line 136 "parser.c" { cs = JSON_object_start; } -#line 166 "parser.rl" +#line 186 "parser.rl" -#line 123 "parser.c" +#line 143 "parser.c" { if ( p == pe ) goto _test_eof; @@ -147,7 +167,7 @@ case 2: goto st2; goto st0; tr2: -#line 133 "parser.rl" +#line 153 "parser.rl" { char *np; json->parsing_name = 1; @@ -160,7 +180,7 @@ st3: if ( ++p == pe ) goto _test_eof3; case 3: -#line 164 "parser.c" +#line 184 "parser.c" switch( (*p) ) { case 13: goto st3; case 32: goto st3; @@ -227,7 +247,7 @@ case 8: goto st8; goto st0; tr11: -#line 118 "parser.rl" +#line 138 "parser.rl" { VALUE v = Qnil; char *np = JSON_parse_value(json, p, pe, &v); @@ -247,7 +267,7 @@ st9: if ( ++p == pe ) goto _test_eof9; case 9: -#line 251 "parser.c" +#line 271 "parser.c" switch( (*p) ) { case 13: goto st9; case 32: goto st9; @@ -336,14 +356,14 @@ case 18: goto st9; goto st18; tr4: -#line 141 "parser.rl" +#line 161 "parser.rl" { p--; {p++; cs = 27; goto _out;} } goto st27; st27: if ( ++p == pe ) goto _test_eof27; case 27: -#line 347 "parser.c" +#line 367 "parser.c" goto st0; st19: if ( ++p == pe ) @@ -441,7 +461,7 @@ case 26: _out: {} } -#line 167 "parser.rl" +#line 187 "parser.rl" if (cs >= JSON_object_first_final) { if (json->create_additions) { @@ -466,15 +486,15 @@ case 26: -#line 470 "parser.c" -enum {JSON_value_start = 1}; -enum {JSON_value_first_final = 21}; -enum {JSON_value_error = 0}; +#line 490 "parser.c" +static const int JSON_value_start = 1; +static const int JSON_value_first_final = 21; +static const int JSON_value_error = 0; -enum {JSON_value_en_main = 1}; +static const int JSON_value_en_main = 1; -#line 271 "parser.rl" +#line 291 "parser.rl" static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -482,14 +502,14 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul int cs = EVIL; -#line 486 "parser.c" +#line 506 "parser.c" { cs = JSON_value_start; } -#line 278 "parser.rl" +#line 298 "parser.rl" -#line 493 "parser.c" +#line 513 "parser.c" { if ( p == pe ) goto _test_eof; @@ -514,14 +534,14 @@ st0: cs = 0; goto _out; tr0: -#line 219 "parser.rl" +#line 239 "parser.rl" { char *np = JSON_parse_string(json, p, pe, result); if (np == NULL) { p--; {p++; cs = 21; goto _out;} } else {p = (( np))-1;} } goto st21; tr2: -#line 224 "parser.rl" +#line 244 "parser.rl" { char *np; if(pe > p + 9 - json->quirks_mode && !strncmp(MinusInfinity, p, 9)) { @@ -530,7 +550,7 @@ tr2: {p = (( p + 10))-1;} p--; {p++; cs = 21; goto _out;} } else { - rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p); + rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p); } } np = JSON_parse_float(json, p, pe, result); @@ -541,7 +561,7 @@ tr2: } goto st21; tr5: -#line 242 "parser.rl" +#line 262 "parser.rl" { char *np; json->current_nesting++; @@ -551,7 +571,7 @@ tr5: } goto st21; tr9: -#line 250 "parser.rl" +#line 270 "parser.rl" { char *np; json->current_nesting++; @@ -561,39 +581,39 @@ tr9: } goto st21; tr16: -#line 212 "parser.rl" +#line 232 "parser.rl" { if (json->allow_nan) { *result = CInfinity; } else { - rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p - 8); + rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 8); } } goto st21; tr18: -#line 205 "parser.rl" +#line 225 "parser.rl" { if (json->allow_nan) { *result = CNaN; } else { - rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p - 2); + rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 2); } } goto st21; tr22: -#line 199 "parser.rl" +#line 219 "parser.rl" { *result = Qfalse; } goto st21; tr25: -#line 196 "parser.rl" +#line 216 "parser.rl" { *result = Qnil; } goto st21; tr28: -#line 202 "parser.rl" +#line 222 "parser.rl" { *result = Qtrue; } @@ -602,9 +622,9 @@ st21: if ( ++p == pe ) goto _test_eof21; case 21: -#line 258 "parser.rl" +#line 278 "parser.rl" { p--; {p++; cs = 21; goto _out;} } -#line 608 "parser.c" +#line 628 "parser.c" goto st0; st2: if ( ++p == pe ) @@ -765,7 +785,7 @@ case 20: _out: {} } -#line 279 "parser.rl" +#line 299 "parser.rl" if (cs >= JSON_value_first_final) { return p; @@ -775,15 +795,15 @@ case 20: } -#line 779 "parser.c" -enum {JSON_integer_start = 1}; -enum {JSON_integer_first_final = 3}; -enum {JSON_integer_error = 0}; +#line 799 "parser.c" +static const int JSON_integer_start = 1; +static const int JSON_integer_first_final = 3; +static const int JSON_integer_error = 0; -enum {JSON_integer_en_main = 1}; +static const int JSON_integer_en_main = 1; -#line 295 "parser.rl" +#line 315 "parser.rl" static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -791,15 +811,15 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res int cs = EVIL; -#line 795 "parser.c" +#line 815 "parser.c" { cs = JSON_integer_start; } -#line 302 "parser.rl" +#line 322 "parser.rl" json->memo = p; -#line 803 "parser.c" +#line 823 "parser.c" { if ( p == pe ) goto _test_eof; @@ -833,14 +853,14 @@ case 3: goto st0; goto tr4; tr4: -#line 292 "parser.rl" +#line 312 "parser.rl" { p--; {p++; cs = 4; goto _out;} } goto st4; st4: if ( ++p == pe ) goto _test_eof4; case 4: -#line 844 "parser.c" +#line 864 "parser.c" goto st0; st5: if ( ++p == pe ) @@ -859,7 +879,7 @@ case 5: _out: {} } -#line 304 "parser.rl" +#line 324 "parser.rl" if (cs >= JSON_integer_first_final) { long len = p - json->memo; @@ -874,15 +894,15 @@ case 5: } -#line 878 "parser.c" -enum {JSON_float_start = 1}; -enum {JSON_float_first_final = 8}; -enum {JSON_float_error = 0}; +#line 898 "parser.c" +static const int JSON_float_start = 1; +static const int JSON_float_first_final = 8; +static const int JSON_float_error = 0; -enum {JSON_float_en_main = 1}; +static const int JSON_float_en_main = 1; -#line 329 "parser.rl" +#line 349 "parser.rl" static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -890,15 +910,15 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul int cs = EVIL; -#line 894 "parser.c" +#line 914 "parser.c" { cs = JSON_float_start; } -#line 336 "parser.rl" +#line 356 "parser.rl" json->memo = p; -#line 902 "parser.c" +#line 922 "parser.c" { if ( p == pe ) goto _test_eof; @@ -956,14 +976,14 @@ case 8: goto st0; goto tr9; tr9: -#line 323 "parser.rl" +#line 343 "parser.rl" { p--; {p++; cs = 9; goto _out;} } goto st9; st9: if ( ++p == pe ) goto _test_eof9; case 9: -#line 967 "parser.c" +#line 987 "parser.c" goto st0; st5: if ( ++p == pe ) @@ -1024,7 +1044,7 @@ case 7: _out: {} } -#line 338 "parser.rl" +#line 358 "parser.rl" if (cs >= JSON_float_first_final) { long len = p - json->memo; @@ -1040,15 +1060,15 @@ case 7: -#line 1044 "parser.c" -enum {JSON_array_start = 1}; -enum {JSON_array_first_final = 17}; -enum {JSON_array_error = 0}; +#line 1064 "parser.c" +static const int JSON_array_start = 1; +static const int JSON_array_first_final = 17; +static const int JSON_array_error = 0; -enum {JSON_array_en_main = 1}; +static const int JSON_array_en_main = 1; -#line 381 "parser.rl" +#line 401 "parser.rl" static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -1062,14 +1082,14 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class); -#line 1066 "parser.c" +#line 1086 "parser.c" { cs = JSON_array_start; } -#line 394 "parser.rl" +#line 414 "parser.rl" -#line 1073 "parser.c" +#line 1093 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1108,7 +1128,7 @@ case 2: goto st2; goto st0; tr2: -#line 358 "parser.rl" +#line 378 "parser.rl" { VALUE v = Qnil; char *np = JSON_parse_value(json, p, pe, &v); @@ -1128,7 +1148,7 @@ st3: if ( ++p == pe ) goto _test_eof3; case 3: -#line 1132 "parser.c" +#line 1152 "parser.c" switch( (*p) ) { case 13: goto st3; case 32: goto st3; @@ -1228,14 +1248,14 @@ case 12: goto st3; goto st12; tr4: -#line 373 "parser.rl" +#line 393 "parser.rl" { p--; {p++; cs = 17; goto _out;} } goto st17; st17: if ( ++p == pe ) goto _test_eof17; case 17: -#line 1239 "parser.c" +#line 1259 "parser.c" goto st0; st13: if ( ++p == pe ) @@ -1291,12 +1311,12 @@ case 16: _out: {} } -#line 395 "parser.rl" +#line 415 "parser.rl" if(cs >= JSON_array_first_final) { return p + 1; } else { - rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p); + rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p); return NULL; } } @@ -1372,15 +1392,15 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd) } -#line 1376 "parser.c" -enum {JSON_string_start = 1}; -enum {JSON_string_first_final = 8}; -enum {JSON_string_error = 0}; +#line 1396 "parser.c" +static const int JSON_string_start = 1; +static const int JSON_string_first_final = 8; +static const int JSON_string_error = 0; -enum {JSON_string_en_main = 1}; +static const int JSON_string_en_main = 1; -#line 494 "parser.rl" +#line 514 "parser.rl" static int @@ -1402,15 +1422,15 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu *result = rb_str_buf_new(0); -#line 1406 "parser.c" +#line 1426 "parser.c" { cs = JSON_string_start; } -#line 515 "parser.rl" +#line 535 "parser.rl" json->memo = p; -#line 1414 "parser.c" +#line 1434 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1435,7 +1455,7 @@ case 2: goto st0; goto st2; tr2: -#line 480 "parser.rl" +#line 500 "parser.rl" { *result = json_string_unescape(*result, json->memo + 1, p); if (NIL_P(*result)) { @@ -1446,14 +1466,14 @@ tr2: {p = (( p + 1))-1;} } } -#line 491 "parser.rl" +#line 511 "parser.rl" { p--; {p++; cs = 8; goto _out;} } goto st8; st8: if ( ++p == pe ) goto _test_eof8; case 8: -#line 1457 "parser.c" +#line 1477 "parser.c" goto st0; st3: if ( ++p == pe ) @@ -1529,7 +1549,7 @@ case 7: _out: {} } -#line 517 "parser.rl" +#line 537 "parser.rl" if (json->create_additions && RTEST(match_string = json->match_string)) { VALUE klass; @@ -1566,29 +1586,29 @@ case 7: static VALUE convert_encoding(VALUE source) { - char *ptr = RSTRING_PTR(source); + const char *ptr = RSTRING_PTR(source); long len = RSTRING_LEN(source); if (len < 2) { rb_raise(eParserError, "A JSON text must at least contain two octets!"); } #ifdef HAVE_RUBY_ENCODING_H { - VALUE encoding = rb_funcall(source, i_encoding, 0); - if (encoding == CEncoding_ASCII_8BIT) { + rb_encoding *enc = rb_enc_get(source); + if (enc == rb_ascii8bit_encoding()) { if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) { - source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_32BE); + source = rb_str_conv_enc(source, UTF_32BE, rb_utf8_encoding()); } else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) { - source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_16BE); + source = rb_str_conv_enc(source, UTF_16BE, rb_utf8_encoding()); } else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) { - source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_32LE); + source = rb_str_conv_enc(source, UTF_32LE, rb_utf8_encoding()); } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) { - source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_16LE); + source = rb_str_conv_enc(source, UTF_16LE, rb_utf8_encoding()); } else { source = rb_str_dup(source); FORCE_UTF8(source); } } else { - source = rb_funcall(source, i_encode, 1, CEncoding_UTF_8); + source = rb_str_conv_enc(source, NULL, rb_utf8_encoding()); } } #else @@ -1639,12 +1659,18 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) if (json->Vsource) { rb_raise(rb_eTypeError, "already initialized instance"); } +#ifdef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH + rb_scan_args(argc, argv, "1:", &source, &opts); +#else rb_scan_args(argc, argv, "11", &source, &opts); +#endif if (!NIL_P(opts)) { +#ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash"); if (NIL_P(opts)) { rb_raise(rb_eArgError, "opts needs to be like a hash"); } else { +#endif VALUE tmp = ID2SYM(i_max_nesting); if (option_given_p(opts, tmp)) { VALUE max_nesting = rb_hash_aref(opts, tmp); @@ -1707,7 +1733,9 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } else { json->match_string = Qnil; } +#ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH } +#endif } else { json->max_nesting = 100; json->allow_nan = 0; @@ -1716,12 +1744,11 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) json->object_class = Qnil; json->array_class = Qnil; } - source = rb_convert_type(source, T_STRING, "String", "to_str"); + StringValue(source); if (!json->quirks_mode) { - source = convert_encoding(StringValue(source)); + source = convert_encoding(source); } json->current_nesting = 0; - StringValue(source); json->len = RSTRING_LEN(source); json->source = RSTRING_PTR(source);; json->Vsource = source; @@ -1729,15 +1756,15 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } -#line 1733 "parser.c" -enum {JSON_start = 1}; -enum {JSON_first_final = 10}; -enum {JSON_error = 0}; +#line 1760 "parser.c" +static const int JSON_start = 1; +static const int JSON_first_final = 10; +static const int JSON_error = 0; -enum {JSON_en_main = 1}; +static const int JSON_en_main = 1; -#line 740 "parser.rl" +#line 767 "parser.rl" static VALUE cParser_parse_strict(VALUE self) @@ -1748,16 +1775,16 @@ static VALUE cParser_parse_strict(VALUE self) GET_PARSER; -#line 1752 "parser.c" +#line 1779 "parser.c" { cs = JSON_start; } -#line 750 "parser.rl" +#line 777 "parser.rl" p = json->source; pe = p + json->len; -#line 1761 "parser.c" +#line 1788 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1813,7 +1840,7 @@ case 5: goto st1; goto st5; tr3: -#line 729 "parser.rl" +#line 756 "parser.rl" { char *np; json->current_nesting = 1; @@ -1822,7 +1849,7 @@ tr3: } goto st10; tr4: -#line 722 "parser.rl" +#line 749 "parser.rl" { char *np; json->current_nesting = 1; @@ -1834,7 +1861,7 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: -#line 1838 "parser.c" +#line 1865 "parser.c" switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -1891,27 +1918,27 @@ case 9: _out: {} } -#line 753 "parser.rl" +#line 780 "parser.rl" if (cs >= JSON_first_final && p == pe) { return result; } else { - rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p); + rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p); return Qnil; } } -#line 1907 "parser.c" -enum {JSON_quirks_mode_start = 1}; -enum {JSON_quirks_mode_first_final = 10}; -enum {JSON_quirks_mode_error = 0}; +#line 1934 "parser.c" +static const int JSON_quirks_mode_start = 1; +static const int JSON_quirks_mode_first_final = 10; +static const int JSON_quirks_mode_error = 0; -enum {JSON_quirks_mode_en_main = 1}; +static const int JSON_quirks_mode_en_main = 1; -#line 778 "parser.rl" +#line 805 "parser.rl" static VALUE cParser_parse_quirks_mode(VALUE self) @@ -1922,16 +1949,16 @@ static VALUE cParser_parse_quirks_mode(VALUE self) GET_PARSER; -#line 1926 "parser.c" +#line 1953 "parser.c" { cs = JSON_quirks_mode_start; } -#line 788 "parser.rl" +#line 815 "parser.rl" p = json->source; pe = p + json->len; -#line 1935 "parser.c" +#line 1962 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1965,7 +1992,7 @@ st0: cs = 0; goto _out; tr2: -#line 770 "parser.rl" +#line 797 "parser.rl" { char *np = JSON_parse_value(json, p, pe, &result); if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;} @@ -1975,7 +2002,7 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: -#line 1979 "parser.c" +#line 2006 "parser.c" switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -2064,12 +2091,12 @@ case 9: _out: {} } -#line 791 "parser.rl" +#line 818 "parser.rl" if (cs >= JSON_quirks_mode_first_final && p == pe) { return result; } else { - rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p); + rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p); return Qnil; } } @@ -2194,14 +2221,11 @@ void Init_parser(void) i_aref = rb_intern("[]"); i_leftshift = rb_intern("<<"); #ifdef HAVE_RUBY_ENCODING_H - CEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8")); - CEncoding_UTF_16BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16be")); - CEncoding_UTF_16LE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16le")); - CEncoding_UTF_32BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-32be")); - CEncoding_UTF_32LE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-32le")); - CEncoding_ASCII_8BIT = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("ascii-8bit")); - i_encoding = rb_intern("encoding"); - i_encode = rb_intern("encode"); + UTF_8 = rb_utf8_encoding(); + UTF_16BE = rb_enc_find("utf-16be"); + UTF_16LE = rb_enc_find("utf-16le"); + UTF_32BE = rb_enc_find("utf-32be"); + UTF_32LE = rb_enc_find("utf-32le"); #else i_iconv = rb_intern("iconv"); #endif diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl index 216ad26..2fa0cae 100644 --- a/ext/json/ext/parser/parser.rl +++ b/ext/json/ext/parser/parser.rl @@ -1,6 +1,28 @@ #include "../fbuffer/fbuffer.h" #include "parser.h" +#if defined HAVE_RUBY_ENCODING_H +# define EXC_ENCODING UTF_8, +# ifndef HAVE_RB_ENC_RAISE +static void +enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...) +{ + va_list args; + VALUE mesg; + + va_start(args, fmt); + mesg = rb_enc_vsprintf(enc, fmt, args); + va_end(args); + + rb_exc_raise(rb_exc_new3(exc, mesg)); +} +# define rb_enc_raise enc_raise +# endif +#else +# define EXC_ENCODING /* nothing */ +# define rb_enc_raise rb_raise +#endif + /* unicode */ static const char digit_values[256] = { @@ -66,9 +88,7 @@ static int convert_UTF32_to_UTF8(char *buf, UTF32 ch) } #ifdef HAVE_RUBY_ENCODING_H -static VALUE CEncoding_ASCII_8BIT, CEncoding_UTF_8, CEncoding_UTF_16BE, - CEncoding_UTF_16LE, CEncoding_UTF_32BE, CEncoding_UTF_32LE; -static ID i_encoding, i_encode; +static rb_encoding *UTF_8, *UTF_16BE, *UTF_16LE, *UTF_32BE, *UTF_32LE; #else static ID i_iconv; #endif @@ -206,14 +226,14 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu if (json->allow_nan) { *result = CNaN; } else { - rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p - 2); + rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 2); } } action parse_infinity { if (json->allow_nan) { *result = CInfinity; } else { - rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p - 8); + rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 8); } } action parse_string { @@ -229,7 +249,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu fexec p + 10; fhold; fbreak; } else { - rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p); + rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p); } } np = JSON_parse_float(json, fpc, pe, result); @@ -396,7 +416,7 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul if(cs >= JSON_array_first_final) { return p + 1; } else { - rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p); + rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p); return NULL; } } @@ -550,29 +570,29 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu static VALUE convert_encoding(VALUE source) { - char *ptr = RSTRING_PTR(source); + const char *ptr = RSTRING_PTR(source); long len = RSTRING_LEN(source); if (len < 2) { rb_raise(eParserError, "A JSON text must at least contain two octets!"); } #ifdef HAVE_RUBY_ENCODING_H { - VALUE encoding = rb_funcall(source, i_encoding, 0); - if (encoding == CEncoding_ASCII_8BIT) { + rb_encoding *enc = rb_enc_get(source); + if (enc == rb_ascii8bit_encoding()) { if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) { - source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_32BE); + source = rb_str_conv_enc(source, UTF_32BE, rb_utf8_encoding()); } else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) { - source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_16BE); + source = rb_str_conv_enc(source, UTF_16BE, rb_utf8_encoding()); } else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) { - source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_32LE); + source = rb_str_conv_enc(source, UTF_32LE, rb_utf8_encoding()); } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) { - source = rb_funcall(source, i_encode, 2, CEncoding_UTF_8, CEncoding_UTF_16LE); + source = rb_str_conv_enc(source, UTF_16LE, rb_utf8_encoding()); } else { source = rb_str_dup(source); FORCE_UTF8(source); } } else { - source = rb_funcall(source, i_encode, 1, CEncoding_UTF_8); + source = rb_str_conv_enc(source, NULL, rb_utf8_encoding()); } } #else @@ -623,12 +643,18 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) if (json->Vsource) { rb_raise(rb_eTypeError, "already initialized instance"); } +#ifdef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH + rb_scan_args(argc, argv, "1:", &source, &opts); +#else rb_scan_args(argc, argv, "11", &source, &opts); +#endif if (!NIL_P(opts)) { +#ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash"); if (NIL_P(opts)) { rb_raise(rb_eArgError, "opts needs to be like a hash"); } else { +#endif VALUE tmp = ID2SYM(i_max_nesting); if (option_given_p(opts, tmp)) { VALUE max_nesting = rb_hash_aref(opts, tmp); @@ -691,7 +717,9 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } else { json->match_string = Qnil; } +#ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH } +#endif } else { json->max_nesting = 100; json->allow_nan = 0; @@ -700,12 +728,11 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) json->object_class = Qnil; json->array_class = Qnil; } - source = rb_convert_type(source, T_STRING, "String", "to_str"); + StringValue(source); if (!json->quirks_mode) { - source = convert_encoding(StringValue(source)); + source = convert_encoding(source); } json->current_nesting = 0; - StringValue(source); json->len = RSTRING_LEN(source); json->source = RSTRING_PTR(source);; json->Vsource = source; @@ -754,7 +781,7 @@ static VALUE cParser_parse_strict(VALUE self) if (cs >= JSON_first_final && p == pe) { return result; } else { - rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p); + rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p); return Qnil; } } @@ -792,7 +819,7 @@ static VALUE cParser_parse_quirks_mode(VALUE self) if (cs >= JSON_quirks_mode_first_final && p == pe) { return result; } else { - rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p); + rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p); return Qnil; } } @@ -917,14 +944,11 @@ void Init_parser(void) i_aref = rb_intern("[]"); i_leftshift = rb_intern("<<"); #ifdef HAVE_RUBY_ENCODING_H - CEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8")); - CEncoding_UTF_16BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16be")); - CEncoding_UTF_16LE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16le")); - CEncoding_UTF_32BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-32be")); - CEncoding_UTF_32LE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-32le")); - CEncoding_ASCII_8BIT = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("ascii-8bit")); - i_encoding = rb_intern("encoding"); - i_encode = rb_intern("encode"); + UTF_8 = rb_utf8_encoding(); + UTF_16BE = rb_enc_find("utf-16be"); + UTF_16LE = rb_enc_find("utf-16le"); + UTF_32BE = rb_enc_find("utf-32be"); + UTF_32LE = rb_enc_find("utf-32le"); #else i_iconv = rb_intern("iconv"); #endif diff --git a/json.gemspec b/json.gemspec Binary files differindex d0b0674..03427c4 100644 --- a/json.gemspec +++ b/json.gemspec diff --git a/json_pure.gemspec b/json_pure.gemspec index dfd90b0..0dd12d5 100644 --- a/json_pure.gemspec +++ b/json_pure.gemspec @@ -8,15 +8,15 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.require_paths = ["lib"] s.authors = ["Florian Frank"] - s.date = "2016-02-25" + s.date = "2016-06-21" s.description = "This is a JSON implementation in pure Ruby." s.email = "flori@ping.de" s.extra_rdoc_files = ["README.md"] - s.files = ["./tests/test_json.rb", "./tests/test_json_addition.rb", "./tests/test_json_encoding.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_generate.rb", "./tests/test_json_generic_object.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb", ".gitignore", ".travis.yml", "CHANGES", "Gemfile", "README-json-jruby.markdown", "README.md", "Rakefile", "TODO", "VERSION", "data/example.json", "data/index.html", "data/prototype.js", "diagrams/.keep", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/depend", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser/depend", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.c", "ext/json/ext/parser/parser.h", "ext/json/ext/parser/parser.rl", "ext/json/extconf.rb", "install.rb", "java/src/json/ext/ByteListTranscoder.java", "java/src/json/ext/Generator.java", "java/src/json/ext/GeneratorMethods.java", "java/src/json/ext/GeneratorService.java", "java/src/json/ext/GeneratorState.java", "java/src/json/ext/OptionsReader.java", "java/src/json/ext/Parser.java", "java/src/json/ext/Parser.rl", "java/src/json/ext/ParserService.java", "java/src/json/ext/RuntimeInfo.java", "java/src/json/ext/StringDecoder.java", "java/src/json/ext/StringEncoder.java", "java/src/json/ext/Utils.java", "json-java.gemspec", "json.gemspec", "json_pure.gemspec", "lib/json.rb", "lib/json/add/bigdecimal.rb", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/date.rb", "lib/json/add/date_time.rb", "lib/json/add/exception.rb", "lib/json/add/ostruct.rb", "lib/json/add/range.rb", "lib/json/add/rational.rb", "lib/json/add/regexp.rb", "lib/json/add/struct.rb", "lib/json/add/symbol.rb", "lib/json/add/time.rb", "lib/json/common.rb", "lib/json/ext.rb", "lib/json/ext/.keep", "lib/json/generic_object.rb", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "tests/fixtures/fail1.json", "tests/fixtures/fail10.json", "tests/fixtures/fail11.json", "tests/fixtures/fail12.json", "tests/fixtures/fail13.json", "tests/fixtures/fail14.json", "tests/fixtures/fail18.json", "tests/fixtures/fail19.json", "tests/fixtures/fail2.json", "tests/fixtures/fail20.json", "tests/fixtures/fail21.json", "tests/fixtures/fail22.json", "tests/fixtures/fail23.json", "tests/fixtures/fail24.json", "tests/fixtures/fail25.json", "tests/fixtures/fail27.json", "tests/fixtures/fail28.json", "tests/fixtures/fail3.json", "tests/fixtures/fail4.json", "tests/fixtures/fail5.json", "tests/fixtures/fail6.json", "tests/fixtures/fail7.json", "tests/fixtures/fail8.json", "tests/fixtures/fail9.json", "tests/fixtures/pass1.json", "tests/fixtures/pass15.json", "tests/fixtures/pass16.json", "tests/fixtures/pass17.json", "tests/fixtures/pass2.json", "tests/fixtures/pass26.json", "tests/fixtures/pass3.json", "tests/setup_variant.rb", "tests/test_json.rb", "tests/test_json_addition.rb", "tests/test_json_encoding.rb", "tests/test_json_fixtures.rb", "tests/test_json_generate.rb", "tests/test_json_generic_object.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "tools/fuzz.rb", "tools/server.rb"] + s.files = ["./tests/test_json.rb", "./tests/test_json_addition.rb", "./tests/test_json_encoding.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_generate.rb", "./tests/test_json_generic_object.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb", ".gitignore", ".travis.yml", "CHANGES", "Gemfile", "README-json-jruby.markdown", "README.md", "Rakefile", "TODO", "VERSION", "data/example.json", "data/index.html", "data/prototype.js", "diagrams/.keep", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/depend", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser/depend", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.c", "ext/json/ext/parser/parser.h", "ext/json/ext/parser/parser.rl", "ext/json/extconf.rb", "install.rb", "java/src/json/ext/ByteListTranscoder.java", "java/src/json/ext/Generator.java", "java/src/json/ext/GeneratorMethods.java", "java/src/json/ext/GeneratorService.java", "java/src/json/ext/GeneratorState.java", "java/src/json/ext/OptionsReader.java", "java/src/json/ext/Parser.java", "java/src/json/ext/Parser.rl", "java/src/json/ext/ParserService.java", "java/src/json/ext/RuntimeInfo.java", "java/src/json/ext/StringDecoder.java", "java/src/json/ext/StringEncoder.java", "java/src/json/ext/Utils.java", "json-java.gemspec", "json.gemspec", "json_pure.gemspec", "lib/json.rb", "lib/json/add/bigdecimal.rb", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/date.rb", "lib/json/add/date_time.rb", "lib/json/add/exception.rb", "lib/json/add/ostruct.rb", "lib/json/add/range.rb", "lib/json/add/rational.rb", "lib/json/add/regexp.rb", "lib/json/add/struct.rb", "lib/json/add/symbol.rb", "lib/json/add/time.rb", "lib/json/common.rb", "lib/json/ext.rb", "lib/json/ext/.keep", "lib/json/generic_object.rb", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "tests/fixtures/fail1.json", "tests/fixtures/fail10.json", "tests/fixtures/fail11.json", "tests/fixtures/fail12.json", "tests/fixtures/fail13.json", "tests/fixtures/fail14.json", "tests/fixtures/fail18.json", "tests/fixtures/fail19.json", "tests/fixtures/fail2.json", "tests/fixtures/fail20.json", "tests/fixtures/fail21.json", "tests/fixtures/fail22.json", "tests/fixtures/fail23.json", "tests/fixtures/fail24.json", "tests/fixtures/fail25.json", "tests/fixtures/fail27.json", "tests/fixtures/fail28.json", "tests/fixtures/fail3.json", "tests/fixtures/fail4.json", "tests/fixtures/fail5.json", "tests/fixtures/fail6.json", "tests/fixtures/fail7.json", "tests/fixtures/fail8.json", "tests/fixtures/fail9.json", "tests/fixtures/pass1.json", "tests/fixtures/pass15.json", "tests/fixtures/pass16.json", "tests/fixtures/pass17.json", "tests/fixtures/pass2.json", "tests/fixtures/pass26.json", "tests/fixtures/pass3.json", "tests/setup_variant.rb", "tests/test_json.rb", "tests/test_json_addition.rb", "tests/test_json_encoding.rb", "tests/test_json_fixtures.rb", "tests/test_json_generate.rb", "tests/test_json_generic_object.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "tools/diff.sh", "tools/fuzz.rb", "tools/server.rb"] s.homepage = "http://flori.github.com/json" s.licenses = ["Ruby"] s.rdoc_options = ["--title", "JSON implemention for ruby", "--main", "README.md"] - s.rubygems_version = "2.5.0" + s.rubygems_version = "2.5.1" s.summary = "JSON Implementation for Ruby" s.test_files = ["./tests/test_json.rb", "./tests/test_json_addition.rb", "./tests/test_json_encoding.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_generate.rb", "./tests/test_json_generic_object.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb"] |