Index: factory/NTLconvert.cc
===================================================================
--- factory/NTLconvert.cc	(revision 6840b2040b65b549b02b0e852339ab1a0a791484)
+++ factory/NTLconvert.cc	(revision 1e6de686866af59b3d97fffef1d92033d15f47c6)
@@ -1,3 +1,3 @@
-/* $Id: NTLconvert.cc,v 1.22 2007-04-26 08:22:48 Singular Exp $ */
+/* $Id: NTLconvert.cc,v 1.23 2008-01-07 13:33:09 Singular Exp $ */
 #include <config.h>
 
@@ -71,5 +71,5 @@
 {
   printf("%s",s1);
-  if (f==0) printf("+0");
+  if (f.isZero()) printf("+0");
   else if (! f.inCoeffDomain() )
   {
Index: factory/cf_factor.cc
===================================================================
--- factory/cf_factor.cc	(revision 6840b2040b65b549b02b0e852339ab1a0a791484)
+++ factory/cf_factor.cc	(revision 1e6de686866af59b3d97fffef1d92033d15f47c6)
@@ -1,4 +1,4 @@
 /* emacs edit mode for this file is -*- C++ -*- */
-/* $Id: cf_factor.cc,v 1.35 2007-10-25 14:45:41 Singular Exp $ */
+/* $Id: cf_factor.cc,v 1.36 2008-01-07 13:33:10 Singular Exp $ */
 
 //{{{ docu
@@ -85,5 +85,5 @@
 {
   printf("%s",s1);
-  if (f==0) printf("+0");
+  if (f.isZero()) printf("+0");
   //else if (! f.inCoeffDomain() )
   else if (! f.inBaseDomain() )
Index: factory/cf_gcd.cc
===================================================================
--- factory/cf_gcd.cc	(revision 6840b2040b65b549b02b0e852339ab1a0a791484)
+++ factory/cf_gcd.cc	(revision 1e6de686866af59b3d97fffef1d92033d15f47c6)
@@ -1,4 +1,4 @@
 /* emacs edit mode for this file is -*- C++ -*- */
-/* $Id: cf_gcd.cc,v 1.58 2007-12-19 14:27:14 Singular Exp $ */
+/* $Id: cf_gcd.cc,v 1.59 2008-01-07 13:33:10 Singular Exp $ */
 
 #include <config.h>
@@ -475,5 +475,5 @@
   int mp, cc, p1, pe;
   mp = f.level()+1;
-#if 0
+#if 1
   if (( getCharacteristic() == 0 )
   && (f.level() >4)
@@ -489,57 +489,46 @@
   }
 #endif
-  cf_prepgcd( f, g, cc, p1, pe);
-  if ( cc != 0 )
-  {
-    if ( cc > 0 )
-    {
-      fc = replacevar( f, Variable(cc), Variable(mp) );
-      gc = g;
-    }
-    else
-    {
-      fc = replacevar( g, Variable(-cc), Variable(mp) );
-      gc = f;
-    }
-    return cf_content( fc, gc );
-  }
-// now each appearing variable is in f and g
-  fc = f;
-  gc = g;
-  if( gcd_avoid_mtaildegree ( fc, gc, d1 ) )
-      return d1;
-  bool fc_isUnivariate=fc.isUnivariate();
-  bool fc_and_gc_Univariate=fc_isUnivariate && gc.isUnivariate();
+  bool fc_isUnivariate=f.isUnivariate();
+  bool fc_and_gc_Univariate=fc_isUnivariate && g.isUnivariate();
   if ( getCharacteristic() != 0 )
   {
     if (isOn( SW_USE_EZGCD_P ) && (!fc_and_gc_Univariate))
     {
-      if ( pe == 1 )
-        fc = fin_ezgcd( fc, gc );
-      else if ( pe > 0 )// no variable at position 1
+        return fin_ezgcd( f, g );
+    }
+    else if (isOn(SW_USE_GCD_P))
+    {
+      return newGCD(f,g);
+    }
+    else
+    {
+      cf_prepgcd( f, g, cc, p1, pe);
+      if ( cc != 0 )
       {
-        fc = replacevar( fc, Variable(pe), Variable(1) );
-        gc = replacevar( gc, Variable(pe), Variable(1) );
-        fc = replacevar( fin_ezgcd( fc, gc ), Variable(1), Variable(pe) );
+        if ( cc > 0 )
+        {
+          fc = replacevar( f, Variable(cc), Variable(mp) );
+          gc = g;
+        }
+        else
+        {
+          fc = replacevar( g, Variable(-cc), Variable(mp) );
+          gc = f;
+        }
+        return cf_content( fc, gc );
       }
+      // now each appearing variable is in f and g
+      fc = f;
+      gc = g;
+      if( gcd_avoid_mtaildegree ( fc, gc, d1 ) )
+        return d1;
+      if ( p1 == fc.level() )
+        fc = gcd_poly_p( fc, gc );
       else
       {
-        pe = -pe;
-        fc = swapvar( fc, Variable(pe), Variable(1) );
-        gc = swapvar( gc, Variable(pe), Variable(1) );
-        fc = swapvar( fin_ezgcd( fc, gc ), Variable(1), Variable(pe) );
+        fc = replacevar( fc, Variable(p1), Variable(mp) );
+        gc = replacevar( gc, Variable(p1), Variable(mp) );
+        fc = replacevar( gcd_poly_p( fc, gc ), Variable(mp), Variable(p1) );
       }
-    }
-    else if (isOn(SW_USE_GCD_P))
-    {
-      fc=newGCD(fc,gc);
-    }
-    else if ( p1 == fc.level() )
-      fc = gcd_poly_p( fc, gc );
-    else
-    {
-      fc = replacevar( fc, Variable(p1), Variable(mp) );
-      gc = replacevar( gc, Variable(p1), Variable(mp) );
-      fc = replacevar( gcd_poly_p( fc, gc ), Variable(mp), Variable(p1) );
     }
   }
@@ -548,65 +537,69 @@
     if (
     isOn(SW_USE_CHINREM_GCD)
-    && (gc.level() >5)
-    && (fc.level() >5)
-    && (isPurePoly_m(fc)) && (isPurePoly_m(gc))
+    && (g.level() >5)
+    && (f.level() >5)
+    && (isPurePoly_m(f)) && (isPurePoly_m(g))
     )
     {
-    #if 0
-      if ( p1 == fc.level() )
-        fc = chinrem_gcd( fc, gc );
-      else
+      return chinrem_gcd( f, g);
+    }
+    if ( isOn( SW_USE_EZGCD ) )
+    {
+      return ezgcd( f, g );
+    }
+    else if (
+    isOn(SW_USE_CHINREM_GCD)
+    && (isPurePoly_m(f)) && (isPurePoly_m(g))
+    )
+    {
+      return chinrem_gcd( f, g);
+    }
+    else
+    {
+      cf_prepgcd( f, g, cc, p1, pe);
+      if ( cc != 0 )
       {
-        fc = replacevar( fc, Variable(p1), Variable(mp) );
-        gc = replacevar( gc, Variable(p1), Variable(mp) );
-        fc = replacevar( chinrem_gcd( fc, gc ), Variable(mp), Variable(p1) );
+        if ( cc > 0 )
+        {
+          fc = replacevar( f, Variable(cc), Variable(mp) );
+          gc = g;
+        }
+        else
+        {
+          fc = replacevar( g, Variable(-cc), Variable(mp) );
+          gc = f;
+        }
+        return cf_content( fc, gc );
       }
-    #else
-      fc = chinrem_gcd( fc, gc);
-    #endif
-    }
-    if ( isOn( SW_USE_EZGCD ) )
-    {
-      if ( pe == 1 )
-        fc = ezgcd( fc, gc );
-      else if ( pe > 0 )// no variable at position 1
+      // now each appearing variable is in f and g
+      fc = f;
+      gc = g;
+      if( gcd_avoid_mtaildegree ( fc, gc, d1 ) )
+        return d1;
+      fc = gcd_poly_0( fc, gc );
+    }
+  }
+  else
+  {
+    cf_prepgcd( f, g, cc, p1, pe);
+    if ( cc != 0 )
+    {
+      if ( cc > 0 )
       {
-        fc = replacevar( fc, Variable(pe), Variable(1) );
-        gc = replacevar( gc, Variable(pe), Variable(1) );
-        fc = replacevar( ezgcd( fc, gc ), Variable(1), Variable(pe) );
+        fc = replacevar( f, Variable(cc), Variable(mp) );
+        gc = g;
       }
       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) );
+        fc = replacevar( g, Variable(-cc), Variable(mp) );
+        gc = f;
       }
-    }
-    else if (
-    isOn(SW_USE_CHINREM_GCD)
-    && (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 );
-    }
-  }
-  else
-  {
+      return cf_content( fc, gc );
+    }
+    // now each appearing variable is in f and g
+    fc = f;
+    gc = g;
+    if( gcd_avoid_mtaildegree ( fc, gc, d1 ) )
+      return d1;
     fc = gcd_poly_0( fc, gc );
   }
