Index: factory/cf_gcd.cc
===================================================================
--- factory/cf_gcd.cc	(revision a4f5ce528f6265f42ae27cf6284dedb95f91544e)
+++ factory/cf_gcd.cc	(revision 33d87254b9d1883fe8b32ec87df6614827559310)
@@ -1,4 +1,4 @@
 /* emacs edit mode for this file is -*- C++ -*- */
-/* $Id: cf_gcd.cc,v 1.28 2005-02-03 14:05:55 Singular Exp $ */
+/* $Id: cf_gcd.cc,v 1.29 2005-02-11 13:22:44 Singular Exp $ */
 
 #include <config.h>
@@ -198,4 +198,8 @@
     if ( getCharacteristic() > 0 )
     {
+      //CanonicalForm cf=F.lc();
+      //CanonicalForm f=F / cf;
+      //CanonicalForm cg=G.lc();
+      //CanonicalForm g= G / cg;
       zz_pContext ccc(getCharacteristic());
       ccc.restore();
@@ -204,12 +208,34 @@
       zz_pX G1=convertFacCF2NTLzzpX(G);
       zz_pX R=GCD(F1,G1);
-      return convertNTLzzpX2CF(R,F.mvar());
+      return  convertNTLzzpX2CF(R,F.mvar());
     }
     else
     {
-      ZZX F1=convertFacCF2NTLZZX(F);
-      ZZX G1=convertFacCF2NTLZZX(G);
+      CanonicalForm f=F ;
+      CanonicalForm g=G ;
+      bool rat=isOn( SW_RATIONAL );
+      if ( isOn( SW_RATIONAL ) )
+      {
+         DEBOUTLN( cerr, "NTL_gcd: ..." );
+         CanonicalForm cdF = bCommonDen( F );
+         CanonicalForm cdG = bCommonDen( G );
+         Off( SW_RATIONAL );
+         CanonicalForm l = lcm( cdF, cdG );
+         On( SW_RATIONAL );
+         f *= l, g *= l;
+      }
+      DEBOUTLN( cerr, "NTL_gcd: f=" << f );
+      DEBOUTLN( cerr, "NTL_gcd: g=" << g );
+      ZZX F1=convertFacCF2NTLZZX(f);
+      ZZX G1=convertFacCF2NTLZZX(g);
       ZZX R=GCD(F1,G1);
-      return convertNTLZZX2CF(R,F.mvar());
+      CanonicalForm r=convertNTLZZX2CF(R,F.mvar());
+      DEBOUTLN( cerr, "NTL_gcd: -> " << r );
+      if (rat)
+      {
+        r /= r.lc();
+        DEBOUTLN( cerr, "NTL_gcd2: -> " << r );
+      }
+      return r;
     }
   }
@@ -316,9 +342,9 @@
     if ( pi.isUnivariate() && pi1.isUnivariate() )
     {
-      if ( modularflag
 #ifdef HAVE_NTL
-      || (isOn(SW_USE_NTL_GCD) && isPurePoly(pi) && isPurePoly(pi1))
+      if (isOn(SW_USE_NTL_GCD) && isPurePoly(pi) && isPurePoly(pi1))
+         return gcd_poly_univar0(f, g, true);
 #endif
-      )
+      if ( modularflag)
         return gcd_poly_univar0( pi, pi1, true ) * C;
     }
Index: factory/fac_ezgcd.cc
===================================================================
--- factory/fac_ezgcd.cc	(revision a4f5ce528f6265f42ae27cf6284dedb95f91544e)
+++ factory/fac_ezgcd.cc	(revision 33d87254b9d1883fe8b32ec87df6614827559310)
@@ -1,4 +1,4 @@
 /* emacs edit mode for this file is -*- C++ -*- */
-/* $Id: fac_ezgcd.cc,v 1.17 2005-02-03 14:05:55 Singular Exp $ */
+/* $Id: fac_ezgcd.cc,v 1.18 2005-02-11 13:24:27 Singular Exp $ */
 
 #include <config.h>
@@ -123,5 +123,9 @@
             CanonicalForm xxx;
             //if ( gcd( (DD[1] = Fb / Db), Db ) == 1 ) {
-	    xxx= gcd( (DD[1] = Fb / Db), Db );
+            DD[1] = Fb / Db;
+	    xxx= gcd( DD[1], Db );
+            DEBOUTLN( cerr, "gcd((Fb/Db),Db) = " << xxx );
+            DEBOUTLN( cerr, "Fb/Db = " << DD[1] );
+            DEBOUTLN( cerr, "Db = " << Db );
 	    if (xxx.inCoeffDomain()) {
                 B = F;
@@ -132,7 +136,13 @@
             }
             //else  if ( gcd( (DD[1] = Gb / Db), Db ) == 1 ) {
-	    else { 
-	    xxx=gcd( (DD[1] = Gb / Db), Db );
-	    if (xxx.inCoeffDomain()) {
+	    else
+            { 
+              DD[1] = Gb / Db;
+	      xxx=gcd( DD[1], Db );
+              DEBOUTLN( cerr, "gcd((Gb/Db),Db) = " << xxx );
+              DEBOUTLN( cerr, "Gb/Db = " << DD[1] );
+              DEBOUTLN( cerr, "Db = " << Db );
+	      if (xxx.inCoeffDomain())
+              {
                 B = G;
                 DD[2] = Db;
@@ -140,6 +150,7 @@
                 lcDD[2] = lcG;
                 B *= lcG;
-            }
-            else {
+              }
+              else
+              {
 #ifdef DEBUGOUTPUT
                 CanonicalForm dummyres = d * ezgcd_specialcase( F, G, b, bound );
@@ -149,5 +160,5 @@
                 return d * ezgcd_specialcase( F, G, b, bound );
 #endif
-            }
+              }
 	    }
             /// ---> A7
@@ -179,4 +190,5 @@
             /// ---> A8 (gcdfound)
         }
+        delta++;
     }
     /// ---> A9
@@ -209,8 +221,11 @@
     }
 #if 1
-    extern CanonicalForm
-gcd_poly1( const CanonicalForm & f, const CanonicalForm & g, bool modularflag );
-
-    return gcd_poly1( F, G, getCharacteristic()==0 );
+    Off(SW_USE_EZGCD);
+    //bool ntl=isOn(SW_USE_NTL_GCD);
+    //Off(SW_USE_NTL_GCD);
+    d=gcd( F, G );
+    //if (ntl) On(SW_USE_NTL_GCD);
+    On(SW_USE_EZGCD);
+    return d;
 #else
 
