From 7eb11ed61cb816e458f620fc8dd35b4888783bcc Mon Sep 17 00:00:00 2001 From: tadf Date: Tue, 28 Oct 2008 14:11:08 +0000 Subject: * 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: http://svn.ruby-lang.org/repos/ruby/trunk@20001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- complex.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'complex.c') diff --git a/complex.c b/complex.c index 316533f14..e59554ede 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 -- cgit