Index: factory/cf_gcd.cc
===================================================================
--- factory/cf_gcd.cc	(revision f4b18020f64669b26ca1cbe58482a4d2d8178a49)
+++ factory/cf_gcd.cc	(revision c992ec156497eaa9343dc9a5d158563b0e6e2626)
@@ -1,4 +1,4 @@
 /* emacs edit mode for this file is -*- C++ -*- */
-/* $Id: cf_gcd.cc,v 1.52 2007-09-26 15:07:16 Singular Exp $ */
+/* $Id: cf_gcd.cc,v 1.53 2007-10-09 12:41:24 Singular Exp $ */
 
 #include <config.h>
@@ -501,44 +501,50 @@
         }
     }
-    else if (
-    isOn(SW_USE_CHINREM_GCD)
-    && (!fc.isUnivariate()) && (!gc.isUnivariate())
-    && (isPurePoly_m(fc)) && (isPurePoly_m(gc))
-    )
-    {
-        if ( p1 == fc.level() )
-            fc = chinrem_gcd( fc, gc );
-        else
-        {
-            fc = replacevar( fc, Variable(p1), Variable(mp) );
-            gc = replacevar( gc, Variable(p1), Variable(mp) );
-            fc = replacevar( chinrem_gcd( fc, gc ), Variable(mp), Variable(p1) );
-        }
-      //fc = chinrem_gcd( fc, gc);
-    }
-    else if ( isOn( SW_USE_EZGCD ) && !fc.isUnivariate() )
-    {
-      if ( pe == 1 )
+    else if (!fc.isUnivariate())
+    {
+      if ( isOn( SW_USE_EZGCD ) )
+      {
+        if ( pe == 1 )
           fc = ezgcd( fc, gc );
-      else if ( pe > 0 )// no variable at position 1
-      {
+        else if ( pe > 0 )// no variable at position 1
+        {
           fc = replacevar( fc, Variable(pe), Variable(1) );
           gc = replacevar( gc, Variable(pe), Variable(1) );
           fc = replacevar( ezgcd( fc, gc ), Variable(1), Variable(pe) );
-      }
-      else
-      {
+        }
+        else
+        {
           pe = -pe;
           fc = swapvar( fc, Variable(pe), Variable(1) );
           gc = swapvar( gc, Variable(pe), Variable(1) );
           fc = swapvar( ezgcd( fc, gc ), Variable(1), Variable(pe) );
+        }
       }
-    }
-    else
-    {
-        fc = gcd_poly_0( fc, gc );
+      else if (
+      isOn(SW_USE_CHINREM_GCD)
+      && (!gc.isUnivariate())
+      && (isPurePoly_m(fc)) && (isPurePoly_m(gc))
+      )
+      {
+      #if 0
+        if ( p1 == fc.level() )
+            fc = chinrem_gcd( fc, gc );
+        else
+        {
+            fc = replacevar( fc, Variable(p1), Variable(mp) );
+            gc = replacevar( gc, Variable(p1), Variable(mp) );
+            fc = replacevar( chinrem_gcd( fc, gc ), Variable(mp), Variable(p1) );
+        }
+      #else
+        fc = chinrem_gcd( fc, gc);
+      #endif
+      }
+    }
+    else
+    {
+      fc = gcd_poly_0( fc, gc );
     }
     if ( d1.degree() > 0 )
-        fc *= d1;
+      fc *= d1;
     return fc;
 }
@@ -982,9 +988,8 @@
 }
 
-#define GCD_CHINES_MIN_TRIES 3
 CanonicalForm chinrem_gcd ( const CanonicalForm & FF, const CanonicalForm & GG )
 {
   CanonicalForm f, g, cg, cl, q, Dp, newD, D, newq;
-  int p, i, n, dp_deg, d_deg;;
+  int p, i, dp_deg, d_deg;;
 
   CanonicalForm cd = bCommonDen( FF );
@@ -1004,5 +1009,4 @@
   cl =  f.lc()* g.lc();
 
-  n=GCD_CHINES_MIN_TRIES;
   while ( true )
   {
@@ -1015,5 +1019,4 @@
     }
     setCharacteristic( p );
-    n--;
     Dp = gcd( mapinto( f ), mapinto( g ) );
     Dp /=Dp.lc();
@@ -1038,5 +1041,4 @@
       else if ( dp_deg < d_deg )
       {
-        n=GCD_CHINES_MIN_TRIES;
         // all previous p's are bad primes
         q = p;
@@ -1048,22 +1050,19 @@
     if ( i >= 0 )
     {
-      if (n<=0)
+      CanonicalForm Dn= Farey(D,q);
+      int is_rat=isOn(SW_RATIONAL);
+      On(SW_RATIONAL);
+      CanonicalForm cd = bCommonDen( Dn ); // we need On(SW_RATIONAL)
+      if (!is_rat) Off(SW_RATIONAL);
+      Dn *=cd;
+      //Dn /=vcontent(Dn,Variable(1));
+      if ( fdivides( Dn, f ) && fdivides( Dn, g ) )
       {
-        CanonicalForm Dn= Farey(D,q);
-        int is_rat=isOn(SW_RATIONAL);
-        On(SW_RATIONAL);
-        CanonicalForm cd = bCommonDen( Dn ); // we need On(SW_RATIONAL)
-        if (!is_rat) Off(SW_RATIONAL);
-        Dn *=cd;
-        //Dn /=vcontent(Dn,Variable(1));
-        if ( fdivides( Dn, f ) && fdivides( Dn, g ) )
-        {
-          return Dn;
-        }
+        return Dn;
+      }
       //else: try more primes
-      }
-    }
-    else
-    {
+    }
+    else
+    { // try other method
       Off(SW_USE_CHINREM_GCD);
       D=gcd_poly( f, g );
