Index: kernel/polys1.cc
===================================================================
--- kernel/polys1.cc	(revision 61944d0a0689203f1f85c43b1610be266ec31371)
+++ kernel/polys1.cc	(revision 60933487e53ddb20e0e5d7d5ccc137ac53893f37)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: polys1.cc,v 1.32 2008-07-25 14:37:55 Singular Exp $ */
+/* $Id: polys1.cc,v 1.33 2009-02-26 11:14:16 levandov Exp $ */
 
 /*
@@ -26,4 +26,8 @@
 #ifdef HAVE_FACTORY
 #include "clapsing.h"
+#endif
+
+#ifdef HAVE_RATGRING
+#include "ratgring.h"
 #endif
 
@@ -1048,5 +1052,13 @@
     }
     if (h!=NULL) nDelete(&h);
-    pContent(ph);
+  
+#ifdef HAVE_RATGRING
+    if (rIsRatGRing(currRing))
+    {
+      pContentRat(ph);
+    }
+    else
+#endif
+      pContent(ph);
   }
 }
Index: kernel/ratgring.cc
===================================================================
--- kernel/ratgring.cc	(revision 61944d0a0689203f1f85c43b1610be266ec31371)
+++ kernel/ratgring.cc	(revision 60933487e53ddb20e0e5d7d5ccc137ac53893f37)
@@ -7,5 +7,5 @@
  *  Author:  levandov (Viktor Levandovsky)
  *  Created: 8/00 - 11/00
- *  Version: $Id: ratgring.cc,v 1.17 2009-02-25 17:01:00 Singular Exp $
+ *  Version: $Id: ratgring.cc,v 1.18 2009-02-26 11:14:16 levandov Exp $
  *******************************************************************/
 #include "mod2.h"
@@ -100,5 +100,4 @@
 }
 
