=================================================================== RCS file: /home/cvs/OpenXM_contrib/gmp/mpq/Attic/canonicalize.c,v retrieving revision 1.1.1.2 retrieving revision 1.1.1.3 diff -u -p -r1.1.1.2 -r1.1.1.3 --- OpenXM_contrib/gmp/mpq/Attic/canonicalize.c 2000/09/09 14:13:02 1.1.1.2 +++ OpenXM_contrib/gmp/mpq/Attic/canonicalize.c 2003/08/25 16:06:34 1.1.1.3 @@ -1,7 +1,7 @@ /* mpq_canonicalize(op) -- Remove common factors of the denominator and numerator in OP. -Copyright (C) 1991, 1994, 1995, 1996 Free Software Foundation, Inc. +Copyright 1991, 1994, 1995, 1996, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -24,16 +24,14 @@ MA 02111-1307, USA. */ #include "gmp-impl.h" void -#if __STDC__ mpq_canonicalize (MP_RAT *op) -#else -mpq_canonicalize (op) - MP_RAT *op; -#endif { mpz_t gcd; TMP_DECL (marker); + if (op->_mp_den._mp_size == 0) + DIVIDE_BY_ZERO; + TMP_MARK (marker); /* ??? Dunno if the 1+ is needed. */ @@ -41,8 +39,11 @@ mpq_canonicalize (op) ABS (op->_mp_den._mp_size))); mpz_gcd (gcd, &(op->_mp_num), &(op->_mp_den)); - mpz_divexact (&(op->_mp_num), &(op->_mp_num), gcd); - mpz_divexact (&(op->_mp_den), &(op->_mp_den), gcd); + if (! MPZ_EQUAL_1_P (gcd)) + { + mpz_divexact_gcd (&(op->_mp_num), &(op->_mp_num), gcd); + mpz_divexact_gcd (&(op->_mp_den), &(op->_mp_den), gcd); + } if (op->_mp_den._mp_size < 0) {