summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-10 12:33:09 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-10 12:33:09 +0000
commitcdf993100566b2a42ffb040f0f2b7a900fdc5ff7 (patch)
tree3c61a71da04198a68375aee80a5106ac1c204e85
parent5edb9fab69a8ccdd8e9b0c98e30d3051e2f2634b (diff)
merge revision(s) 59765: [Backport #13877]
ruby.h: unnormalized Fixnum value * include/ruby/ruby.h (ST2FIX): fix unnormalized Fixnum value bug on mingw/mswin. [ruby-core:82687] [Bug #13877] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/bigdecimal/bigdecimal.c2
-rw-r--r--ext/date/date_core.c2
-rw-r--r--ext/openssl/ossl_bn.c2
-rw-r--r--include/ruby/ruby.h3
-rw-r--r--internal.h2
-rw-r--r--test/bigdecimal/test_bigdecimal.rb1
-rw-r--r--test/date/test_date.rb2
-rw-r--r--version.h2
8 files changed, 10 insertions, 6 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 0d9d0518a8..220d993ad2 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -382,7 +382,7 @@ BigDecimal_hash(VALUE self)
hash ^= rb_memhash(p->frac, sizeof(BDIGIT)*p->Prec);
hash += p->exponent;
}
- return INT2FIX(hash);
+ return ST2FIX(hash);
}
/*
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index 9b12c584a8..86ce0d8add 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -6444,7 +6444,7 @@ d_lite_hash(VALUE self)
h[2] = m_df(dat);
h[3] = m_sf(dat);
v = rb_memhash(h, sizeof(h));
- return LONG2FIX(v);
+ return ST2FIX(v);
}
#include "date_tmx.h"
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c
index aa0f2c605f..29dc1a2169 100644
--- a/ext/openssl/ossl_bn.c
+++ b/ext/openssl/ossl_bn.c
@@ -953,7 +953,7 @@ ossl_bn_hash(VALUE self)
ossl_raise(eBNError, NULL);
}
- hash = INT2FIX(rb_memhash(buf, len));
+ hash = ST2FIX(rb_memhash(buf, len));
xfree(buf);
return hash;
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 9dc0b3000e..43fe804337 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1575,6 +1575,9 @@ rb_num2char_inline(VALUE x)
#define NUM2CHR(x) RB_NUM2CHR(x)
#define CHR2FIX(x) RB_CHR2FIX(x)
+#define RB_ST2FIX(h) RB_LONG2FIX((long)(h))
+#define ST2FIX(h) RB_ST2FIX(h)
+
#define RB_ALLOC_N(type,n) ((type*)ruby_xmalloc2((size_t)(n),sizeof(type)))
#define RB_ALLOC(type) ((type*)ruby_xmalloc(sizeof(type)))
#define RB_ZALLOC_N(type,n) ((type*)ruby_xcalloc((size_t)(n),sizeof(type)))
diff --git a/internal.h b/internal.h
index e0a4729d2f..45e32c35b7 100644
--- a/internal.h
+++ b/internal.h
@@ -330,8 +330,6 @@ ntz_intptr(uintptr_t x)
VALUE rb_int128t2big(int128_t n);
#endif
-#define ST2FIX(h) LONG2FIX((long)(h))
-
/* arguments must be Fixnum */
static inline VALUE
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 80ffc3fedd..60f9f70068 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -549,6 +549,7 @@ class TestBigDecimal < Test::Unit::TestCase
a.each_with_index do |x, i|
assert_equal(i, h[x])
end
+ assert_instance_of(String, b.hash.to_s)
end
def test_marshal
diff --git a/test/date/test_date.rb b/test/date/test_date.rb
index 247cce1eaf..ba3fbbffaf 100644
--- a/test/date/test_date.rb
+++ b/test/date/test_date.rb
@@ -129,6 +129,8 @@ class TestDate < Test::Unit::TestCase
assert_equal(3, h.size)
assert_equal(9, h[Date.new(1999,5,25)])
assert_equal(9, h[DateTime.new(1999,5,25)])
+
+ assert_instance_of(String, Date.new(1999,5,25).hash.to_s)
end
def test_freeze
diff --git a/version.h b/version.h
index c93a33c622..65b3d8ff47 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.4.2"
#define RUBY_RELEASE_DATE "2017-09-10"
-#define RUBY_PATCHLEVEL 195
+#define RUBY_PATCHLEVEL 196
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 9