-/* TO TEST!!! */
 /* returns x-coeff of p, i.e. a poly in x, s.t. corresponding xd-monomials 
 have the same D-part 
@@ -110,5 +109,5 @@
   poly q   = pNext(p);
   poly res; // = p_Head(p,r);
-  res = p_GetExp_k_n(p, ishift+1, r->N, r);
+  res = p_GetExp_k_n(p, ishift+1, r->N, r); // does pSetm internally
   p_SetCoeff(res,n_Copy(p_GetCoeff(p,r),r),r);
   poly s;
@@ -129,6 +128,5 @@
   p_LmCheckPolyRing2(*p, r);
   poly q = p_Head(*p,r);
-  // in the next line ishift is correct
-  while ( ( (*p)!=NULL ) && ( p_Comp_k_n(*p, q, ishift, r) ))
+  while ( ( (*p)!=NULL ) && ( p_Comp_k_n(*p, q, ishift+1, r) ))
   {
     p_LmDelete(p,r);
@@ -464,9 +462,9 @@
   id_Delete(&ncsyz,r);
 
-  p_LmDeleteAndNextRat(&p1, is+1, r); // t_f
-  p_LmDeleteAndNextRat(&HF, is+1, r); // r_f = h_f - lt_D(h_f)
-
-  p_LmDeleteAndNextRat(&p2, is+1, r); // t_g
-  p_LmDeleteAndNextRat(&HG, is+1, r); // r_g = h_g - lt_D(h_g)
+  p_LmDeleteAndNextRat(&p1, is, r); // t_f
+  p_LmDeleteAndNextRat(&HF, is, r); // r_f = h_f - lt_D(h_f)
+
+  p_LmDeleteAndNextRat(&p2, is, r); // t_g
+  p_LmDeleteAndNextRat(&HG, is, r); // r_g = h_g - lt_D(h_g)
 
 
@@ -506,5 +504,5 @@
 #endif
 
-  if ( out!=NULL ) pContent(out);
+  //  if ( out!=NULL ) pContent(out); // postponed to enterS
   return(out);
 }
@@ -560,5 +558,5 @@
   // alt:
   poly out = p_Copy(p1,r);
-  p_LmDeleteAndNextRat(&out, is+1, r); // out == t_g
+  p_LmDeleteAndNextRat(&out, is, r); // out == t_g
 
   ideal ncsyz = ncGCD(P,K,r);
@@ -572,6 +570,6 @@
 #endif
   id_Delete(&ncsyz,r);
-  p_LmDeleteAndNextRat(&p2, is+1, r); // t_f
-  p_LmDeleteAndNextRat(&H, is+1, r); // r_g = h_g - lt_D(h_g)
+  p_LmDeleteAndNextRat(&p2, is, r); // t_f
+  p_LmDeleteAndNextRat(&H, is, r); // r_g = h_g - lt_D(h_g)
 
 #ifdef PDEBUG
@@ -608,5 +606,5 @@
 #endif
 
-  if ( out!=NULL ) pContent(out);
+  //  if ( out!=NULL ) pContent(out); // postponed to enterS
   return(out);
 }
@@ -687,6 +685,6 @@
 }
 
-poly pContentRat(poly ph)
-// destroys ph
+void pContentRat(poly ph)
+// changes ph
 // for rat coefficients in K(x1,..xN)
 {
@@ -701,12 +699,13 @@
   int *L = (int *)omAlloc0((len+1)*sizeof(int));  //lengths of coeffs
   int k = 0;
-  poly p = ph;
+  poly p = pCopy(ph); // ph will be needed below
   int HasConstantCoef = 0;
   int mintdeg = pTotaldegree(p);
   int minlen = len;
+  int is = currRing->real_var_start - 1;
   while (p!=NULL)
   {
-    LM[k] = p_HeadRat(p, currRing->real_var_start, currRing); 
-    C[k] = p_GetCoeffRat(p, currRing->real_var_start, currRing);
+    LM[k] = p_GetExp_k_n(p,1,is,currRing); // need LmRat istead of  p_HeadRat(p, is, currRing); !
+    C[k] = p_GetCoeffRat(p, is, currRing);
     D[k] =  pTotaldegree(C[k]);
     mintdeg = si_min(mintdeg,D[k]);
@@ -719,5 +718,5 @@
       // smth like goto cleanup and return(pContent(p));
     }
-    p_LmDeleteAndNextRat(&p, currRing->real_var_start, currRing);
+    p_LmDeleteAndNextRat(&p, is, currRing);
     k++;
   }
@@ -734,5 +733,5 @@
       if (L[i] < mindeglen)
       {
-	mindeglen=L[i];
+        mindeglen=L[i];
         pmindeglen = i;
       }
@@ -759,5 +758,5 @@
         pDelete(&LM[k]);
       }
-      p=pContent(ph);
+      pContent(ph);
       goto cleanup;
     }
@@ -774,7 +773,9 @@
   for(i=0; i<=k; i++)
   {
-   p=pAdd(p,pMult(C[i],LM[i]));
+   p = pAdd(p, pMult(C[i],LM[i]) );
    C[i]=NULL; LM[i]=NULL;
   }
+  pDelete(&ph); // do not need it anymore
+  ph = p;
   // aufraeumen, return
 cleanup:
@@ -783,5 +784,4 @@
   omFree(D);
   omFree(L);
-  return p;
-}
-#endif
+}
+#endif
Index: kernel/ratgring.h
===================================================================
--- kernel/ratgring.h	(revision 61944d0a0689203f1f85c43b1610be266ec31371)
+++ kernel/ratgring.h	(revision 60933487e53ddb20e0e5d7d5ccc137ac53893f37)
@@ -4,5 +4,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: ratgring.h,v 1.9 2009-02-25 16:37:34 levandov Exp $ */
+/* $Id: ratgring.h,v 1.10 2009-02-26 11:14:16 levandov Exp $ */
 /*
 * ABSTRACT additional defines etc for --with-plural
@@ -12,4 +12,5 @@
 #ifdef HAVE_RATGRING
 #include "structs.h"
+#include "gring.h"
 
 /* MACROS */
@@ -114,5 +115,4 @@
 // Content stuff
 
-poly pInitContentRat_a(poly ph);
 void pContentRat(poly ph);
 
