From 797ce5386e3919b33831c01561b381a475757f8a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 19 Oct 2015 10:53:16 -0700 Subject: resize strings after parsing The parser uses `rb_str_buf_new` to allocate new strings. `rb_str_buf_new` [has a minimum size of 128 and is not an embedded string](https://github.com/ruby/ruby/blob/9949407fd90c1c5bfe332141c75db995a9b867aa/string.c#L1119-L1135). This causes applications that parse JS to allocate extra memory when parsing short strings. For a real-world example, we can use the mime-types gem. The mime-types gem stores all mime types inside a JSON file and parses them when you require the gem. Here is a sample program: ```ruby require 'objspace' require 'mime-types' GC.start GC.start p ObjectSpace.memsize_of_all String ``` The example program loads the mime-types gem and outputs the total space used by all strings. Here are the results of the program before and after this patch: ** Before ** ``` [aaron@TC json (memuse)]$ ruby test.rb 5497494 [aaron@TC json (memuse)]$ ``` ** After ** ``` [aaron@TC json (memuse)]$ ruby -I lib:ext test.rb 3335862 [aaron@TC json (memuse)]$ ``` This change results in a ~40% reduction of memory use for strings in the mime-types gem. Thanks @matthewd for finding the problem, and @nobu for the patch! --- ext/json/ext/parser/parser.rl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl index 04d1b47..f479281 100644 --- a/ext/json/ext/parser/parser.rl +++ b/ext/json/ext/parser/parser.rl @@ -542,6 +542,8 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu if (json->symbolize_names && json->parsing_name) { *result = rb_str_intern(*result); + } else { + rb_str_resize(*result, RSTRING_LEN(*result)); } if (cs >= JSON_string_first_final) { return p + 1; -- cgit v1.2.1 From ad7e997411f8de2184ed4f61b0d207b0ea3e76ef Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 3 Mar 2016 14:49:15 -0800 Subject: regenerate parser --- ext/json/ext/parser/parser.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index 8d83808..7e32ef0 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -1647,6 +1647,8 @@ case 7: if (json->symbolize_names && json->parsing_name) { *result = rb_str_intern(*result); + } else { + rb_str_resize(*result, RSTRING_LEN(*result)); } if (cs >= JSON_string_first_final) { return p + 1; -- cgit v1.2.1 From a33422799cc104acf8eb7884c4613a714ccc5da3 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 24 Apr 2016 02:21:20 +0900 Subject: Append newline at EOF --- lib/json/add/complex.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/json/add/complex.rb b/lib/json/add/complex.rb index 2723f60..3d653bb 100644 --- a/lib/json/add/complex.rb +++ b/lib/json/add/complex.rb @@ -25,4 +25,4 @@ class Complex def to_json(*) as_json.to_json end -end \ No newline at end of file +end -- cgit v1.2.1 From 253c61548214effb11fbfd2a256578fe16d8e2bc Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 24 Apr 2016 02:17:49 +0900 Subject: Remove useless methods Remove useless overriding methods, [] and []=, which are same as OpenStruct. --- lib/json/generic_object.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/json/generic_object.rb b/lib/json/generic_object.rb index 8b8fd53..3a14f0e 100644 --- a/lib/json/generic_object.rb +++ b/lib/json/generic_object.rb @@ -47,14 +47,6 @@ module JSON table end - def [](name) - table[name.to_sym] - end - - def []=(name, value) - __send__ "#{name}=", value - end - def |(other) self.class[other.to_hash.merge(to_hash)] end -- cgit v1.2.1 From 16bd77f50d055dd85acf4e11296141c5e984b350 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 24 Apr 2016 02:10:53 +0900 Subject: Use assert_raise consistently --- tests/json_addition_test.rb | 4 +-- tests/json_common_interface_test.rb | 4 +-- tests/json_fixtures_test.rb | 2 +- tests/json_generator_test.rb | 34 ++++++++++++------------- tests/json_parser_test.rb | 50 ++++++++++++++++++------------------- 5 files changed, 47 insertions(+), 47 deletions(-) diff --git a/tests/json_addition_test.rb b/tests/json_addition_test.rb index 128f34a..cb07659 100644 --- a/tests/json_addition_test.rb +++ b/tests/json_addition_test.rb @@ -108,7 +108,7 @@ class JSONAdditionTest < Test::Unit::TestCase c = C.new assert !C.json_creatable? json = generate(c) - assert_raises(ArgumentError, NameError) { parse(json, :create_additions => true) } + assert_raise(ArgumentError, NameError) { parse(json, :create_additions => true) } end def test_raw_strings @@ -147,7 +147,7 @@ class JSONAdditionTest < Test::Unit::TestCase assert_equal s, JSON(JSON(s), :create_additions => true) struct = Struct.new :foo, :bar s = struct.new 4711, 'foot' - assert_raises(JSONError) { JSON(s) } + assert_raise(JSONError) { JSON(s) } begin raise TypeError, "test me" rescue TypeError => e diff --git a/tests/json_common_interface_test.rb b/tests/json_common_interface_test.rb index 38136fa..30c54c8 100644 --- a/tests/json_common_interface_test.rb +++ b/tests/json_common_interface_test.rb @@ -100,8 +100,8 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase too_deep = '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]' assert_equal too_deep, dump(eval(too_deep)) assert_kind_of String, Marshal.dump(eval(too_deep)) - assert_raises(ArgumentError) { dump(eval(too_deep), 100) } - assert_raises(ArgumentError) { Marshal.dump(eval(too_deep), 100) } + assert_raise(ArgumentError) { dump(eval(too_deep), 100) } + assert_raise(ArgumentError) { Marshal.dump(eval(too_deep), 100) } assert_equal too_deep, dump(eval(too_deep), 101) assert_kind_of String, Marshal.dump(eval(too_deep), 101) output = StringIO.new diff --git a/tests/json_fixtures_test.rb b/tests/json_fixtures_test.rb index 6681b8d..0419983 100644 --- a/tests/json_fixtures_test.rb +++ b/tests/json_fixtures_test.rb @@ -22,7 +22,7 @@ class JSONFixturesTest < Test::Unit::TestCase def test_failing for name, source in @failed - assert_raises(JSON::ParserError, JSON::NestingError, + assert_raise(JSON::ParserError, JSON::NestingError, "Did not fail for fixture '#{name}': #{source.inspect}") do JSON.parse(source) end diff --git a/tests/json_generator_test.rb b/tests/json_generator_test.rb index 7087471..18b0833 100644 --- a/tests/json_generator_test.rb +++ b/tests/json_generator_test.rb @@ -118,12 +118,12 @@ EOT assert s[:check_circular?] h = { 1=>2 } h[3] = h - assert_raises(JSON::NestingError) { generate(h) } - assert_raises(JSON::NestingError) { generate(h, s) } + assert_raise(JSON::NestingError) { generate(h) } + assert_raise(JSON::NestingError) { generate(h, s) } s = JSON.state.new a = [ 1, 2 ] a << a - assert_raises(JSON::NestingError) { generate(a, s) } + assert_raise(JSON::NestingError) { generate(a, s) } assert s.check_circular? assert s[:check_circular?] end @@ -177,34 +177,34 @@ EOT end def test_allow_nan - assert_raises(GeneratorError) { generate([JSON::NaN]) } + assert_raise(GeneratorError) { generate([JSON::NaN]) } assert_equal '[NaN]', generate([JSON::NaN], :allow_nan => true) - assert_raises(GeneratorError) { fast_generate([JSON::NaN]) } - assert_raises(GeneratorError) { pretty_generate([JSON::NaN]) } + assert_raise(GeneratorError) { fast_generate([JSON::NaN]) } + assert_raise(GeneratorError) { pretty_generate([JSON::NaN]) } assert_equal "[\n NaN\n]", pretty_generate([JSON::NaN], :allow_nan => true) - assert_raises(GeneratorError) { generate([JSON::Infinity]) } + assert_raise(GeneratorError) { generate([JSON::Infinity]) } assert_equal '[Infinity]', generate([JSON::Infinity], :allow_nan => true) - assert_raises(GeneratorError) { fast_generate([JSON::Infinity]) } - assert_raises(GeneratorError) { pretty_generate([JSON::Infinity]) } + assert_raise(GeneratorError) { fast_generate([JSON::Infinity]) } + assert_raise(GeneratorError) { pretty_generate([JSON::Infinity]) } assert_equal "[\n Infinity\n]", pretty_generate([JSON::Infinity], :allow_nan => true) - assert_raises(GeneratorError) { generate([JSON::MinusInfinity]) } + assert_raise(GeneratorError) { generate([JSON::MinusInfinity]) } assert_equal '[-Infinity]', generate([JSON::MinusInfinity], :allow_nan => true) - assert_raises(GeneratorError) { fast_generate([JSON::MinusInfinity]) } - assert_raises(GeneratorError) { pretty_generate([JSON::MinusInfinity]) } + assert_raise(GeneratorError) { fast_generate([JSON::MinusInfinity]) } + assert_raise(GeneratorError) { pretty_generate([JSON::MinusInfinity]) } assert_equal "[\n -Infinity\n]", pretty_generate([JSON::MinusInfinity], :allow_nan => true) end def test_depth ary = []; ary << ary assert_equal 0, JSON::SAFE_STATE_PROTOTYPE.depth - assert_raises(JSON::NestingError) { generate(ary) } + assert_raise(JSON::NestingError) { generate(ary) } assert_equal 0, JSON::SAFE_STATE_PROTOTYPE.depth assert_equal 0, JSON::PRETTY_STATE_PROTOTYPE.depth - assert_raises(JSON::NestingError) { JSON.pretty_generate(ary) } + assert_raise(JSON::NestingError) { JSON.pretty_generate(ary) } assert_equal 0, JSON::PRETTY_STATE_PROTOTYPE.depth s = JSON.state.new assert_equal 0, s.depth - assert_raises(JSON::NestingError) { ary.to_json(s) } + assert_raise(JSON::NestingError) { ary.to_json(s) } assert_equal 100, s.depth end @@ -330,8 +330,8 @@ EOT def test_nesting too_deep = '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]' too_deep_ary = eval too_deep - assert_raises(JSON::NestingError) { generate too_deep_ary } - assert_raises(JSON::NestingError) { generate too_deep_ary, :max_nesting => 100 } + assert_raise(JSON::NestingError) { generate too_deep_ary } + assert_raise(JSON::NestingError) { generate too_deep_ary, :max_nesting => 100 } ok = generate too_deep_ary, :max_nesting => 101 assert_equal too_deep, ok ok = generate too_deep_ary, :max_nesting => nil diff --git a/tests/json_parser_test.rb b/tests/json_parser_test.rb index a5793f9..d2b0fd1 100644 --- a/tests/json_parser_test.rb +++ b/tests/json_parser_test.rb @@ -52,7 +52,7 @@ class JSONParserTest < Test::Unit::TestCase assert_equal({ "a" => nil }, parse('{"a":null}')) assert_equal({ "a" => false }, parse('{ "a" : false } ')) assert_equal({ "a" => false }, parse('{"a":false}')) - assert_raises(JSON::ParserError) { parse('{false}') } + assert_raise(JSON::ParserError) { parse('{false}') } assert_equal({ "a" => true }, parse('{"a":true}')) assert_equal({ "a" => true }, parse(' { "a" : true } ')) assert_equal({ "a" => -23 }, parse(' { "a" : -23 } ')) @@ -64,10 +64,10 @@ class JSONParserTest < Test::Unit::TestCase end def test_parse_numbers - assert_raises(JSON::ParserError) { parse('+23.2') } - assert_raises(JSON::ParserError) { parse('+23') } - assert_raises(JSON::ParserError) { parse('.23') } - assert_raises(JSON::ParserError) { parse('023') } + assert_raise(JSON::ParserError) { parse('+23.2') } + assert_raise(JSON::ParserError) { parse('+23') } + assert_raise(JSON::ParserError) { parse('.23') } + assert_raise(JSON::ParserError) { parse('023') } assert_equal 23, parse('23') assert_equal -23, parse('-23') assert_equal_float 3.141, parse('3.141') @@ -78,11 +78,11 @@ class JSONParserTest < Test::Unit::TestCase assert_equal_float 3.141, parse('3141.0E-3') assert_equal_float -3.141, parse('-3141.0e-3') assert_equal_float -3.141, parse('-3141e-3') - assert_raises(ParserError) { parse('NaN') } + assert_raise(ParserError) { parse('NaN') } assert parse('NaN', :allow_nan => true).nan? - assert_raises(ParserError) { parse('Infinity') } + assert_raise(ParserError) { parse('Infinity') } assert_equal 1.0/0, parse('Infinity', :allow_nan => true) - assert_raises(ParserError) { parse('-Infinity') } + assert_raise(ParserError) { parse('-Infinity') } assert_equal -1.0/0, parse('-Infinity', :allow_nan => true) end @@ -165,19 +165,19 @@ class JSONParserTest < Test::Unit::TestCase end def test_some_wrong_inputs - assert_raises(ParserError) { parse('[] bla') } - assert_raises(ParserError) { parse('[] 1') } - assert_raises(ParserError) { parse('[] []') } - assert_raises(ParserError) { parse('[] {}') } - assert_raises(ParserError) { parse('{} []') } - assert_raises(ParserError) { parse('{} {}') } - assert_raises(ParserError) { parse('[NULL]') } - assert_raises(ParserError) { parse('[FALSE]') } - assert_raises(ParserError) { parse('[TRUE]') } - assert_raises(ParserError) { parse('[07] ') } - assert_raises(ParserError) { parse('[0a]') } - assert_raises(ParserError) { parse('[1.]') } - assert_raises(ParserError) { parse(' ') } + assert_raise(ParserError) { parse('[] bla') } + assert_raise(ParserError) { parse('[] 1') } + assert_raise(ParserError) { parse('[] []') } + assert_raise(ParserError) { parse('[] {}') } + assert_raise(ParserError) { parse('{} []') } + assert_raise(ParserError) { parse('{} {}') } + assert_raise(ParserError) { parse('[NULL]') } + assert_raise(ParserError) { parse('[FALSE]') } + assert_raise(ParserError) { parse('[TRUE]') } + assert_raise(ParserError) { parse('[07] ') } + assert_raise(ParserError) { parse('[0a]') } + assert_raise(ParserError) { parse('[1.]') } + assert_raise(ParserError) { parse(' ') } end def test_symbolize_names @@ -212,7 +212,7 @@ EOT * comment */ } EOT - assert_raises(ParserError) { parse(json) } + assert_raise(ParserError) { parse(json) } json = < 100 } + assert_raise(JSON::NestingError) { parse too_deep } + assert_raise(JSON::NestingError) { parse too_deep, :max_nesting => 100 } ok = parse too_deep, :max_nesting => 101 assert_equal too_deep_ary, ok ok = parse too_deep, :max_nesting => nil -- cgit v1.2.1 From 963e815cb1c3c9989192b2459da9a93518522807 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 24 Apr 2016 01:52:15 +0900 Subject: Use enum Use `enum` instead of `static const int` to get rid of unused-const-variable warnings. --- Rakefile | 1 + ext/json/ext/parser/parser.c | 65 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index 4aa311e..4448d2e 100644 --- a/Rakefile +++ b/Rakefile @@ -361,6 +361,7 @@ else sh "ragel -x parser.rl | #{RAGEL_CODEGEN} -G2" end src = File.read("parser.c").gsub(/[ \t]+$/, '') + src.gsub!(/^static const int (JSON_.*=.*);$/, 'enum {\1};') File.open("parser.c", "w") {|f| f.print src} end end diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index 7e32ef0..b1260b3 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -102,12 +102,19 @@ static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, +<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 106 "parser.c" static const int JSON_object_start = 1; static const int JSON_object_first_final = 27; static const int JSON_object_error = 0; +======= +#line 92 "parser.c" +enum {JSON_object_start = 1}; +enum {JSON_object_first_final = 27}; +enum {JSON_object_error = 0}; +>>>>>>> Use enum -static const int JSON_object_en_main = 1; +enum {JSON_object_en_main = 1}; #line 165 "parser.rl" @@ -480,12 +487,19 @@ case 26: +<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 484 "parser.c" static const int JSON_value_start = 1; static const int JSON_value_first_final = 29; static const int JSON_value_error = 0; +======= +#line 470 "parser.c" +enum {JSON_value_start = 1}; +enum {JSON_value_first_final = 29}; +enum {JSON_value_error = 0}; +>>>>>>> Use enum -static const int JSON_value_en_main = 1; +enum {JSON_value_en_main = 1}; #line 285 "parser.rl" @@ -878,12 +892,19 @@ case 28: } +<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 882 "parser.c" static const int JSON_integer_start = 1; static const int JSON_integer_first_final = 3; static const int JSON_integer_error = 0; +======= +#line 868 "parser.c" +enum {JSON_integer_start = 1}; +enum {JSON_integer_first_final = 3}; +enum {JSON_integer_error = 0}; +>>>>>>> Use enum -static const int JSON_integer_en_main = 1; +enum {JSON_integer_en_main = 1}; #line 309 "parser.rl" @@ -977,12 +998,19 @@ case 5: } +<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 981 "parser.c" static const int JSON_float_start = 1; static const int JSON_float_first_final = 8; static const int JSON_float_error = 0; +======= +#line 967 "parser.c" +enum {JSON_float_start = 1}; +enum {JSON_float_first_final = 8}; +enum {JSON_float_error = 0}; +>>>>>>> Use enum -static const int JSON_float_en_main = 1; +enum {JSON_float_en_main = 1}; #line 343 "parser.rl" @@ -1143,12 +1171,19 @@ case 7: +<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 1147 "parser.c" static const int JSON_array_start = 1; static const int JSON_array_first_final = 17; static const int JSON_array_error = 0; +======= +#line 1133 "parser.c" +enum {JSON_array_start = 1}; +enum {JSON_array_first_final = 17}; +enum {JSON_array_error = 0}; +>>>>>>> Use enum -static const int JSON_array_en_main = 1; +enum {JSON_array_en_main = 1}; #line 395 "parser.rl" @@ -1475,12 +1510,19 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd) } +<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 1479 "parser.c" static const int JSON_string_start = 1; static const int JSON_string_first_final = 8; static const int JSON_string_error = 0; +======= +#line 1465 "parser.c" +enum {JSON_string_start = 1}; +enum {JSON_string_first_final = 8}; +enum {JSON_string_error = 0}; +>>>>>>> Use enum -static const int JSON_string_en_main = 1; +enum {JSON_string_en_main = 1}; #line 508 "parser.rl" @@ -1811,12 +1853,19 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } +<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 1813 "parser.c" static const int JSON_start = 1; static const int JSON_first_final = 10; static const int JSON_error = 0; - -static const int JSON_en_main = 1; +======= +#line 1788 "parser.c" +enum {JSON_start = 1}; +enum {JSON_first_final = 10}; +enum {JSON_error = 0}; +>>>>>>> Use enum + +enum {JSON_en_main = 1}; #line 721 "parser.rl" -- cgit v1.2.1 From a20bc3c5fcd0e93b85803e685b527ac1ea14c1be Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 24 Apr 2016 01:37:39 +0900 Subject: Remove unnecessary conversion StringValue does the conversion. --- ext/json/ext/parser/parser.c | 33 ++++++++++++++++++++++++++++++++- ext/json/ext/parser/parser.rl | 1 - 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index b1260b3..afa2864 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -1842,7 +1842,6 @@ 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"); source = convert_encoding(StringValue(source)); json->current_nesting = 0; StringValue(source); @@ -1853,6 +1852,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } +<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b <<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 1813 "parser.c" static const int JSON_start = 1; @@ -1860,6 +1860,9 @@ static const int JSON_first_final = 10; static const int JSON_error = 0; ======= #line 1788 "parser.c" +======= +#line 1787 "parser.c" +>>>>>>> Remove unnecessary conversion enum {JSON_start = 1}; enum {JSON_first_final = 10}; enum {JSON_error = 0}; @@ -1868,7 +1871,11 @@ enum {JSON_error = 0}; enum {JSON_en_main = 1}; +<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b #line 721 "parser.rl" +======= +#line 695 "parser.rl" +>>>>>>> Remove unnecessary conversion /* @@ -1885,16 +1892,28 @@ static VALUE cParser_parse(VALUE self) GET_PARSER; +<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b #line 1838 "parser.c" +======= +#line 1812 "parser.c" +>>>>>>> Remove unnecessary conversion { cs = JSON_start; } +<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b #line 737 "parser.rl" p = json->source; pe = p + json->len; #line 1847 "parser.c" +======= +#line 711 "parser.rl" + p = json->source; + pe = p + json->len; + +#line 1821 "parser.c" +>>>>>>> Remove unnecessary conversion { if ( p == pe ) goto _test_eof; @@ -1928,7 +1947,11 @@ st0: cs = 0; goto _out; tr2: +<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b #line 713 "parser.rl" +======= +#line 687 "parser.rl" +>>>>>>> Remove unnecessary conversion { char *np = JSON_parse_value(json, p, pe, &result); if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;} @@ -1938,7 +1961,11 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: +<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b #line 1891 "parser.c" +======= +#line 1865 "parser.c" +>>>>>>> Remove unnecessary conversion switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -2027,7 +2054,11 @@ case 9: _out: {} } +<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b #line 740 "parser.rl" +======= +#line 714 "parser.rl" +>>>>>>> Remove unnecessary conversion if (cs >= JSON_first_final && p == pe) { return result; diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl index f479281..0c65a09 100644 --- a/ext/json/ext/parser/parser.rl +++ b/ext/json/ext/parser/parser.rl @@ -695,7 +695,6 @@ 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"); source = convert_encoding(StringValue(source)); json->current_nesting = 0; StringValue(source); -- cgit v1.2.1 From 0a49b1f7d5bccfa324cdc74ba6f899f3925a7830 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 24 Apr 2016 01:47:49 +0900 Subject: Use rb_encoding Use rb_encoding functions to convert encodings. --- ext/json/ext/parser/mkmf.log | 60 +++++++++++++++++++++++++++ ext/json/ext/parser/parser.c | 97 ++++---------------------------------------- 2 files changed, 68 insertions(+), 89 deletions(-) create mode 100644 ext/json/ext/parser/mkmf.log diff --git a/ext/json/ext/parser/mkmf.log b/ext/json/ext/parser/mkmf.log new file mode 100644 index 0000000..e725db5 --- /dev/null +++ b/ext/json/ext/parser/mkmf.log @@ -0,0 +1,60 @@ +have_func: checking for rb_enc_raise() in ruby.h... -------------------- yes + +"gcc -o conftest -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin15 -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/flori/.rvm/rubies/ruby-2.3.1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.3.0 -lpthread -ldl -lobjc " +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main(int argc, char **argv) +4: { +5: return 0; +6: } +/* end */ + +"gcc -o conftest -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin15 -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/flori/.rvm/rubies/ruby-2.3.1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.3.0 -lpthread -ldl -lobjc " +conftest.c:15:57: error: use of undeclared identifier 'rb_enc_raise' +int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_enc_raise; return !p; } + ^ +1 error generated. +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: printf("%p", &t); +11: } +12: +13: return 0; +14: } +15: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_enc_raise; return !p; } +/* end */ + +"gcc -o conftest -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin15 -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/flori/.rvm/rubies/ruby-2.3.1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.3.0 -lpthread -ldl -lobjc " +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: printf("%p", &t); +11: } +12: +13: return 0; +14: } +15: extern void rb_enc_raise(); +16: int t(void) { rb_enc_raise(); return 0; } +/* end */ + +-------------------- + diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index afa2864..269c9ca 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -102,17 +102,10 @@ static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 106 "parser.c" -static const int JSON_object_start = 1; -static const int JSON_object_first_final = 27; -static const int JSON_object_error = 0; -======= -#line 92 "parser.c" enum {JSON_object_start = 1}; enum {JSON_object_first_final = 27}; enum {JSON_object_error = 0}; ->>>>>>> Use enum enum {JSON_object_en_main = 1}; @@ -487,17 +480,10 @@ case 26: -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 484 "parser.c" -static const int JSON_value_start = 1; -static const int JSON_value_first_final = 29; -static const int JSON_value_error = 0; -======= -#line 470 "parser.c" enum {JSON_value_start = 1}; enum {JSON_value_first_final = 29}; enum {JSON_value_error = 0}; ->>>>>>> Use enum enum {JSON_value_en_main = 1}; @@ -892,17 +878,10 @@ case 28: } -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 882 "parser.c" -static const int JSON_integer_start = 1; -static const int JSON_integer_first_final = 3; -static const int JSON_integer_error = 0; -======= -#line 868 "parser.c" enum {JSON_integer_start = 1}; enum {JSON_integer_first_final = 3}; enum {JSON_integer_error = 0}; ->>>>>>> Use enum enum {JSON_integer_en_main = 1}; @@ -998,17 +977,10 @@ case 5: } -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 981 "parser.c" -static const int JSON_float_start = 1; -static const int JSON_float_first_final = 8; -static const int JSON_float_error = 0; -======= -#line 967 "parser.c" enum {JSON_float_start = 1}; enum {JSON_float_first_final = 8}; enum {JSON_float_error = 0}; ->>>>>>> Use enum enum {JSON_float_en_main = 1}; @@ -1171,17 +1143,10 @@ case 7: -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 1147 "parser.c" -static const int JSON_array_start = 1; -static const int JSON_array_first_final = 17; -static const int JSON_array_error = 0; -======= -#line 1133 "parser.c" enum {JSON_array_start = 1}; enum {JSON_array_first_final = 17}; enum {JSON_array_error = 0}; ->>>>>>> Use enum enum {JSON_array_en_main = 1}; @@ -1510,17 +1475,10 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd) } -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 #line 1479 "parser.c" -static const int JSON_string_start = 1; -static const int JSON_string_first_final = 8; -static const int JSON_string_error = 0; -======= -#line 1465 "parser.c" enum {JSON_string_start = 1}; enum {JSON_string_first_final = 8}; enum {JSON_string_error = 0}; ->>>>>>> Use enum enum {JSON_string_en_main = 1}; @@ -1852,30 +1810,15 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -<<<<<<< dad1dad53ad48946bf2a8de60b8fb419e1180bf0 -#line 1813 "parser.c" -static const int JSON_start = 1; -static const int JSON_first_final = 10; -static const int JSON_error = 0; -======= -#line 1788 "parser.c" -======= -#line 1787 "parser.c" ->>>>>>> Remove unnecessary conversion +#line 1814 "parser.c" enum {JSON_start = 1}; enum {JSON_first_final = 10}; enum {JSON_error = 0}; ->>>>>>> Use enum enum {JSON_en_main = 1}; -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -#line 721 "parser.rl" -======= -#line 695 "parser.rl" ->>>>>>> Remove unnecessary conversion +#line 722 "parser.rl" /* @@ -1892,28 +1835,16 @@ static VALUE cParser_parse(VALUE self) GET_PARSER; -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -#line 1838 "parser.c" -======= -#line 1812 "parser.c" ->>>>>>> Remove unnecessary conversion +#line 1839 "parser.c" { cs = JSON_start; } -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -#line 737 "parser.rl" +#line 738 "parser.rl" p = json->source; pe = p + json->len; -#line 1847 "parser.c" -======= -#line 711 "parser.rl" - p = json->source; - pe = p + json->len; - -#line 1821 "parser.c" ->>>>>>> Remove unnecessary conversion +#line 1848 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1947,11 +1878,7 @@ st0: cs = 0; goto _out; tr2: -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -#line 713 "parser.rl" -======= -#line 687 "parser.rl" ->>>>>>> Remove unnecessary conversion +#line 714 "parser.rl" { char *np = JSON_parse_value(json, p, pe, &result); if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;} @@ -1961,11 +1888,7 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -#line 1891 "parser.c" -======= -#line 1865 "parser.c" ->>>>>>> Remove unnecessary conversion +#line 1892 "parser.c" switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -2054,11 +1977,7 @@ case 9: _out: {} } -<<<<<<< 949543418c0888d7deba00a93e08b7f56637ce9b -#line 740 "parser.rl" -======= -#line 714 "parser.rl" ->>>>>>> Remove unnecessary conversion +#line 741 "parser.rl" if (cs >= JSON_first_final && p == pe) { return result; -- cgit v1.2.1 From 2d475160b490389060d66980465bb7220b2363e7 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 24 Apr 2016 02:04:34 +0900 Subject: Exception encoding Raise with messages in UTF-8 encoding. --- ext/json/ext/parser/parser.c | 34 +++++++++++++++++++++++++++++++++- ext/json/ext/parser/parser.rl | 2 +- tests/json_parser_test.rb | 10 ++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index 269c9ca..a99b73b 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -1810,7 +1810,11 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } +<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 1814 "parser.c" +======= +#line 1801 "parser.c" +>>>>>>> Exception encoding enum {JSON_start = 1}; enum {JSON_first_final = 10}; enum {JSON_error = 0}; @@ -1818,7 +1822,11 @@ enum {JSON_error = 0}; enum {JSON_en_main = 1}; +<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 722 "parser.rl" +======= +#line 709 "parser.rl" +>>>>>>> Exception encoding /* @@ -1835,16 +1843,28 @@ static VALUE cParser_parse(VALUE self) GET_PARSER; +<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 1839 "parser.c" +======= +#line 1826 "parser.c" +>>>>>>> Exception encoding { cs = JSON_start; } +<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 738 "parser.rl" p = json->source; pe = p + json->len; #line 1848 "parser.c" +======= +#line 725 "parser.rl" + p = json->source; + pe = p + json->len; + +#line 1835 "parser.c" +>>>>>>> Exception encoding { if ( p == pe ) goto _test_eof; @@ -1878,7 +1898,11 @@ st0: cs = 0; goto _out; tr2: +<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 714 "parser.rl" +======= +#line 701 "parser.rl" +>>>>>>> Exception encoding { char *np = JSON_parse_value(json, p, pe, &result); if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;} @@ -1888,7 +1912,11 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: +<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 1892 "parser.c" +======= +#line 1879 "parser.c" +>>>>>>> Exception encoding switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -1977,12 +2005,16 @@ case 9: _out: {} } +<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 741 "parser.rl" +======= +#line 728 "parser.rl" +>>>>>>> Exception encoding 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; } } diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl index 0c65a09..eac3e6c 100644 --- a/ext/json/ext/parser/parser.rl +++ b/ext/json/ext/parser/parser.rl @@ -742,7 +742,7 @@ static VALUE cParser_parse(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; } } diff --git a/tests/json_parser_test.rb b/tests/json_parser_test.rb index d2b0fd1..1d1987b 100644 --- a/tests/json_parser_test.rb +++ b/tests/json_parser_test.rb @@ -19,6 +19,16 @@ class JSONParserTest < Test::Unit::TestCase assert_equal Encoding::UTF_16, source.encoding end if defined?(Encoding::UTF_16) + def test_error_message_encoding + bug10705 = '[ruby-core:67386] [Bug #10705]' + json = ".\"\xE2\x88\x9A\"".force_encoding(Encoding::UTF_8) + e = assert_raise(JSON::ParserError) { + JSON::Ext::Parser.new(json).parse + } + assert_equal(Encoding::UTF_8, e.message.encoding, bug10705) + assert_include(e.message, json, bug10705) + end if defined?(Encoding::UTF_8) and defined?(JSON::Ext::Parser) + def test_parsing parser = JSON::Parser.new('"test"') assert_equal 'test', parser.parse -- cgit v1.2.1 From 236d43ed1aaa2eeae346d2f6b2304c32b62b8823 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 24 Apr 2016 02:08:30 +0900 Subject: Optional hash in rb_scan_args Use ':' in rb_scan_args to get optional hash, which available since ruby 2.1. --- ext/json/ext/parser/parser.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index a99b73b..f3e2502 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -1810,11 +1810,15 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } +<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c <<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 1814 "parser.c" ======= #line 1801 "parser.c" >>>>>>> Exception encoding +======= +#line 1809 "parser.c" +>>>>>>> Optional hash in rb_scan_args enum {JSON_start = 1}; enum {JSON_first_final = 10}; enum {JSON_error = 0}; @@ -1822,11 +1826,15 @@ enum {JSON_error = 0}; enum {JSON_en_main = 1}; +<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c <<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 722 "parser.rl" ======= #line 709 "parser.rl" >>>>>>> Exception encoding +======= +#line 717 "parser.rl" +>>>>>>> Optional hash in rb_scan_args /* @@ -1843,15 +1851,20 @@ static VALUE cParser_parse(VALUE self) GET_PARSER; +<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c <<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 1839 "parser.c" ======= #line 1826 "parser.c" >>>>>>> Exception encoding +======= +#line 1834 "parser.c" +>>>>>>> Optional hash in rb_scan_args { cs = JSON_start; } +<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c <<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 738 "parser.rl" p = json->source; @@ -1865,6 +1878,13 @@ static VALUE cParser_parse(VALUE self) #line 1835 "parser.c" >>>>>>> Exception encoding +======= +#line 733 "parser.rl" + p = json->source; + pe = p + json->len; + +#line 1843 "parser.c" +>>>>>>> Optional hash in rb_scan_args { if ( p == pe ) goto _test_eof; @@ -1898,11 +1918,15 @@ st0: cs = 0; goto _out; tr2: +<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c <<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 714 "parser.rl" ======= #line 701 "parser.rl" >>>>>>> Exception encoding +======= +#line 709 "parser.rl" +>>>>>>> Optional hash in rb_scan_args { char *np = JSON_parse_value(json, p, pe, &result); if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;} @@ -1912,11 +1936,15 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: +<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c <<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 1892 "parser.c" ======= #line 1879 "parser.c" >>>>>>> Exception encoding +======= +#line 1887 "parser.c" +>>>>>>> Optional hash in rb_scan_args switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -2005,11 +2033,15 @@ case 9: _out: {} } +<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c <<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 741 "parser.rl" ======= #line 728 "parser.rl" >>>>>>> Exception encoding +======= +#line 736 "parser.rl" +>>>>>>> Optional hash in rb_scan_args if (cs >= JSON_first_final && p == pe) { return result; -- cgit v1.2.1 From 1e5684ff2cbde8be819eac1e50e0edbfd120d77b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 24 Apr 2016 02:31:53 +0900 Subject: Add frozen_string_literal: false When you change this to true, you may need to add more tests. --- lib/json.rb | 1 + lib/json/add/bigdecimal.rb | 1 + lib/json/add/complex.rb | 1 + lib/json/add/core.rb | 1 + lib/json/add/date.rb | 1 + lib/json/add/date_time.rb | 1 + lib/json/add/exception.rb | 1 + lib/json/add/ostruct.rb | 1 + lib/json/add/range.rb | 1 + lib/json/add/rational.rb | 1 + lib/json/add/regexp.rb | 1 + lib/json/add/struct.rb | 1 + lib/json/add/symbol.rb | 1 + lib/json/add/time.rb | 1 + lib/json/common.rb | 1 + lib/json/generic_object.rb | 1 + lib/json/pure/generator.rb | 1 + lib/json/pure/parser.rb | 1 + lib/json/version.rb | 1 + tests/json_addition_test.rb | 1 + tests/json_common_interface_test.rb | 1 + tests/json_encoding_test.rb | 1 + tests/json_ext_parser_test.rb | 1 + tests/json_fixtures_test.rb | 1 + tests/json_generic_object_test.rb | 1 + tests/json_parser_test.rb | 1 + tests/json_string_matching_test.rb | 1 + 27 files changed, 27 insertions(+) diff --git a/lib/json.rb b/lib/json.rb index 24aa385..b5a6912 100644 --- a/lib/json.rb +++ b/lib/json.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false require 'json/common' ## diff --git a/lib/json/add/bigdecimal.rb b/lib/json/add/bigdecimal.rb index 0ef69f1..539daee 100644 --- a/lib/json/add/bigdecimal.rb +++ b/lib/json/add/bigdecimal.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end diff --git a/lib/json/add/complex.rb b/lib/json/add/complex.rb index 3d653bb..28ef734 100644 --- a/lib/json/add/complex.rb +++ b/lib/json/add/complex.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end diff --git a/lib/json/add/core.rb b/lib/json/add/core.rb index 77d9dc0..bfb017c 100644 --- a/lib/json/add/core.rb +++ b/lib/json/add/core.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false # This file requires the implementations of ruby core's custom objects for # serialisation/deserialisation. diff --git a/lib/json/add/date.rb b/lib/json/add/date.rb index 458d9eb..2552356 100644 --- a/lib/json/add/date.rb +++ b/lib/json/add/date.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end diff --git a/lib/json/add/date_time.rb b/lib/json/add/date_time.rb index a1009cf..38b0e86 100644 --- a/lib/json/add/date_time.rb +++ b/lib/json/add/date_time.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end diff --git a/lib/json/add/exception.rb b/lib/json/add/exception.rb index f4b150d..a107e5b 100644 --- a/lib/json/add/exception.rb +++ b/lib/json/add/exception.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end diff --git a/lib/json/add/ostruct.rb b/lib/json/add/ostruct.rb index a62f92f..7c13910 100644 --- a/lib/json/add/ostruct.rb +++ b/lib/json/add/ostruct.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end diff --git a/lib/json/add/range.rb b/lib/json/add/range.rb index 0df382c..93529fb 100644 --- a/lib/json/add/range.rb +++ b/lib/json/add/range.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end diff --git a/lib/json/add/rational.rb b/lib/json/add/rational.rb index ee39c20..356940b 100644 --- a/lib/json/add/rational.rb +++ b/lib/json/add/rational.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end diff --git a/lib/json/add/regexp.rb b/lib/json/add/regexp.rb index 9adf06c..a93866b 100644 --- a/lib/json/add/regexp.rb +++ b/lib/json/add/regexp.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end diff --git a/lib/json/add/struct.rb b/lib/json/add/struct.rb index e1e2480..e8395ed 100644 --- a/lib/json/add/struct.rb +++ b/lib/json/add/struct.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end diff --git a/lib/json/add/symbol.rb b/lib/json/add/symbol.rb index 6df77ca..74b13a4 100644 --- a/lib/json/add/symbol.rb +++ b/lib/json/add/symbol.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end diff --git a/lib/json/add/time.rb b/lib/json/add/time.rb index 1227508..b73acc4 100644 --- a/lib/json/add/time.rb +++ b/lib/json/add/time.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED require 'json' end diff --git a/lib/json/common.rb b/lib/json/common.rb index 55908f8..b53041b 100644 --- a/lib/json/common.rb +++ b/lib/json/common.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false require 'json/version' require 'json/generic_object' diff --git a/lib/json/generic_object.rb b/lib/json/generic_object.rb index 3a14f0e..6c8f039 100644 --- a/lib/json/generic_object.rb +++ b/lib/json/generic_object.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false require 'ostruct' module JSON diff --git a/lib/json/pure/generator.rb b/lib/json/pure/generator.rb index 98bc369..ccb6fe4 100644 --- a/lib/json/pure/generator.rb +++ b/lib/json/pure/generator.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false module JSON MAP = { "\x0" => '\u0000', diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb index f02f408..b907236 100644 --- a/lib/json/pure/parser.rb +++ b/lib/json/pure/parser.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false require 'strscan' module JSON diff --git a/lib/json/version.rb b/lib/json/version.rb index b91ccd7..b4d1b3b 100644 --- a/lib/json/version.rb +++ b/lib/json/version.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false module JSON # JSON version VERSION = '2.0.0' diff --git a/tests/json_addition_test.rb b/tests/json_addition_test.rb index cb07659..a028e0f 100644 --- a/tests/json_addition_test.rb +++ b/tests/json_addition_test.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false require 'test_helper' require 'json/add/core' require 'json/add/complex' diff --git a/tests/json_common_interface_test.rb b/tests/json_common_interface_test.rb index 30c54c8..b2051d4 100644 --- a/tests/json_common_interface_test.rb +++ b/tests/json_common_interface_test.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false require 'test_helper' require 'stringio' require 'tempfile' diff --git a/tests/json_encoding_test.rb b/tests/json_encoding_test.rb index d983e12..29ae02e 100644 --- a/tests/json_encoding_test.rb +++ b/tests/json_encoding_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +#frozen_string_literal: false require 'test_helper' class JSONEncodingTest < Test::Unit::TestCase diff --git a/tests/json_ext_parser_test.rb b/tests/json_ext_parser_test.rb index ade9784..c5a030e 100644 --- a/tests/json_ext_parser_test.rb +++ b/tests/json_ext_parser_test.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false require 'test_helper' class JSONExtParserTest < Test::Unit::TestCase diff --git a/tests/json_fixtures_test.rb b/tests/json_fixtures_test.rb index 0419983..01954fe 100644 --- a/tests/json_fixtures_test.rb +++ b/tests/json_fixtures_test.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false require 'test_helper' class JSONFixturesTest < Test::Unit::TestCase diff --git a/tests/json_generic_object_test.rb b/tests/json_generic_object_test.rb index 171fdb8..82742dc 100644 --- a/tests/json_generic_object_test.rb +++ b/tests/json_generic_object_test.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false require 'test_helper' class JSONGenericObjectTest < Test::Unit::TestCase diff --git a/tests/json_parser_test.rb b/tests/json_parser_test.rb index 1d1987b..5120f09 100644 --- a/tests/json_parser_test.rb +++ b/tests/json_parser_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: false require 'test_helper' require 'stringio' diff --git a/tests/json_string_matching_test.rb b/tests/json_string_matching_test.rb index 7fec841..5d55dc3 100644 --- a/tests/json_string_matching_test.rb +++ b/tests/json_string_matching_test.rb @@ -1,3 +1,4 @@ +#frozen_string_literal: false require 'test_helper' require 'time' -- cgit v1.2.1 From 29c918ad9e16f3b67780a141353df05c029eb1eb Mon Sep 17 00:00:00 2001 From: Florian Frank Date: Thu, 9 Jun 2016 17:42:22 +0200 Subject: Support 1.9 ruby's OpenStruct --- lib/json/generic_object.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/json/generic_object.rb b/lib/json/generic_object.rb index 6c8f039..108309d 100644 --- a/lib/json/generic_object.rb +++ b/lib/json/generic_object.rb @@ -48,6 +48,14 @@ module JSON table end + def [](name) + __send__(name) + end unless method_defined?(:[]) + + def []=(name, value) + __send__("#{name}=", value) + end unless method_defined?(:[]=) + def |(other) self.class[other.to_hash.merge(to_hash)] end -- cgit v1.2.1 From e96a29e9bb261410a53b63acf26a9ec780b5199c Mon Sep 17 00:00:00 2001 From: Florian Frank Date: Tue, 21 Jun 2016 10:52:31 +0200 Subject: Fix some merge problems --- ext/json/ext/parser/mkmf.log | 60 ---------------------------------------- ext/json/ext/parser/parser.c | 64 ------------------------------------------- json.gemspec | Bin 5410 -> 4479 bytes json_pure.gemspec | 40 +++++++++++++-------------- lib/json/version.rb | 1 - 5 files changed, 20 insertions(+), 145 deletions(-) delete mode 100644 ext/json/ext/parser/mkmf.log diff --git a/ext/json/ext/parser/mkmf.log b/ext/json/ext/parser/mkmf.log deleted file mode 100644 index e725db5..0000000 --- a/ext/json/ext/parser/mkmf.log +++ /dev/null @@ -1,60 +0,0 @@ -have_func: checking for rb_enc_raise() in ruby.h... -------------------- yes - -"gcc -o conftest -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin15 -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/flori/.rvm/rubies/ruby-2.3.1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.3.0 -lpthread -ldl -lobjc " -checked program was: -/* begin */ -1: #include "ruby.h" -2: -3: int main(int argc, char **argv) -4: { -5: return 0; -6: } -/* end */ - -"gcc -o conftest -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin15 -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/flori/.rvm/rubies/ruby-2.3.1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.3.0 -lpthread -ldl -lobjc " -conftest.c:15:57: error: use of undeclared identifier 'rb_enc_raise' -int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_enc_raise; return !p; } - ^ -1 error generated. -checked program was: -/* begin */ - 1: #include "ruby.h" - 2: - 3: #include - 4: - 5: /*top*/ - 6: extern int t(void); - 7: int main(int argc, char **argv) - 8: { - 9: if (argc > 1000000) { -10: printf("%p", &t); -11: } -12: -13: return 0; -14: } -15: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_enc_raise; return !p; } -/* end */ - -"gcc -o conftest -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin15 -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I/Users/flori/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/flori/.rvm/rubies/ruby-2.3.1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.2.3.0 -lpthread -ldl -lobjc " -checked program was: -/* begin */ - 1: #include "ruby.h" - 2: - 3: #include - 4: - 5: /*top*/ - 6: extern int t(void); - 7: int main(int argc, char **argv) - 8: { - 9: if (argc > 1000000) { -10: printf("%p", &t); -11: } -12: -13: return 0; -14: } -15: extern void rb_enc_raise(); -16: int t(void) { rb_enc_raise(); return 0; } -/* end */ - --------------------- - diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index f3e2502..a65d17d 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -1810,15 +1810,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } -<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c -<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 1814 "parser.c" -======= -#line 1801 "parser.c" ->>>>>>> Exception encoding -======= -#line 1809 "parser.c" ->>>>>>> Optional hash in rb_scan_args enum {JSON_start = 1}; enum {JSON_first_final = 10}; enum {JSON_error = 0}; @@ -1826,15 +1818,7 @@ enum {JSON_error = 0}; enum {JSON_en_main = 1}; -<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c -<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 722 "parser.rl" -======= -#line 709 "parser.rl" ->>>>>>> Exception encoding -======= -#line 717 "parser.rl" ->>>>>>> Optional hash in rb_scan_args /* @@ -1851,40 +1835,16 @@ static VALUE cParser_parse(VALUE self) GET_PARSER; -<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c -<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 1839 "parser.c" -======= -#line 1826 "parser.c" ->>>>>>> Exception encoding -======= -#line 1834 "parser.c" ->>>>>>> Optional hash in rb_scan_args { cs = JSON_start; } -<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c -<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 738 "parser.rl" p = json->source; pe = p + json->len; #line 1848 "parser.c" -======= -#line 725 "parser.rl" - p = json->source; - pe = p + json->len; - -#line 1835 "parser.c" ->>>>>>> Exception encoding -======= -#line 733 "parser.rl" - p = json->source; - pe = p + json->len; - -#line 1843 "parser.c" ->>>>>>> Optional hash in rb_scan_args { if ( p == pe ) goto _test_eof; @@ -1918,15 +1878,7 @@ st0: cs = 0; goto _out; tr2: -<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c -<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 714 "parser.rl" -======= -#line 701 "parser.rl" ->>>>>>> Exception encoding -======= -#line 709 "parser.rl" ->>>>>>> Optional hash in rb_scan_args { char *np = JSON_parse_value(json, p, pe, &result); if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;} @@ -1936,15 +1888,7 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: -<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c -<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 1892 "parser.c" -======= -#line 1879 "parser.c" ->>>>>>> Exception encoding -======= -#line 1887 "parser.c" ->>>>>>> Optional hash in rb_scan_args switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -2033,15 +1977,7 @@ case 9: _out: {} } -<<<<<<< 066bc5c70082f719951f398f4e20894571f8986c -<<<<<<< 2e06c964fceb550203659db23971459bc9d35054 #line 741 "parser.rl" -======= -#line 728 "parser.rl" ->>>>>>> Exception encoding -======= -#line 736 "parser.rl" ->>>>>>> Optional hash in rb_scan_args if (cs >= JSON_first_final && p == pe) { return result; diff --git a/json.gemspec b/json.gemspec index 71982d9..54bae4d 100644 Binary files a/json.gemspec and b/json.gemspec differ diff --git a/json_pure.gemspec b/json_pure.gemspec index 3b3726b..a8132d4 100644 --- a/json_pure.gemspec +++ b/json_pure.gemspec @@ -2,36 +2,36 @@ # stub: json_pure 2.0.0 ruby lib Gem::Specification.new do |s| - s.name = "json_pure".freeze + s.name = "json_pure" s.version = "2.0.0" - s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= - s.require_paths = ["lib".freeze] - s.authors = ["Florian Frank".freeze] + 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-06-21" - s.description = "This is a JSON implementation in pure Ruby.".freeze - s.email = "flori@ping.de".freeze - s.extra_rdoc_files = ["README.md".freeze] - s.files = ["./tests/test_helper.rb".freeze, ".gitignore".freeze, ".travis.yml".freeze, "CHANGES".freeze, "Gemfile".freeze, "README-json-jruby.markdown".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "data/example.json".freeze, "data/index.html".freeze, "data/prototype.js".freeze, "diagrams/.keep".freeze, "ext/json/ext/fbuffer/fbuffer.h".freeze, "ext/json/ext/generator/depend".freeze, "ext/json/ext/generator/extconf.rb".freeze, "ext/json/ext/generator/generator.c".freeze, "ext/json/ext/generator/generator.h".freeze, "ext/json/ext/parser/depend".freeze, "ext/json/ext/parser/extconf.rb".freeze, "ext/json/ext/parser/parser.c".freeze, "ext/json/ext/parser/parser.h".freeze, "ext/json/ext/parser/parser.rl".freeze, "ext/json/extconf.rb".freeze, "install.rb".freeze, "java/src/json/ext/ByteListTranscoder.java".freeze, "java/src/json/ext/Generator.java".freeze, "java/src/json/ext/GeneratorMethods.java".freeze, "java/src/json/ext/GeneratorService.java".freeze, "java/src/json/ext/GeneratorState.java".freeze, "java/src/json/ext/OptionsReader.java".freeze, "java/src/json/ext/Parser.java".freeze, "java/src/json/ext/Parser.rl".freeze, "java/src/json/ext/ParserService.java".freeze, "java/src/json/ext/RuntimeInfo.java".freeze, "java/src/json/ext/StringDecoder.java".freeze, "java/src/json/ext/StringEncoder.java".freeze, "java/src/json/ext/Utils.java".freeze, "json-java.gemspec".freeze, "json.gemspec".freeze, "json_pure.gemspec".freeze, "lib/json.rb".freeze, "lib/json/add/bigdecimal.rb".freeze, "lib/json/add/complex.rb".freeze, "lib/json/add/core.rb".freeze, "lib/json/add/date.rb".freeze, "lib/json/add/date_time.rb".freeze, "lib/json/add/exception.rb".freeze, "lib/json/add/ostruct.rb".freeze, "lib/json/add/range.rb".freeze, "lib/json/add/rational.rb".freeze, "lib/json/add/regexp.rb".freeze, "lib/json/add/struct.rb".freeze, "lib/json/add/symbol.rb".freeze, "lib/json/add/time.rb".freeze, "lib/json/common.rb".freeze, "lib/json/ext.rb".freeze, "lib/json/ext/.keep".freeze, "lib/json/generic_object.rb".freeze, "lib/json/pure.rb".freeze, "lib/json/pure/generator.rb".freeze, "lib/json/pure/parser.rb".freeze, "lib/json/version.rb".freeze, "references/rfc7159.txt".freeze, "tests/fixtures/fail10.json".freeze, "tests/fixtures/fail11.json".freeze, "tests/fixtures/fail12.json".freeze, "tests/fixtures/fail13.json".freeze, "tests/fixtures/fail14.json".freeze, "tests/fixtures/fail18.json".freeze, "tests/fixtures/fail19.json".freeze, "tests/fixtures/fail2.json".freeze, "tests/fixtures/fail20.json".freeze, "tests/fixtures/fail21.json".freeze, "tests/fixtures/fail22.json".freeze, "tests/fixtures/fail23.json".freeze, "tests/fixtures/fail24.json".freeze, "tests/fixtures/fail25.json".freeze, "tests/fixtures/fail27.json".freeze, "tests/fixtures/fail28.json".freeze, "tests/fixtures/fail3.json".freeze, "tests/fixtures/fail4.json".freeze, "tests/fixtures/fail5.json".freeze, "tests/fixtures/fail6.json".freeze, "tests/fixtures/fail7.json".freeze, "tests/fixtures/fail8.json".freeze, "tests/fixtures/fail9.json".freeze, "tests/fixtures/obsolete_fail1.json".freeze, "tests/fixtures/pass1.json".freeze, "tests/fixtures/pass15.json".freeze, "tests/fixtures/pass16.json".freeze, "tests/fixtures/pass17.json".freeze, "tests/fixtures/pass2.json".freeze, "tests/fixtures/pass26.json".freeze, "tests/fixtures/pass3.json".freeze, "tests/json_addition_test.rb".freeze, "tests/json_common_interface_test.rb".freeze, "tests/json_encoding_test.rb".freeze, "tests/json_ext_parser_test.rb".freeze, "tests/json_fixtures_test.rb".freeze, "tests/json_generator_test.rb".freeze, "tests/json_generic_object_test.rb".freeze, "tests/json_parser_test.rb".freeze, "tests/json_string_matching_test.rb".freeze, "tests/test_helper.rb".freeze, "tools/diff.sh".freeze, "tools/fuzz.rb".freeze, "tools/server.rb".freeze] - s.homepage = "http://flori.github.com/json".freeze - s.licenses = ["Ruby".freeze] - s.rdoc_options = ["--title".freeze, "JSON implemention for ruby".freeze, "--main".freeze, "README.md".freeze] - s.rubygems_version = "2.6.4".freeze - s.summary = "JSON Implementation for Ruby".freeze - s.test_files = ["./tests/test_helper.rb".freeze] + 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_helper.rb", ".gitignore", ".travis.yml", "CHANGES", "Gemfile", "README-json-jruby.markdown", "README.md", "Rakefile", "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", "references/rfc7159.txt", "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/obsolete_fail1.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/json_addition_test.rb", "tests/json_common_interface_test.rb", "tests/json_encoding_test.rb", "tests/json_ext_parser_test.rb", "tests/json_fixtures_test.rb", "tests/json_generator_test.rb", "tests/json_generic_object_test.rb", "tests/json_parser_test.rb", "tests/json_string_matching_test.rb", "tests/test_helper.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.1" + s.summary = "JSON Implementation for Ruby" + s.test_files = ["./tests/test_helper.rb"] if s.respond_to? :specification_version then s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_development_dependency(%q.freeze, [">= 0"]) - s.add_development_dependency(%q.freeze, ["~> 2.0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, ["~> 2.0"]) else - s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, ["~> 2.0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 2.0"]) end else - s.add_dependency(%q.freeze, [">= 0"]) - s.add_dependency(%q.freeze, ["~> 2.0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 2.0"]) end end diff --git a/lib/json/version.rb b/lib/json/version.rb index b4d1b3b..b91ccd7 100644 --- a/lib/json/version.rb +++ b/lib/json/version.rb @@ -1,4 +1,3 @@ -#frozen_string_literal: false module JSON # JSON version VERSION = '2.0.0' -- cgit v1.2.1