Index: factory/ffreval.cc
===================================================================
--- factory/ffreval.cc	(revision 6840b2040b65b549b02b0e852339ab1a0a791484)
+++ factory/ffreval.cc	(revision 1e6de686866af59b3d97fffef1d92033d15f47c6)
@@ -20,5 +20,9 @@
 
   for( int i=values.min(); i<=n; i++ )
-    values[i] = offset[i] = gen->generate(); // generate random point
+  {
+    CanonicalForm tmp=gen->generate();
+    values[i] = tmp; // generate random point
+    offset[i] = tmp; // generate random point
+  }
 }
 
@@ -50,10 +54,10 @@
   if( this != &e )
   {
-    if( gen != 0 )
+    if( gen != NULL )
       delete gen;
     values = e.values;
     offset = e.offset;
-    if( e.gen == 0 )
-      gen = 0;
+    if( e.gen == NULL )
+      gen = NULL;
     else
       gen = e.gen->clone();
@@ -112,5 +116,6 @@
         b.init(); // choose random point
     }
-    while ( ! gcdfound ) {
+    while ( ! gcdfound )
+    {
         /// ---> A2
         DEBOUTLN( cerr, "search for evaluation, delta = " << delta );
@@ -138,5 +143,6 @@
         /// ---> A4
         //deltaold = delta;
-        while ( 1 ) {
+        while ( 1 )
+        {
             bt = b;
             if( ! fin_findeval( F, G, Fbt, Gbt, Dbt, bt, delta + 1, degF, degG ) )
@@ -156,5 +162,6 @@
             if ( dd /*degree( Dbt )*/ == delta )
                 break;
-            else  if ( dd /*degree( Dbt )*/ < delta ) {
+            else  if ( dd /*degree( Dbt )*/ < delta )
+            {
                 delta = dd /*degree( Dbt )*/;
                 b = bt;
@@ -174,5 +181,6 @@
             return d*G;
         }
-        if ( delta != degF && delta != degG ) {
+        if ( delta != degF && delta != degG )
+        {
             bool B_is_F;
             /// ---> A6
@@ -184,5 +192,6 @@
             DEBOUTLN( cerr, "Fb/Db = " << DD[1] );
             DEBOUTLN( cerr, "Db = " << Db );
-            if (xxx.inCoeffDomain()) {
+            if (xxx.inCoeffDomain())
+            {
                 B = F;
                 DD[2] = Db;
@@ -261,92 +270,8 @@
 {
     CanonicalForm d;
-#if 1
-    Off(SW_USE_EZGCD);
-    //bool ntl0=isOn(SW_USE_NTL_GCD_0);
-    //Off(SW_USE_NTL_GCD_0);
-    //bool ntlp=isOn(SW_USE_NTL_GCD_P);
-    //Off(SW_USE_NTL_GCD_P);
+    Off(SW_USE_EZGCD_P);
     d=gcd_poly( F, G );
-    //if (ntl0) On(SW_USE_NTL_GCD_0);
-    //if (ntlp) On(SW_USE_NTL_GCD_P);
-    On(SW_USE_EZGCD);
+    On(SW_USE_EZGCD_P);
     return d;
-#else
-    DEBOUTLN( cerr, "fin_ezgcd: special case" );
-    CanonicalForm Ft, Gt, L, LL, Fb, Gb, Db, Lb, D, Ds, Dt;
-    CFArray DD( 1, 2 ), lcDD( 1, 2 );
-    Variable x = Variable( 1 );
-    bool gcdfound;
-    Dt = 1;
-    /// ---> S1
-    DEBOUTLN( cerr, "fin_ezgcdspec: (S1)" );
-    Ft = fin_ezgcd( F, F.deriv( x ) );
-    if ( Ft.isOne() ) {
-        // In this case F is squarefree and we came here by bad chance
-        // (means: bad evaluation point).  Try again with another
-        // evaluation point.  Bug fix (?) by JS.  The bad example was
-        // gcd.debug -ocr /+USE_EZGCD/@12/CB \
-        //     '(16*B^8-208*B^6*C+927*B^4*C^2-1512*B^2*C^3+432*C^4)' \
-        //     '(4*B^7*C^2-50*B^5*C^3+208*B^3*C^4-288*B*C^5)'
-        if( ! b.step() ) // Error: run out of points
-        {
-          Off(SW_USE_EZGCD_P);
-          d = gcd_poly(F,G);
-          On(SW_USE_EZGCD_P);
-          return d;
-        }
-        return fin_ezgcd( F, G, b, true );
-    }
-    DEBOUTLN( cerr, "fin_ezgcdspec: (S1) done, Ft = " << Ft );
-    L = F / Ft;
-    /// ---> S2
-    DEBOUTLN( cerr, "fin_ezgcdspec: (S2)" );
-    L = fin_ezgcd( L, G, b, true );
-    DEBOUTLN( cerr, "fin_ezgcdspec: (S2) done, Ds = " << Ds );
-    Gt = G / L;
-    Ds = L; Dt = L;
-    Lb = b( L ); Gb = b( Gt ); Fb = b( Ft );
-    d = gcd( LC( L, x ), gcd( LC( Ft, x ), LC( Gt, x ) ) );
-    while ( true ) {
-        /// ---> S3
-        DEBOUTLN( cerr, "fin_ezgcdspec: (S3)" );
-        DEBOUTLN( cerr, "fin_ezgcdspec: Fb = " << Fb );
-        DEBOUTLN( cerr, "fin_ezgcdspec: Gb = " << Gb );
-        DD[1] = gcd( Lb, gcd( Fb, Gb ) );
-        /// ---> S4
-        DEBOUTLN( cerr, "fin_ezgcdspec: (S4)" );
-        if ( degree( DD[1] ) == 0 )
-            return Ds;
-        /// ---> S5
-        DEBOUTLN( cerr, "fin_ezgcdspec: (S5)" );
-        DEBOUTLN( cerr, "fin_ezgcdspec: Lb = " << Lb );
-        DEBOUTLN( cerr, "fin_ezgcdspec: Db = " << DD[1] );
-        Db = DD[1];
-        if ( ! (DD[2] = Lb/DD[1]).isOne() ) {
-            DEBOUTLN( cerr, "fin_ezgcdspec: (S55)" );
-            lcDD[2] = LC( L, x );
-            lcDD[1] = d;
-            DD[1] = ( DD[1] * b( d ) ) / lc( DD[1] );
-            DD[2] = ( DD[2] * b( lcDD[2] ) ) / lc( DD[2] );
-            LL = L * d;
-            DEBOUTLN( cerr, "fin_ezgcdspec: begin with lift." );
-            DEBOUTLN( cerr, "fin_ezgcdspec: B     = " << LL );
-            DEBOUTLN( cerr, "fin_ezgcdspec: DD    = " << DD );
-            DEBOUTLN( cerr, "fin_ezgcdspec: lcDD  = " << lcDD );
-            DEBOUTLN( cerr, "fin_ezgcdspec: b     = " << b );
-            DEBOUTLN( cerr, "fin_ezgcdspec: lc(B) = " << LC( LL, x ) );
-            DEBOUTLN( cerr, "fin_ezgcdspec: test  = " << b( LL ) - DD[1] * DD[2] );
-            gcdfound = Hensel( LL, DD, lcDD, b, p, x );
-            ASSERT( gcdfound, "fatal error in algorithm" );
-            Dt = pp( DD[1] );
-        }
-        DEBOUTLN( cerr, "fin_ezgcdspec: (S7)" );
-        Ds = Ds * Dt;
-        Fb = Fb / Db;
-        Gb = Gb / Db;
-    }
-    // this point is never reached, but to avoid compiler warnings let's return a value
-    return 0;
-#endif
 }
 
@@ -357,9 +282,11 @@
     DEBOUTLN( cerr, "fin_ezgcd: (fin_findeval) F = " << F  <<", G="<< G);
     DEBOUTLN( cerr, "fin_ezgcd: (fin_findeval) degF = " << degF << ", degG="<<degG );
-    while(1) {
+    while(1)
+    {
         DEBOUTLN( cerr, "fin_ezgcd: (fin_findeval) b = " << b );
         Fb = b( F );
         ok = degree( Fb ) == degF;
-        if ( ok ) {
+        if ( ok )
+        {
             Gb = b( G );
             ok = degree( Gb ) == degG;
Index: factory/int_int.cc
===================================================================
--- factory/int_int.cc	(revision 6840b2040b65b549b02b0e852339ab1a0a791484)
+++ factory/int_int.cc	(revision 1e6de686866af59b3d97fffef1d92033d15f47c6)
@@ -1,4 +1,4 @@
 /* emacs edit mode for this file is -*- C++ -*- */
-/* $Id: int_int.cc,v 1.19 2007-12-04 15:24:53 Singular Exp $ */
+/* $Id: int_int.cc,v 1.20 2008-01-07 13:33:10 Singular Exp $ */
 
 #include <config.h>
@@ -86,5 +86,6 @@
 InternalInteger::neg ()
 {
-    if ( getRefCount() > 1 ) {
+    if ( getRefCount() > 1 )
+    {
         decRefCount();
         MP_INT dummy;
@@ -92,5 +93,7 @@
         mpz_neg( &dummy, &dummy );
         return new InternalInteger( dummy );
-    } else {
+    }
+    else
+    {
         mpz_neg( &thempi, &thempi );
         return this;
@@ -102,10 +105,12 @@
 InternalCF* InternalInteger::addsame( InternalCF * c )
 {
-    if ( getRefCount() > 1 ) {
+    if ( getRefCount() > 1 )
+    {
         decRefCount();
         MP_INT dummy;
         mpz_init( &dummy );
         mpz_add( &dummy, &thempi, &MPI( c ) );
-        if ( mpz_is_imm( &dummy ) ) {
+        if ( mpz_is_imm( &dummy ) )
+        {
             InternalCF * res = int2imm( mpz_get_si( &dummy ) );
             mpz_clear( &dummy );
@@ -115,7 +120,9 @@
             return new InternalInteger( dummy );
     }
-    else {
+    else
+    {
         mpz_add( &thempi, &thempi, &MPI( c ) );
-        if ( mpz_is_imm( &thempi ) ) {
+        if ( mpz_is_imm( &thempi ) )
+        {
             InternalCF * res = int2imm( mpz_get_si( &thempi ) );
             delete this;
@@ -129,10 +136,12 @@
 InternalCF* InternalInteger::subsame( InternalCF * c )
 {
-    if ( getRefCount() > 1 ) {
+    if ( getRefCount() > 1 )
+    {
         decRefCount();
         MP_INT dummy;
         mpz_init( &dummy );
         mpz_sub( &dummy, &thempi, &MPI( c ) );
-        if ( mpz_is_imm( &dummy ) ) {
+        if ( mpz_is_imm( &dummy ) )
+        {
             InternalCF * res = int2imm( mpz_get_si( &dummy ) );
             mpz_clear( &dummy );
@@ -142,7 +151,9 @@
             return new InternalInteger( dummy );
     }
-    else {
+    else
+    {
         mpz_sub( &thempi, &thempi, &MPI( c ) );
-        if ( mpz_is_imm( &thempi ) ) {
+        if ( mpz_is_imm( &thempi ) )
+        {
             InternalCF * res = int2imm( mpz_get_si( &thempi ) );
             delete this;
@@ -156,10 +167,13 @@
 InternalCF* InternalInteger::mulsame( InternalCF * c )
 {
-    if ( getRefCount() > 1 ) {
+    if ( getRefCount() > 1 )
+    {
         decRefCount();
         MP_INT dummy;
         mpz_init( &dummy );
         mpz_mul( &dummy, &thempi, &MPI( c ) );
-        if ( mpz_is_imm( &dummy ) ) {
+        if ( mpz_is_imm( &dummy ) )
+        {
+        // can this happen ???
             InternalCF * res = int2imm( mpz_get_si( &dummy ) );
             mpz_clear( &dummy );
@@ -169,7 +183,10 @@
             return new InternalInteger( dummy );
     }
-    else {
+    else
+    {
         mpz_mul( &thempi, &thempi, &MPI( c ) );
-        if ( mpz_is_imm( &thempi ) ) {
+        if ( mpz_is_imm( &thempi ) )
+        {
+        // can this happen ???
             InternalCF * res = int2imm( mpz_get_si( &thempi ) );
             delete this;
@@ -202,5 +219,6 @@
     ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" );
     int cc = imm2int( c );
-    if ( getRefCount() > 1 ) {
+    if ( getRefCount() > 1 )
+    {
         decRefCount();
         MP_INT dummy;
@@ -210,5 +228,6 @@
         else
             mpz_add_ui( &dummy, &thempi, cc );
-        if ( mpz_is_imm( &dummy ) ) {
+        if ( mpz_is_imm( &dummy ) )
+        {
             InternalCF * res = int2imm( mpz_get_si( &dummy ) );
             mpz_clear( &dummy );
Index: factory/int_poly.cc
===================================================================
--- factory/int_poly.cc	(revision 6840b2040b65b549b02b0e852339ab1a0a791484)
+++ factory/int_poly.cc	(revision 1e6de686866af59b3d97fffef1d92033d15f47c6)
@@ -1,4 +1,4 @@
 /* emacs edit mode for this file is -*- C++ -*- */
-/* $Id: int_poly.cc,v 1.19 2006-09-15 10:15:48 Singular Exp $ */
+/* $Id: int_poly.cc,v 1.20 2008-01-07 13:33:10 Singular Exp $ */
 
 #include <config.h>
@@ -1140,10 +1140,12 @@
     if ( aTermList == 0 )
         return 0;
-    else  if ( negate ) {
+    else  if ( negate )
+    {
         termList sourceCursor = aTermList;
         termList dummy = new term;
         termList targetCursor = dummy;
 
-        while ( sourceCursor ) {
+        while ( sourceCursor )
+        {
             targetCursor->next = new term( 0, -sourceCursor->coeff, sourceCursor->exp );
             targetCursor = targetCursor->next;
@@ -1156,10 +1158,12 @@
         return targetCursor;
     }
-    else {
+    else
+    {
         termList sourceCursor = aTermList;
         termList dummy = new term;
         termList targetCursor = dummy;
 
-        while ( sourceCursor ) {
+        while ( sourceCursor )
+        {
             targetCursor->next = new term( 0, sourceCursor->coeff, sourceCursor->exp );
             targetCursor = targetCursor->next;
@@ -1179,10 +1183,12 @@
     if ( aTermList == 0 )
         return 0;
-    else {
+    else
+    {
         termList sourceCursor = aTermList;
         termList dummy = new term;
         termList targetCursor = dummy;
 
-        while ( sourceCursor ) {
+        while ( sourceCursor )
+        {
             targetCursor->next = new term( 0, sourceCursor->coeff.deepCopy(), sourceCursor->exp );
             targetCursor = targetCursor->next;
@@ -1202,5 +1208,6 @@
     termList cursor = aTermList;
 
-    while ( cursor ) {
+    while ( cursor )
+    {
         cursor = cursor->next;
         delete aTermList;
@@ -1213,5 +1220,6 @@
 {
     termList cursor = terms;
-    while ( cursor ) {
+    while ( cursor )
+    {
         cursor->coeff = -cursor->coeff;
         cursor = cursor->next;
@@ -1226,17 +1234,22 @@
     termList predCursor = 0;
 
-    while ( theCursor && aCursor ) {
-        if ( theCursor->exp == aCursor->exp ) {
+    while ( theCursor && aCursor )
+    {
+        if ( theCursor->exp == aCursor->exp )
+        {
             if ( negate )
                 theCursor->coeff -= aCursor->coeff;
             else
                 theCursor->coeff += aCursor->coeff;
-            if ( theCursor->coeff.isZero() ) {
-                if ( predCursor ) {
+            if ( theCursor->coeff.isZero() )
+            {
+                if ( predCursor )
+                {
                     predCursor->next = theCursor->next;
                     delete theCursor;
                     theCursor = predCursor->next;
                 }
-                else {
+                else
+                {
                     theList = theList->next;
                     delete theCursor;
@@ -1244,5 +1257,6 @@
                 }
             }
-            else {
+            else
+            {
                 predCursor = theCursor;
                 theCursor = theCursor->next;
@@ -1250,20 +1264,25 @@
             aCursor = aCursor->next;
         }
-        else if ( theCursor->exp < aCursor->exp ) {
+        else if ( theCursor->exp < aCursor->exp )
+        {
             if ( negate )
-                if ( predCursor ) {
+                if ( predCursor )
+                {
                     predCursor->next = new term( theCursor, -aCursor->coeff, aCursor->exp );
                     predCursor = predCursor->next;
                 }
-                else {
+                else
+                {
                     theList = new term( theCursor, -aCursor->coeff, aCursor->exp );
                     predCursor = theList;
                 }
             else
-                if ( predCursor ) {
+                if ( predCursor )
+                {
                     predCursor->next = new term( theCursor, aCursor->coeff, aCursor->exp );
                     predCursor = predCursor->next;
                 }
-                else {
+                else
+                {
                     theList = new term( theCursor, aCursor->coeff, aCursor->exp );
                     predCursor = theList;
@@ -1271,10 +1290,12 @@
             aCursor = aCursor->next;
         }
-        else {
+        else
+        {
             predCursor = theCursor;
             theCursor = theCursor->next;
         }
     }
-    if ( aCursor ) {
+    if ( aCursor )
+    {
         if ( predCursor )
             predCursor->next = copyTermList( aCursor, lastTerm, negate );
@@ -1291,5 +1312,6 @@
 InternalPoly::mulTermList ( termList theCursor, const CanonicalForm& coeff, const int exp )
 {
-    while ( theCursor ) {
+    while ( theCursor )
+    {
         theCursor->coeff *= coeff;
         theCursor->exp += exp;
@@ -1305,7 +1327,9 @@
     termList dummy;
 
-    while ( theCursor ) {
+    while ( theCursor )
+    {
         theCursor->coeff /= coeff;
-        if ( theCursor->coeff.isZero() ) {
+        if ( theCursor->coeff.isZero() )
+        {
             if ( theCursor == firstTerm )
                 firstTerm = theCursor->next;
@@ -1316,5 +1340,6 @@
             delete dummy;
         }
-        else {
+        else
+        {
             lastTerm = theCursor;
             theCursor = theCursor->next;
@@ -1331,7 +1356,9 @@
     termList dummy;
 
-    while ( theCursor ) {
+    while ( theCursor )
+    {
         theCursor->coeff.div( coeff );
-        if ( theCursor->coeff.isZero() ) {
+        if ( theCursor->coeff.isZero() )
+        {
             if ( theCursor == firstTerm )
                 firstTerm = theCursor->next;
@@ -1342,5 +1369,6 @@
             delete dummy;
         }
-        else {
+        else
+        {
             lastTerm = theCursor;
             theCursor = theCursor->next;
@@ -1357,7 +1385,9 @@
     termList dummy;
 
-    while ( theCursor ) {
+    while ( theCursor )
+    {
         theCursor->coeff.mod( coeff );
-        if ( theCursor->coeff.isZero() ) {
+        if ( theCursor->coeff.isZero() )
+        {
             if ( theCursor == firstTerm )
                 firstTerm = theCursor->next;
@@ -1368,5 +1398,6 @@
             delete dummy;
         }
-        else {
+        else
+        {
             lastTerm = theCursor;
             theCursor = theCursor->next;
@@ -1379,9 +1410,11 @@
 InternalPoly::appendTermList ( termList& first, termList& last, const CanonicalForm& coeff, const int exp )
 {
-    if ( last ) {
+    if ( last )
+    {
         last->next = new term( 0, coeff, exp );
         last = last->next;
     }
-    else {
+    else
+    {
         first = new term( 0, coeff, exp );
         last = first;
@@ -1402,14 +1435,19 @@
         coeff = c;
 
-    while ( theCursor && aCursor ) {
-        if ( theCursor->exp == aCursor->exp + exp ) {
+    while ( theCursor && aCursor )
+    {
+        if ( theCursor->exp == aCursor->exp + exp )
+        {
             theCursor->coeff += aCursor->coeff * coeff;
-            if ( theCursor->coeff.isZero() ) {
-                if ( predCursor ) {
+            if ( theCursor->coeff.isZero() )
+            {
+                if ( predCursor )
+                {
                     predCursor->next = theCursor->next;
                     delete theCursor;
                     theCursor = predCursor->next;
                 }
-                else {
+                else
+                {
                     theList = theList->next;
                     delete theCursor;
@@ -1417,5 +1455,6 @@
                 }
             }
-            else {
+            else
+            {
                 predCursor = theCursor;
                 theCursor = theCursor->next;
@@ -1423,10 +1462,13 @@
             aCursor = aCursor->next;
         }
-        else if ( theCursor->exp < aCursor->exp + exp ) {
-            if ( predCursor ) {
+        else if ( theCursor->exp < aCursor->exp + exp )
+        {
+            if ( predCursor )
+            {
                 predCursor->next = new term( theCursor, aCursor->coeff * coeff, aCursor->exp + exp );
                 predCursor = predCursor->next;
             }
-            else {
+            else
+            {
                 theList = new term( theCursor, aCursor->coeff * coeff, aCursor->exp + exp );
                 predCursor = theList;
@@ -1434,19 +1476,24 @@
             aCursor = aCursor->next;
         }
-        else {
+        else
+        {
             predCursor = theCursor;
             theCursor = theCursor->next;
         }
     }
-    if ( aCursor ) {
-        if ( predCursor ) {
+    if ( aCursor )
+    {
+        if ( predCursor )
+        {
             predCursor->next = copyTermList( aCursor, lastTerm );
             predCursor = predCursor->next;
         }
-        else {
+        else
+        {
             theList = copyTermList( aCursor, lastTerm );
             predCursor = theList;
         }
-        while ( predCursor ) {
+        while ( predCursor )
+        {
             predCursor->exp += exp;
             predCursor->coeff *= coeff;
@@ -1467,5 +1514,6 @@
     int exp = redterms->exp;
     termList dummy;
-    while ( first && ( first->exp >= exp ) ) {
+    while ( first && ( first->exp >= exp ) )
+    {
         newcoeff = first->coeff / coeff;
         newexp = first->exp - exp;
Index: factory/int_rat.cc
===================================================================
--- factory/int_rat.cc	(revision 6840b2040b65b549b02b0e852339ab1a0a791484)
+++ factory/int_rat.cc	(revision 1e6de686866af59b3d97fffef1d92033d15f47c6)
@@ -1,4 +1,4 @@
 /* emacs edit mode for this file is -*- C++ -*- */
-/* $Id: int_rat.cc,v 1.14 2007-12-04 15:24:53 Singular Exp $ */
+/* $Id: int_rat.cc,v 1.15 2008-01-07 13:33:11 Singular Exp $ */
 
 #include <config.h>
@@ -21,5 +21,6 @@
     int c;
 
-    while ( b != 0 ) {
+    while ( b != 0 )
+    {
         c = a % b;
         a = b;
@@ -45,15 +46,19 @@
 {
     ASSERT( d != 0, "divide by zero" );
-    if ( n == 0 ) {
+    if ( n == 0 )
+    {
         mpz_init_set_si( &_num, 0 );
         mpz_init_set_si( &_den, 1 );
     }
-    else {
+    else
+    {
         int g = intgcd( n, d );
-        if ( d < 0 ) {
+        if ( d < 0 )
+        {
             mpz_init_set_si( &_num, -n / g );
             mpz_init_set_si( &_den, -d / g );
         }
-        else {
+        else
+        {
             mpz_init_set_si( &_num, n / g );
             mpz_init_set_si( &_den, d / g );
@@ -133,9 +138,11 @@
 InternalCF * InternalRational::num ()
 {
-    if ( mpz_is_imm( &_num ) ) {
+    if ( mpz_is_imm( &_num ) )
+    {
         InternalCF * res = int2imm( mpz_get_si( &_num ) );
         return res;
     }
-    else {
+    else
+    {
         MP_INT dummy;
         mpz_init_set( &dummy, &_num );
@@ -146,9 +153,11 @@
 InternalCF * InternalRational::den ()
 {
-    if ( mpz_is_imm( &_den ) ) {
+    if ( mpz_is_imm( &_den ) )
+    {
         InternalCF * res = int2imm( mpz_get_si( &_den ) );
         return res;
     }
-    else {
+    else
+    {
         MP_INT dummy;
         mpz_init_set( &dummy, &_den );
@@ -163,5 +172,6 @@
 InternalRational::neg ()
 {
-    if ( getRefCount() > 1 ) {
+    if ( getRefCount() > 1 )
+    {
         decRefCount();
         MP_INT dummy_num;
@@ -171,5 +181,7 @@
         mpz_neg( &dummy_num, &dummy_num );
         return new InternalRational( dummy_num, dummy_den );
-    } else {
+    }
+    else
+    {
         mpz_neg( &_num, &_num );
         return this;
@@ -186,5 +198,6 @@
     mpz_gcd( &g, &_den, &MPQDEN( c ) );
 
-    if ( mpz_cmp_si( &g, 1 ) == 0 ) {
+    if ( mpz_cmp_si( &g, 1 ) == 0 )
+    {
         mpz_mul( &n, &_den, &MPQNUM( c ) );
         mpz_mul( &g, &_num, &MPQDEN( c ) );
@@ -192,5 +205,6 @@
         mpz_mul( &d, &_den, &MPQDEN( c ) );
     }
-    else {
+    else
+    {
         MP_INT tmp1;
         MP_INT tmp2;
@@ -204,5 +218,6 @@
         mpz_add( &n, &tmp1, &tmp2 );
         mpz_gcd( &g, &n, &d );
-        if ( mpz_cmp_si( &g, 1 ) != 0 ) {
+        if ( mpz_cmp_si( &g, 1 ) != 0 )
+        {
             mpz_div( &n, &n, &g );
             mpz_div( &d, &d, &g );
@@ -213,11 +228,14 @@
     mpz_clear( &g );
     if ( deleteObject() ) delete this;
-    if ( mpz_cmp_si( &d, 1 ) == 0 ) {
-        if ( mpz_is_imm( &n ) ) {
+    if ( mpz_cmp_si( &d, 1 ) == 0 )
+    {
+        if ( mpz_is_imm( &n ) )
+        {
             InternalCF * res = int2imm( mpz_get_si( &n ) );
             mpz_clear( &n ); mpz_clear( &d );
             return res;
         }
-        else {
+        else
+        {
             mpz_clear( &d );
             return new InternalInteger( n );
@@ -236,5 +254,6 @@
     mpz_gcd( &g, &_den, &MPQDEN( c ) );
 
-    if ( mpz_cmp_si( &g, 1 ) == 0 ) {
+    if ( mpz_cmp_si( &g, 1 ) == 0 )
+    {
         mpz_mul( &n, &_den, &MPQNUM( c ) );
         mpz_mul( &g, &_num, &MPQDEN( c ) );
@@ -242,5 +261,6 @@
         mpz_mul( &d, &_den, &MPQDEN( c ) );
     }
-    else {
+    else
+    {
         MP_INT tmp1;
         MP_INT tmp2;
@@ -254,5 +274,6 @@
         mpz_sub( &n, &tmp2, &tmp1 );
         mpz_gcd( &g, &n, &d );
-        if ( mpz_cmp_si( &g, 1 ) != 0 ) {
+        if ( mpz_cmp_si( &g, 1 ) != 0 )
+        {
             mpz_div( &n, &n, &g );
             mpz_div( &d, &d, &g );
@@ -263,11 +284,14 @@
     mpz_clear( &g );
     if ( deleteObject() ) delete this;
-    if ( mpz_cmp_si( &d, 1 ) == 0 ) {
-        if ( mpz_is_imm( &n ) ) {
+    if ( mpz_cmp_si( &d, 1 ) == 0 )
+    {
+        if ( mpz_is_imm( &n ) )
+        {
             InternalCF * res = int2imm( mpz_get_si( &n ) );
             mpz_clear( &n ); mpz_clear( &d );
             return res;
         }
-        else {
+        else
+        {
             mpz_clear( &d );
             return new InternalInteger( n );
@@ -283,10 +307,12 @@
     MP_INT n, d;
 
-    if ( this == c ) {
+    if ( this == c )
+    {
         mpz_init( &n ); mpz_init( &d );
         mpz_mul( &n, &_num, &_num );
         mpz_mul( &d, &_den, &_den );
     }
-    else {
+    else
+    {
         MP_INT g1, g2, tmp1, tmp2;
         mpz_init( &g1 ); mpz_init( &g2 );
@@ -319,11 +345,14 @@
     }
     if ( deleteObject() ) delete this;
-    if ( mpz_cmp_si( &d, 1 ) == 0 ) {
-        if ( mpz_is_imm( &n ) ) {
+    if ( mpz_cmp_si( &d, 1 ) == 0 )
+    {
+        if ( mpz_is_imm( &n ) )
+        {
             InternalCF * res = int2imm( mpz_get_si( &n ) );
             mpz_clear( &n ); mpz_clear( &d );
             return res;
         }
-        else {
+        else
+        {
             mpz_clear( &d );
             return new InternalInteger( n );
@@ -338,9 +367,11 @@
     ASSERT( ! ::is_imm( c ) && c->levelcoeff() == RationalDomain, "illegal domain" );
 
-    if ( this == c ) {
+    if ( this == c )
+    {
         if ( deleteObject() ) delete this;
         return CFFactory::basic( 1 );
     }
-    else {
+    else
+    {
         MP_INT n, d;
         MP_INT g1, g2, tmp1, tmp2;
@@ -377,11 +408,14 @@
             mpz_neg( &n, &n );
         }
-        if ( mpz_cmp_si( &d, 1 ) == 0 ) {
-            if ( mpz_is_imm( &n ) ) {
+        if ( mpz_cmp_si( &d, 1 ) == 0 )
+        {
+            if ( mpz_is_imm( &n ) )
+            {
                 InternalCF * res = int2imm( mpz_get_si( &n ) );
                 mpz_clear( &n ); mpz_clear( &d );
                 return res;
             }
-            else {
+            else
+            {
                 mpz_clear( &d );
                 return new InternalInteger( n );
@@ -456,5 +490,6 @@
 InternalRational::comparecoeff ( InternalCF* c )
 {
-    if ( ::is_imm( c ) ) {
+    if ( ::is_imm( c ) )
+    {
         ASSERT( ::is_imm( c ) == INTMARK, "incompatible base coefficients" );
         MP_INT dummy;
@@ -465,5 +500,6 @@
         return result;
     }
-    else {
+    else
+    {
         ASSERT( c->levelcoeff() == IntegerDomain, "incompatible base coefficients" );
         MP_INT dummy;
@@ -481,14 +517,17 @@
     ASSERT( ::is_imm( c ) == INTMARK || ! ::is_imm( c ), "expected integer" );
     MP_INT n, d;
-    if ( ::is_imm( c ) ) {
+    if ( ::is_imm( c ) )
+    {
         int cc = imm2int( c );
         if ( cc == 0 )
             return this;
-        else  if ( cc < 0 ) {
+        else  if ( cc < 0 )
+        {
             mpz_init( &n );
             mpz_mul_ui( &n, &_den, -cc );
             mpz_sub( &n, &_num, &n );
         }
-        else {
+        else
+        {
             mpz_init( &n );
             mpz_mul_ui( &n, &_den, cc );
@@ -496,5 +535,6 @@
         }
     }
-    else {
+    else
+    {
         ASSERT( c->levelcoeff() == IntegerDomain, "expected integer" );
         mpz_init( &n );
@@ -512,13 +552,17 @@
     ASSERT( ::is_imm( c ) == INTMARK || ! ::is_imm( c ), "expected integer" );
     MP_INT n, d;
-    if ( ::is_imm( c ) ) {
+    if ( ::is_imm( c ) )
+    {
         int cc = imm2int( c );
         if ( cc == 0 )
-            if ( negate ) {
-                if ( getRefCount() == 1 ) {
+            if ( negate )
+            {
+                if ( getRefCount() == 1 )
+                {
                     mpz_neg( &_num, &_num );
                     return this;
                 }
-                else {
+                else
+                {
                     decRefCount();
                     mpz_init_set( &d, &_den );
@@ -531,5 +575,6 @@
                 return this;
         mpz_init( &n );
-        if ( cc < 0 ) {
+        if ( cc < 0 )
+        {
             mpz_mul_ui( &n, &_den, -cc );
             mpz_neg( &n, &n );
@@ -542,5 +587,6 @@
             mpz_sub( &n, &_num, &n );
     }
-    else {
+    else
+    {
         ASSERT( c->levelcoeff() == IntegerDomain, "expected integer" );
         mpz_init( &n );
@@ -561,7 +607,9 @@
     ASSERT( ::is_imm( c ) == INTMARK || ! ::is_imm( c ), "expected integer" );
     MP_INT n, d, g;
-    if ( ::is_imm( c ) ) {
+    if ( ::is_imm( c ) )
+    {
         int cc = imm2int( c );
-        if ( cc == 0 ) {
+        if ( cc == 0 )
+        {
             if ( deleteObject() ) delete this;
             return CFFactory::basic( 0 );
@@ -569,5 +617,6 @@
         mpz_init_set_si( &n, cc );
     }
-    else {
+    else
+    {
         ASSERT( c->levelcoeff() == IntegerDomain, "expected integer" );
         mpz_init_set( &n, &InternalInteger::MPI( c ) );
@@ -575,9 +624,11 @@
     mpz_init( &g );
     mpz_gcd( &g, &n, &_den );
-    if ( mpz_cmp_si( &g, 1 ) == 0 ) {
+    if ( mpz_cmp_si( &g, 1 ) == 0 )
+    {
         mpz_mul( &n, &n, &_num );
         mpz_init_set( &d, &_den );
     }
-    else {
+    else
+    {
         mpz_div( &n, &n, &g );
         mpz_mul( &n, &n, &_num );
@@ -587,11 +638,14 @@
     mpz_clear( &g );
     if ( deleteObject() ) delete this;
-    if ( mpz_cmp_si( &d, 1 ) == 0 ) {
-        if ( mpz_is_imm( &n ) ) {
+    if ( mpz_cmp_si( &d, 1 ) == 0 )
+    {
+        if ( mpz_is_imm( &n ) )
+        {
             InternalCF * res = int2imm( mpz_get_si( &n ) );
             mpz_clear( &n ); mpz_clear( &d );
             return res;
         }
-        else {
+        else
+        {
             mpz_clear( &d );
             return new InternalInteger( n );
@@ -606,18 +660,22 @@
     ASSERT( ::is_imm( c ) == INTMARK || ! ::is_imm( c ), "expected integer" );
     MP_INT n, d, g;
-    if ( ::is_imm( c ) ) {
+    if ( ::is_imm( c ) )
+    {
         int cc = imm2int( c );
         ASSERT( c != 0 || invert, "divide by zero" );
-        if ( cc == 0 ) {
+        if ( cc == 0 )
+        {
             // => invert
             if ( deleteObject() ) delete this;
             return CFFactory::basic( 0 );
         }
-        if ( invert ) {
+        if ( invert )
+        {
             mpz_init_set_si( &n, cc );
             mpz_mul( &n, &n, &_den );
             mpz_init_set( &d, &_num );
         }
-        else {
+        else
+        {
             mpz_init_set_si( &d, cc );
             mpz_mul( &d, &d, &_den );
@@ -625,12 +683,15 @@
         }
     }
-    else {
+    else
+    {
         ASSERT( c->levelcoeff() == IntegerDomain, "expected integer" );
-        if ( invert ) {
+        if ( invert )
+        {
             mpz_init_set( &n, &InternalInteger::MPI( c ) );
             mpz_mul( &n, &n, &_den );
             mpz_init_set( &d, &_num );
         }
-        else {
+        else
+        {
             mpz_init_set( &d, &InternalInteger::MPI( c ) );
             mpz_mul( &d, &d, &_den );
@@ -638,5 +699,6 @@
         }
     }
-    if ( mpz_cmp_si( &d, 0 ) < 0 ) {
+    if ( mpz_cmp_si( &d, 0 ) < 0 )
+    {
         mpz_neg( &d, &d );
         mpz_neg( &n, &n );
@@ -644,5 +706,6 @@
     mpz_init( &g );
     mpz_gcd( &g, &n, &d );
-    if ( mpz_cmp_si( &g, 1 ) != 0 ) {
+    if ( mpz_cmp_si( &g, 1 ) != 0 )
+    {
         mpz_div( &d, &d, &g );
         mpz_div( &n, &n, &g );
@@ -650,15 +713,19 @@
     mpz_clear( &g );
     if ( deleteObject() ) delete this;
-    if ( ! invert ) {
+    if ( ! invert )
+    {
         // then there was no way for the result to become an integer
         return new InternalRational( n, d );
     }
-    if ( mpz_cmp_si( &d, 1 ) == 0 ) {
-        if ( mpz_is_imm( &n ) ) {
+    if ( mpz_cmp_si( &d, 1 ) == 0 )
+    {
+        if ( mpz_is_imm( &n ) )
+        {
             InternalCF * res = int2imm( mpz_get_si( &n ) );
             mpz_clear( &n ); mpz_clear( &d );
             return res;
         }
-        else {
+        else
+        {
             mpz_clear( &d );
             return new InternalInteger( n );
@@ -751,4 +818,5 @@
     }
     if ( mpz_cmp_si( &_den, 1 ) == 0 )
+    {
         if ( mpz_is_imm( &_num ) )
         {
@@ -764,4 +832,5 @@
             return new InternalInteger( res );
         }
+    }
     else
         return this;
