[60220] trunk/dports/lang/ruby

kimuraw at macports.org kimuraw at macports.org
Fri Nov 6 06:23:41 PST 2009


Revision: 60220
          http://trac.macports.org/changeset/60220
Author:   kimuraw at macports.org
Date:     2009-11-06 06:23:38 -0800 (Fri, 06 Nov 2009)
Log Message:
-----------
ruby/lang: fix #22361, Hash equivalence fails on large Fixnums

Modified Paths:
--------------
    trunk/dports/lang/ruby/Portfile

Added Paths:
-----------
    trunk/dports/lang/ruby/files/patch-bug22361.diff

Modified: trunk/dports/lang/ruby/Portfile
===================================================================
--- trunk/dports/lang/ruby/Portfile	2009-11-06 07:53:58 UTC (rev 60219)
+++ trunk/dports/lang/ruby/Portfile	2009-11-06 14:23:38 UTC (rev 60220)
@@ -4,7 +4,7 @@
 
 name			ruby
 version			1.8.7-p174
-revision		0
+revision		1
 
 categories		lang ruby
 maintainers		kimuraw
@@ -36,9 +36,11 @@
 # vendordir: enable vendor-specific.rb
 # #3604: gcc4 fails to detect linking at configure
 # #19050: use $(CC) not cc, this change has been merged at ruby-1.8 trunk
+# #22361: Hash equivalence fails when a value is a Fixnum > 2**29 or 2**61
 patchfiles		patch-vendordir.diff \
 				patch-bug3604.diff \
-				patch-bug19050.diff
+				patch-bug19050.diff \
+				patch-bug22361.diff
 
 # ignore getcontext() and setcontext()
 # on 10.5, these functions have some problems (SEGV on ppc, slower than 1.8.6)

Added: trunk/dports/lang/ruby/files/patch-bug22361.diff
===================================================================
--- trunk/dports/lang/ruby/files/patch-bug22361.diff	                        (rev 0)
+++ trunk/dports/lang/ruby/files/patch-bug22361.diff	2009-11-06 14:23:38 UTC (rev 60220)
@@ -0,0 +1,56 @@
+diff -ur ../ruby-1.8.7-p174.org/hash.c ./hash.c
+--- ../ruby-1.8.7-p174.org/hash.c	2009-02-24 02:40:05.000000000 +0900
++++ ./hash.c	2009-11-06 22:59:06.000000000 +0900
+@@ -81,7 +81,19 @@
+ rb_hash(obj)
+     VALUE obj;
+ {
+-    return rb_funcall(obj, id_hash, 0);
++    VALUE hval = rb_funcall(obj, id_hash, 0);
++  retry:
++    switch (TYPE(hval)) {
++      case T_FIXNUM:
++	return hval;
++
++      case T_BIGNUM:
++	return LONG2FIX(((long*)(RBIGNUM(hval)->digits))[0]);
++
++      default:
++	hval = rb_to_int(hval);
++	goto retry;
++    }
+ }
+ 
+ static int
+@@ -102,10 +114,7 @@
+ 	break;
+ 
+       default:
+-	hval = rb_funcall(a, id_hash, 0);
+-	if (!FIXNUM_P(hval)) {
+-	    hval = rb_funcall(hval, '%', 1, INT2FIX(536870923));
+-	}
++        hval = rb_hash(a);
+ 	hnum = (int)FIX2LONG(hval);
+     }
+     hnum <<= 1;
+Only in .: hash.c.orig
+diff -ur ../ruby-1.8.7-p174.org/test/ruby/test_hash.rb ./test/ruby/test_hash.rb
+--- ../ruby-1.8.7-p174.org/test/ruby/test_hash.rb	2008-06-09 03:25:01.000000000 +0900
++++ ./test/ruby/test_hash.rb	2009-11-06 22:43:45.000000000 +0900
+@@ -638,4 +638,15 @@
+   def test_hash_hash
+     assert_equal({0=>2,11=>1}.hash, {11=>1,0=>2}.hash)
+   end
++
++  def test_hash_bignum_hash
++    x = 2<<(32-3)-1
++    assert_equal({x=>1}.hash, {x=>1}.hash)
++    x = 2<<(64-3)-1
++    assert_equal({x=>1}.hash, {x=>1}.hash)
++
++    o = Object.new
++    def o.hash; 2<<100; end
++    assert_equal({x=>1}.hash, {x=>1}.hash)
++  end
+ end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20091106/8646938e/attachment.html>


More information about the macports-changes mailing list