ruby-changes:34547
From: nagachika <ko1@a...>
Date: Tue, 1 Jul 2014 03:02:30 +0900 (JST)
Subject: [ruby-changes:34547] nagachika:r46628 (ruby_2_1): merge revision(s) r45399, r45400, r46036, r46037: [Backport #416]
nagachika 2014-07-01 03:02:23 +0900 (Tue, 01 Jul 2014) New Revision: 46628 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46628 Log: merge revision(s) r45399,r45400,r46036,r46037: [Backport #416] vm.c: merge code * vm.c (m_core_hash_from_ary, m_core_hash_merge_ary): merge duplicated code. Modified directories: branches/ruby_2_1/ Modified files: branches/ruby_2_1/test/ruby/test_backtrace.rb branches/ruby_2_1/version.h branches/ruby_2_1/vm.c Index: ruby_2_1/vm.c =================================================================== --- ruby_2_1/vm.c (revision 46627) +++ ruby_2_1/vm.c (revision 46628) @@ -2262,46 +2262,62 @@ m_core_set_postexe(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm.c#L2262 return Qnil; } +static VALUE core_hash_merge_ary(VALUE hash, VALUE ary); +static VALUE core_hash_from_ary(VALUE ary); +static VALUE core_hash_merge_kwd(int argc, VALUE *argv); + +static VALUE +core_hash_merge(VALUE hash, long argc, const VALUE *argv) +{ + long i; + + assert(argc % 2 == 0); + for (i=0; i<argc; i+=2) { + rb_hash_aset(hash, argv[i], argv[i+1]); + } + return hash; +} + static VALUE m_core_hash_from_ary(VALUE self, VALUE ary) { + VALUE hash; + REWIND_CFP(hash = core_hash_from_ary(ary)); + return hash; +} + +static VALUE +core_hash_from_ary(VALUE ary) +{ VALUE hash = rb_hash_new(); - int i; if (RUBY_DTRACE_HASH_CREATE_ENABLED()) { RUBY_DTRACE_HASH_CREATE(RARRAY_LEN(ary), rb_sourcefile(), rb_sourceline()); } - assert(RARRAY_LEN(ary) % 2 == 0); - for (i=0; i<RARRAY_LEN(ary); i+=2) { - rb_hash_aset(hash, RARRAY_AREF(ary, i), RARRAY_AREF(ary, i+1)); - } - - return hash; + return core_hash_merge_ary(hash, ary); } static VALUE m_core_hash_merge_ary(VALUE self, VALUE hash, VALUE ary) { - int i; - - assert(RARRAY_LEN(ary) % 2 == 0); - for (i=0; i<RARRAY_LEN(ary); i+=2) { - rb_hash_aset(hash, RARRAY_AREF(ary, i), RARRAY_AREF(ary, i+1)); - } + REWIND_CFP(core_hash_merge_ary(hash, ary)); + return hash; +} +static VALUE +core_hash_merge_ary(VALUE hash, VALUE ary) +{ + core_hash_merge(hash, RARRAY_LEN(ary), RARRAY_CONST_PTR(ary)); return hash; } static VALUE m_core_hash_merge_ptr(int argc, VALUE *argv, VALUE recv) { - int i; VALUE hash = argv[0]; - for (i=1; i<argc; i+=2) { - rb_hash_aset(hash, argv[i], argv[i+1]); - } + REWIND_CFP(core_hash_merge(hash, argc-1, argv+1)); return hash; } @@ -2334,6 +2350,14 @@ kwcheck_i(VALUE key, VALUE value, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm.c#L2350 static VALUE m_core_hash_merge_kwd(int argc, VALUE *argv, VALUE recv) { + VALUE hash; + REWIND_CFP(hash = core_hash_merge_kwd(argc, argv)); + return hash; +} + +static VALUE +core_hash_merge_kwd(int argc, VALUE *argv) +{ VALUE hash, kw; rb_check_arity(argc, 1, 2); hash = argv[0]; Index: ruby_2_1/version.h =================================================================== --- ruby_2_1/version.h (revision 46627) +++ ruby_2_1/version.h (revision 46628) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1 #define RUBY_VERSION "2.1.2" -#define RUBY_RELEASE_DATE "2014-06-30" -#define RUBY_PATCHLEVEL 157 +#define RUBY_RELEASE_DATE "2014-07-01" +#define RUBY_PATCHLEVEL 158 #define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 30 +#define RUBY_RELEASE_MONTH 7 +#define RUBY_RELEASE_DAY 1 #include "ruby/version.h" Index: ruby_2_1/test/ruby/test_backtrace.rb =================================================================== --- ruby_2_1/test/ruby/test_backtrace.rb (revision 46627) +++ ruby_2_1/test/ruby/test_backtrace.rb (revision 46628) @@ -214,4 +214,31 @@ class TestBacktrace < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_backtrace.rb#L214 q << true end end + + def test_core_backtrace_alias + obj = BasicObject.new + e = assert_raise(NameError) do + class << obj + alias foo bar + end + end + assert_not_match(/\Acore#/, e.backtrace_locations[0].base_label) + end + + def test_core_backtrace_undef + obj = BasicObject.new + e = assert_raise(NameError) do + class << obj + undef foo + end + end + assert_not_match(/\Acore#/, e.backtrace_locations[0].base_label) + end + + def test_core_backtrace_hash_merge + e = assert_raise(TypeError) do + {**nil} + end + assert_not_match(/\Acore#/, e.backtrace_locations[0].base_label) + end end Property changes on: ruby_2_1 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r45399-45400,46036-46037 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/