diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-29 16:06:09 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-29 16:06:09 +0000 |
commit | 57dbec8d8ad60c6861d2cc0d74dffc59ae124403 (patch) | |
tree | 4af9346aa99b3058381384fa9cb6eab76436c86f /complex.c | |
parent | 0c6ec45001460e65e2ef50360c2090a26939a689 (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.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -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 |