summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-14 07:09:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-14 07:09:02 +0000
commitc9db11ea60413f98e23dbae4892c6612bb97645a (patch)
tree46af48a9f831f5c6cb8a2dddcd07e014887dc9ee
parentfa0f702c5b455252c66ede8563af7dd928eb8b95 (diff)
bignum.c: get rid of redefined method
* bignum.c (int_pow_tmp3): get rid of redefined Integer#> on internal calculations, as well as the GMP version. * bignum.c (rb_int_powm): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--bignum.c6
-rw-r--r--internal.h2
-rw-r--r--numeric.c12
3 files changed, 17 insertions, 3 deletions
diff --git a/bignum.c b/bignum.c
index dbb0b7f458..00d46ee662 100644
--- a/bignum.c
+++ b/bignum.c
@@ -6965,7 +6965,7 @@ int_pow_tmp3(VALUE x, VALUE y, VALUE m, int nega_flg)
x = rb_int_modulo(x, m);
}
- if (nega_flg && rb_num_positive_int_p(tmp)) {
+ if (nega_flg && rb_int_positive_p(tmp)) {
tmp = rb_int_minus(tmp, m);
}
return tmp;
@@ -7070,14 +7070,14 @@ rb_int_powm(int const argc, VALUE * const argv, VALUE const num)
if ( ! RB_INTEGER_TYPE_P(b)) {
rb_raise(rb_eTypeError, "Integer#pow() 2nd argument not allowed unless a 1st argument is integer");
}
- if (rb_num_negative_int_p(b)) {
+ if (rb_int_negative_p(b)) {
rb_raise(rb_eRangeError, "Integer#pow() 1st argument cannot be negative when 2nd argument specified");
}
if (!RB_INTEGER_TYPE_P(m)) {
rb_raise(rb_eTypeError, "Integer#pow() 2nd argument not allowed unless all arguments are integers");
}
- if (rb_num_negative_int_p(m)) {
+ if (rb_int_negative_p(m)) {
m = rb_int_uminus(m);
nega_flg = 1;
}
diff --git a/internal.h b/internal.h
index 8388741c63..7944f87043 100644
--- a/internal.h
+++ b/internal.h
@@ -1459,6 +1459,8 @@ VALUE rb_int_lshift(VALUE x, VALUE y);
VALUE rb_int_div(VALUE x, VALUE y);
VALUE rb_int_abs(VALUE num);
VALUE rb_int_odd_p(VALUE num);
+int rb_int_positive_p(VALUE num);
+int rb_int_negative_p(VALUE num);
static inline VALUE
rb_num_compare_with_zero(VALUE num, ID mid)
diff --git a/numeric.c b/numeric.c
index 569d558425..7047f9185d 100644
--- a/numeric.c
+++ b/numeric.c
@@ -296,6 +296,18 @@ int_neg_p(VALUE num)
}
int
+rb_int_positive_p(VALUE num)
+{
+ return int_pos_p(num);
+}
+
+int
+rb_int_negative_p(VALUE num)
+{
+ return int_neg_p(num);
+}
+
+int
rb_num_negative_p(VALUE num)
{
return rb_num_negative_int_p(num);