summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-17 08:52:39 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-17 08:52:39 +0000
commit170f64d6ce826788d15a466268798f2b756e0fd9 (patch)
treeb7260240663d5e2dcb437675d7ac891fda7e04c4 /hash.c
parent445954a4bb610229af80380e6f2d26537b3d26a9 (diff)
merge revision(s) 51423,51425: [Backport #9381]
test_hash.rb: add assertions * test/ruby/test_hash.rb (test_wrapper_of_special_const): test other special obejcts. [Bug #9381] * hash.c (rb_any_hash): fix Float hash. rb_dbl_hash() returns a Fixnum, but not a long. [Bug #9381] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/hash.c b/hash.c
index 75ecdc0fe4..0d344f23b5 100644
--- a/hash.c
+++ b/hash.c
@@ -135,7 +135,7 @@ rb_any_hash(VALUE a)
if (a == Qundef) return 0;
if (FLONUM_P(a)) {
/* prevent pathological behavior: [Bug #10761] */
- return rb_dbl_hash(rb_float_value(a));
+ goto flt;
}
hnum = rb_objid_hash((st_index_t)a);
}
@@ -143,7 +143,9 @@ rb_any_hash(VALUE a)
hnum = rb_str_hash(a);
}
else if (BUILTIN_TYPE(a) == T_FLOAT) {
- return rb_dbl_hash(rb_float_value(a));
+ flt:
+ hval = rb_dbl_hash(rb_float_value(a));
+ hnum = FIX2LONG(hval);
}
else {
hval = rb_hash(a);