summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-29 16:06:09 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-29 16:06:09 +0000
commit57dbec8d8ad60c6861d2cc0d74dffc59ae124403 (patch)
tree4af9346aa99b3058381384fa9cb6eab76436c86f /complex.c
parent0c6ec45001460e65e2ef50360c2090a26939a689 (diff)
merged r20001 and r20002 from trunk into ruby_1_9_1.
* complex.c: continues to support canonicalization *unofficially* for an odd library mathn for the time being (only 1.9.x). since grand mathn is must be very very special library for us. * rational.c: ditto. * ext/mathn/*/*: follow the above changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/complex.c b/complex.c
index 316533f14c..e59554eded 100644
--- a/complex.c
+++ b/complex.c
@@ -320,7 +320,19 @@ f_complex_new_bang2(VALUE klass, VALUE x, VALUE y)
return nucomp_s_new_internal(klass, x, y);
}
-#define f_unify_p(klass) rb_const_defined(klass, id_Unify)
+#if RUBY_VERSION_CODE < 200
+#define CANON
+#endif
+
+#ifdef CANON
+static int canonicalization = 0;
+
+void
+nucomp_canonicalize(int f)
+{
+ canonicalization = f;
+}
+#endif
inline static void
nucomp_real_check(VALUE num)
@@ -343,10 +355,10 @@ nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
#ifdef CANON
#define CL_CANON
#ifdef CL_CANON
- if (f_zero_p(imag) && k_exact_p(imag) && f_unify_p(klass))
+ if (f_zero_p(imag) && k_exact_p(imag) && canonicalization)
return real;
#else
- if (f_zero_p(imag) && f_unify_p(klass))
+ if (f_zero_p(imag) && canonicalization)
return real;
#endif
#endif