diff options
author | Hans de Graaff <graaff@gentoo.org> | 2018-12-26 07:43:19 +0100 |
---|---|---|
committer | Hans de Graaff <graaff@gentoo.org> | 2018-12-26 08:11:34 +0100 |
commit | 02f081a1a6cf0384887ced3cb40c50dcb07ae57c (patch) | |
tree | b16b2dfc0cad0a9c4ec5e7b171a91b2e8ad19e35 | |
parent | 9dbc9609d75a633a2dc99eda42f7876eda8dd0fe (diff) | |
download | gentoo-02f081a1a6cf0384887ced3cb40c50dcb07ae57c.tar.gz gentoo-02f081a1a6cf0384887ced3cb40c50dcb07ae57c.tar.xz |
dev-ruby/json: add ruby26
Add patches from ruby for compatibility with ruby26.
These patches have been applied upstream but no release
is currently available.
Signed-off-by: Hans de Graaff <graaff@gentoo.org>
Package-Manager: Portage-2.3.51, Repoman-2.3.11
-rw-r--r-- | dev-ruby/json/files/json-2.1.0-ruby26-1.patch | 20 | ||||
-rw-r--r-- | dev-ruby/json/files/json-2.1.0-ruby26-2.patch | 105 | ||||
-rw-r--r-- | dev-ruby/json/files/json-2.1.0-ruby26-3.patch | 143 | ||||
-rw-r--r-- | dev-ruby/json/json-2.1.0-r1.ebuild | 79 |
4 files changed, 347 insertions, 0 deletions
diff --git a/dev-ruby/json/files/json-2.1.0-ruby26-1.patch b/dev-ruby/json/files/json-2.1.0-ruby26-1.patch new file mode 100644 index 00000000000..e6f76a4be14 --- /dev/null +++ b/dev-ruby/json/files/json-2.1.0-ruby26-1.patch @@ -0,0 +1,20 @@ +commit bf226a9ac40e2296589004be89b4420b2121e000 +Author: eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> +Date: Fri Aug 3 15:11:22 2018 +0000 + + Fix missed update of parser source in r62429 + + git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e + +diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl +index 29900a4a4a..fba01ac0e5 100644 +--- a/ext/json/ext/parser/parser.rl ++++ b/ext/json/ext/parser/parser.rl +@@ -824,6 +824,7 @@ static VALUE cParser_source(VALUE self) + + void Init_parser(void) + { ++#undef rb_intern + rb_require("json/common"); + mJSON = rb_define_module("JSON"); + mExt = rb_define_module_under(mJSON, "Ext"); diff --git a/dev-ruby/json/files/json-2.1.0-ruby26-2.patch b/dev-ruby/json/files/json-2.1.0-ruby26-2.patch new file mode 100644 index 00000000000..9f1bff9b691 --- /dev/null +++ b/dev-ruby/json/files/json-2.1.0-ruby26-2.patch @@ -0,0 +1,105 @@ +commit e7da0fc34e8ed7fa250fc38f1109e4944cbad808 +Author: eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> +Date: Fri Aug 3 15:11:36 2018 +0000 + + ext/json/parser/parser.c: do not call rb_str_resize() on Time object + + * See https://github.com/flori/json/issues/342 + + git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e + +diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c +index b5ed093c1f..c8012796a4 100644 +--- a/ext/json/ext/parser/parser.c ++++ b/ext/json/ext/parser/parser.c +@@ -1659,7 +1659,9 @@ case 7: + if (json->symbolize_names && json->parsing_name) { + *result = rb_str_intern(*result); + } else { +- rb_str_resize(*result, RSTRING_LEN(*result)); ++ if (RB_TYPE_P(*result, T_STRING)) { ++ rb_str_resize(*result, RSTRING_LEN(*result)); ++ } + } + if (cs >= JSON_string_first_final) { + return p + 1; +@@ -1830,7 +1832,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) + } + + +-#line 1834 "parser.c" ++#line 1836 "parser.c" + enum {JSON_start = 1}; + enum {JSON_first_final = 10}; + enum {JSON_error = 0}; +@@ -1838,7 +1840,7 @@ enum {JSON_error = 0}; + enum {JSON_en_main = 1}; + + +-#line 742 "parser.rl" ++#line 744 "parser.rl" + + + /* +@@ -1855,16 +1857,16 @@ static VALUE cParser_parse(VALUE self) + GET_PARSER; + + +-#line 1859 "parser.c" ++#line 1861 "parser.c" + { + cs = JSON_start; + } + +-#line 758 "parser.rl" ++#line 760 "parser.rl" + p = json->source; + pe = p + json->len; + +-#line 1868 "parser.c" ++#line 1870 "parser.c" + { + if ( p == pe ) + goto _test_eof; +@@ -1898,7 +1900,7 @@ st0: + cs = 0; + goto _out; + tr2: +-#line 734 "parser.rl" ++#line 736 "parser.rl" + { + char *np = JSON_parse_value(json, p, pe, &result, 0); + if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;} +@@ -1908,7 +1910,7 @@ st10: + if ( ++p == pe ) + goto _test_eof10; + case 10: +-#line 1912 "parser.c" ++#line 1914 "parser.c" + switch( (*p) ) { + case 13: goto st10; + case 32: goto st10; +@@ -1997,7 +1999,7 @@ case 9: + _out: {} + } + +-#line 761 "parser.rl" ++#line 763 "parser.rl" + + if (cs >= JSON_first_final && p == pe) { + return result; +diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl +index fba01ac0e5..edab32b78f 100644 +--- a/ext/json/ext/parser/parser.rl ++++ b/ext/json/ext/parser/parser.rl +@@ -554,7 +554,9 @@ 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 (RB_TYPE_P(*result, T_STRING)) { ++ rb_str_resize(*result, RSTRING_LEN(*result)); ++ } + } + if (cs >= JSON_string_first_final) { + return p + 1; diff --git a/dev-ruby/json/files/json-2.1.0-ruby26-3.patch b/dev-ruby/json/files/json-2.1.0-ruby26-3.patch new file mode 100644 index 00000000000..cf16e235216 --- /dev/null +++ b/dev-ruby/json/files/json-2.1.0-ruby26-3.patch @@ -0,0 +1,143 @@ +commit a7e3516ff1116a15b3ed62f55143eceee27c4ce9 +Author: mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> +Date: Sun Dec 2 05:21:57 2018 +0000 + + Fix JSON::Parser against bigdecimal updates + + git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e + +diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c +index c8012796a4..b02aae8fb9 100644 +--- a/ext/json/ext/parser/parser.c ++++ b/ext/json/ext/parser/parser.c +@@ -91,12 +91,13 @@ static int convert_UTF32_to_UTF8(char *buf, UTF32 ch) + + static VALUE mJSON, mExt, cParser, eParserError, eNestingError; + static VALUE CNaN, CInfinity, CMinusInfinity; ++static VALUE cBigDecimal = Qundef; + + static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, + i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, + i_object_class, i_array_class, i_decimal_class, i_key_p, + i_deep_const_get, i_match, i_match_string, i_aset, i_aref, +- i_leftshift, i_new; ++ i_leftshift, i_new, i_BigDecimal; + + + #line 125 "parser.rl" +@@ -985,6 +986,19 @@ enum {JSON_float_en_main = 1}; + #line 340 "parser.rl" + + ++static int is_bigdecimal_class(VALUE obj) ++{ ++ if (cBigDecimal == Qundef) { ++ if (rb_const_defined(rb_cObject, i_BigDecimal)) { ++ cBigDecimal = rb_const_get_at(rb_cObject, i_BigDecimal); ++ } ++ else { ++ return 0; ++ } ++ } ++ return obj == cBigDecimal; ++} ++ + static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result) + { + int cs = EVIL; +@@ -1136,7 +1150,11 @@ case 7: + } else { + VALUE text; + text = rb_str_new2(FBUFFER_PTR(json->fbuffer)); +- *result = rb_funcall(json->decimal_class, i_new, 1, text); ++ if (is_bigdecimal_class(json->decimal_class)) { ++ *result = rb_funcall(Qnil, i_BigDecimal, 1, text); ++ } else { ++ *result = rb_funcall(json->decimal_class, i_new, 1, text); ++ } + } + return p + 1; + } else { +@@ -2101,6 +2119,7 @@ void Init_parser(void) + i_aref = rb_intern("[]"); + i_leftshift = rb_intern("<<"); + i_new = rb_intern("new"); ++ i_BigDecimal = rb_intern("BigDecimal"); + } + + /* +diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl +index edab32b78f..d4e7a60e9d 100644 +--- a/ext/json/ext/parser/parser.rl ++++ b/ext/json/ext/parser/parser.rl +@@ -89,12 +89,13 @@ static int convert_UTF32_to_UTF8(char *buf, UTF32 ch) + + static VALUE mJSON, mExt, cParser, eParserError, eNestingError; + static VALUE CNaN, CInfinity, CMinusInfinity; ++static VALUE cBigDecimal = Qundef; + + static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, + i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, + i_object_class, i_array_class, i_decimal_class, i_key_p, + i_deep_const_get, i_match, i_match_string, i_aset, i_aref, +- i_leftshift, i_new; ++ i_leftshift, i_new, i_BigDecimal; + + %%{ + machine JSON_common; +@@ -339,6 +340,19 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res + ) (^[0-9Ee.\-]? @exit ); + }%% + ++static int is_bigdecimal_class(VALUE obj) ++{ ++ if (cBigDecimal == Qundef) { ++ if (rb_const_defined(rb_cObject, i_BigDecimal)) { ++ cBigDecimal = rb_const_get_at(rb_cObject, i_BigDecimal); ++ } ++ else { ++ return 0; ++ } ++ } ++ return obj == cBigDecimal; ++} ++ + static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result) + { + int cs = EVIL; +@@ -357,7 +371,11 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul + } else { + VALUE text; + text = rb_str_new2(FBUFFER_PTR(json->fbuffer)); +- *result = rb_funcall(json->decimal_class, i_new, 1, text); ++ if (is_bigdecimal_class(json->decimal_class)) { ++ *result = rb_funcall(Qnil, i_BigDecimal, 1, text); ++ } else { ++ *result = rb_funcall(json->decimal_class, i_new, 1, text); ++ } + } + return p + 1; + } else { +@@ -861,6 +879,7 @@ void Init_parser(void) + i_aref = rb_intern("[]"); + i_leftshift = rb_intern("<<"); + i_new = rb_intern("new"); ++ i_BigDecimal = rb_intern("BigDecimal"); + } + + /* +diff --git a/test/json/json_parser_test.rb b/test/json/json_parser_test.rb +index 5f454eb121..68aeb572bb 100644 +--- a/tests/json_parser_test.rb ++++ b/tests/json_parser_test.rb +@@ -110,8 +110,8 @@ def test_parse_numbers + end + + def test_parse_bigdecimals +- assert_equal(BigDecimal, JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"].class) +- assert_equal(BigDecimal.new("0.901234567890123456789E1"),JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"] ) ++ assert_equal(BigDecimal, JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"].class) ++ assert_equal(BigDecimal("0.901234567890123456789E1"),JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"] ) + end + + if Array.method_defined?(:permutation) diff --git a/dev-ruby/json/json-2.1.0-r1.ebuild b/dev-ruby/json/json-2.1.0-r1.ebuild new file mode 100644 index 00000000000..74c58ff51b8 --- /dev/null +++ b/dev-ruby/json/json-2.1.0-r1.ebuild @@ -0,0 +1,79 @@ +# Copyright 1999-2018 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 +USE_RUBY="ruby23 ruby24 ruby25 ruby26" + +RUBY_FAKEGEM_RECIPE_DOC="rdoc" +RUBY_FAKEGEM_EXTRADOC="CHANGES.md README.md" +RUBY_FAKEGEM_DOCDIR="doc" + +RUBY_FAKEGEM_GEMSPEC="json.gemspec" + +inherit multilib ruby-fakegem + +DESCRIPTION="A JSON implementation as a Ruby extension" +HOMEPAGE="https://github.com/flori/json" +LICENSE="Ruby" + +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" +SLOT="2" +IUSE="" + +RDEPEND="${RDEPEND}" +DEPEND="${DEPEND} + dev-util/ragel" + +PATCHES=( + "${FILESDIR}/${P}-ruby26-1.patch" + "${FILESDIR}/${P}-ruby26-2.patch" + "${FILESDIR}/${P}-ruby26-3.patch" +) + +ruby_add_bdepend "dev-ruby/rake + doc? ( dev-ruby/rdoc )" + +all_ruby_prepare() { + # Avoid building the extension twice! + # And use rdoc instead of sdoc which we don't have packaged + # And don't call git to list files. We're using the pregenerated spec anyway. + sed -i \ + -e '/task :test/ s|:compile,||' \ + -e 's| => :clean||' \ + -e 's|sdoc|rdoc|' \ + -e 's|`git ls-files`|""|' \ + Rakefile || die "rakefile fix failed" + + # Remove hardcoded and broken -O setting. + sed -i -e '/^ \(if\|unless\)/,/^ end/ s:^:#:' \ + -e '/^unless/,/^end/ s:^:#:' ext/json/ext/*/extconf.rb || die + + # Avoid setting gem since it will not be available yet when installing + sed -i -e '/gem/ s:^:#:' tests/test_helper.rb || die +} + +each_ruby_configure() { + for ext in parser generator ; do + ${RUBY} -Cext/json/ext/${ext} extconf.rb || die + done +} + +each_ruby_compile() { + for ext in parser generator ; do + emake V=1 -Cext/json/ext/${ext} + cp ext/json/ext/${ext}/${ext}$(get_modname) ext/json/ext/ || die + done +} + +each_ruby_test() { + for t in pure ext ; do + JSON=${T} ${RUBY} -S rake do_test_${t} || die + done +} + +each_ruby_install() { + each_fakegem_install + + ruby_fakegem_newins ext/json/ext/generator$(get_modname) lib/json/ext/generator$(get_modname) + ruby_fakegem_newins ext/json/ext/parser$(get_modname) lib/json/ext/parser$(get_modname) +} |