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

ruby-changes:34653

From: usa <ko1@a...>
Date: Mon, 7 Jul 2014 12:37:43 +0900 (JST)
Subject: [ruby-changes:34653] usa:r46736 (ruby_2_0_0): merge revision(s) 45399, 45400, 46036, 46037: [Backport #416]

usa	2014-07-07 12:37:35 +0900 (Mon, 07 Jul 2014)

  New Revision: 46736

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

  Log:
    merge revision(s) 45399,45400,46036,46037: [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_0_0/
  Modified files:
    branches/ruby_2_0_0/test/ruby/test_backtrace.rb
    branches/ruby_2_0_0/version.h
    branches/ruby_2_0_0/vm.c
Index: ruby_2_0_0/vm.c
===================================================================
--- ruby_2_0_0/vm.c	(revision 46735)
+++ ruby_2_0_0/vm.c	(revision 46736)
@@ -2137,46 +2137,44 @@ m_core_set_postexe(VALUE self, VALUE ise https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm.c#L2137
     return Qnil;
 }
 
+static VALUE m_core_hash_merge_ary(VALUE self, VALUE hash, VALUE ary);
+
+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 = 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_PTR(ary)[i], RARRAY_PTR(ary)[i+1]);
-    }
-
-    return hash;
+    return m_core_hash_merge_ary(self, 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_PTR(ary)[i], RARRAY_PTR(ary)[i+1]);
-    }
-
+    core_hash_merge(hash, RARRAY_LEN(ary), RARRAY_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]);
-    }
+    core_hash_merge(hash, argc-1, argv+1);
 
     return hash;
 }
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 46735)
+++ ruby_2_0_0/version.h	(revision 46736)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-07-07"
-#define RUBY_PATCHLEVEL 520
+#define RUBY_PATCHLEVEL 521
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 7
Index: ruby_2_0_0/test/ruby/test_backtrace.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_backtrace.rb	(revision 46735)
+++ ruby_2_0_0/test/ruby/test_backtrace.rb	(revision 46736)
@@ -162,4 +162,26 @@ class TestBacktrace < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_backtrace.rb#L162
       q << true
     end
   end
+
+  def test_core_backtrace_alias
+    obj = BasicObject.new
+    e = assert_raise(NameError) do
+      class << obj
+        alias foo bar
+      end
+    end
+    /`(.*)'\z/.match e.backtrace[0]
+    assert_not_match(/\Acore#/, $1)
+  end
+
+  def test_core_backtrace_undef
+    obj = BasicObject.new
+    e = assert_raise(NameError) do
+      class << obj
+        undef foo
+      end
+    end
+    /`(.*)'\z/.match e.backtrace[0]
+    assert_not_match(/\Acore#/, $1)
+  end
 end

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r45399-45400,46036-46037


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

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