Index: Singular/kstdfac.cc
===================================================================
--- Singular/kstdfac.cc	(revision af191b958ee3fe3243b1c9364cbf7700930e02ba)
+++ Singular/kstdfac.cc	(revision 2753974d7f92c0c2a946d0bfae76c8bdf508b628)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: kstdfac.cc,v 1.15 1998-04-07 17:00:59 Singular Exp $ */
+/* $Id: kstdfac.cc,v 1.16 1998-04-08 16:04:24 Singular Exp $ */
 /*
 *  ABSTRACT -  Kernel: factorizing alg. of Buchberger
@@ -464,5 +464,6 @@
     }
     /* reduction of the element choosen from L */
-    strat->red(&strat->P,strat);
+    if (strat->P.p != NULL)
+      strat->red(&strat->P,strat);
     if (strat->P.p != NULL)
     {
Index: Singular/kutil.cc
===================================================================
--- Singular/kutil.cc	(revision af191b958ee3fe3243b1c9364cbf7700930e02ba)
+++ Singular/kutil.cc	(revision 2753974d7f92c0c2a946d0bfae76c8bdf508b628)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: kutil.cc,v 1.15 1998-04-06 17:59:32 obachman Exp $ */
+/* $Id: kutil.cc,v 1.16 1998-04-08 16:04:25 Singular Exp $ */
 /*
 * ABSTRACT: kernel: utils for std
@@ -200,5 +200,5 @@
 *utilities for TSet, LSet
 */
-inline intset initec (int maxnr)
+inline static intset initec (int maxnr)
 {
   return (intset)Alloc(maxnr*sizeof(int));
@@ -434,5 +434,5 @@
 
 /*2
-*cancels the i-th polynomial in the set
+*cancels the j-th polynomial in the set
 */
 void deleteInL (LSet set, int *length, int j,kStrategy strat)
@@ -449,5 +449,21 @@
       /*- tail belongs to several int spolys -*/
     }
-    else pDelete(&(set[j].p));
+    else 
+    {
+      // search p in T, if it is there, do not delete it
+      int i=strat->tl;
+      poly p=set[j].p;
+      while (i>=0)
+      {
+        if (strat->T[i].p==p)
+	{
+          p=NULL;
+	  break;
+	}
+	i--;
+      }
+      if (p!=NULL) pDelete(&p);
+      set[j].p=NULL;
+    }  
   }
   if ((*length)>0)
@@ -3372,9 +3388,11 @@
   if (strat->sl == IDELEMS(strat->Shdl)-1)
   {
-    strat->ecartS = (intset)ReAlloc(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int),
+    strat->ecartS = (intset)ReAlloc(strat->ecartS,
+                                    IDELEMS(strat->Shdl)*sizeof(int),
                                     (IDELEMS(strat->Shdl)+setmax)*sizeof(int));
     if (strat->fromQ!=NULL)
     {
-      strat->fromQ = (intset)ReAlloc(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int),
+      strat->fromQ = (intset)ReAlloc(strat->fromQ,
+                                    IDELEMS(strat->Shdl)*sizeof(int),
                                     (IDELEMS(strat->Shdl)+setmax)*sizeof(int));
     }
Index: Singular/maps.cc
===================================================================
--- Singular/maps.cc	(revision af191b958ee3fe3243b1c9364cbf7700930e02ba)
+++ Singular/maps.cc	(revision 2753974d7f92c0c2a946d0bfae76c8bdf508b628)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: maps.cc,v 1.7 1998-01-12 18:59:50 obachman Exp $ */
+/* $Id: maps.cc,v 1.8 1998-04-08 16:04:28 Singular Exp $ */
 /*
 * ABSTRACT - the mapping of polynomials to other rings
@@ -199,6 +199,5 @@
   }
   ordersize=i+1;
-  wv = (short **) Alloc(ordersize * sizeof(short **));
-  memset(wv,0,ordersize * sizeof(short **));
+  wv = (short **) Alloc0(ordersize * sizeof(short **));
   for (i--;i!=0 ;i--) wv[i+1] = sourcering->wvhdl[i];
   tmpR = *currRing;
Index: Singular/matpol.cc
===================================================================
--- Singular/matpol.cc	(revision af191b958ee3fe3243b1c9364cbf7700930e02ba)
+++ Singular/matpol.cc	(revision 2753974d7f92c0c2a946d0bfae76c8bdf508b628)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: matpol.cc,v 1.9 1998-02-18 11:35:31 siebert Exp $ */
+/* $Id: matpol.cc,v 1.10 1998-04-08 16:04:29 Singular Exp $ */
 
 /*
@@ -68,9 +68,9 @@
     rc->m = (polyset)Alloc0(s);
 #endif
-    if (rc->m==NULL)
-    {
-      Werror("internal error: creating matrix[%d][%d]",r,c);
-      return NULL;
-    }
+    //if (rc->m==NULL)
+    //{
+    //  Werror("internal error: creating matrix[%d][%d]",r,c);
+    //  return NULL;
+    //}
   }
   return rc;
@@ -725,13 +725,13 @@
   /* fill in the powers of x_var=h*/
   poly h=pOne();
-  for(k=1;k<=r; k++)
+  for(k=r;k>0; k--)
   {
     MATELEM(m,k,k*(p+1))=pOne();
   }
-  for(l=1;l<=p; l++)
+  for(l=p;l>0; l--)
   {
     pSetExp(h,var,l);
     pSetm(h);
-    for(k=1;k<=r; k++)
+    for(k=r;k>0; k--)
     {
       MATELEM(m,k,k*(p+1)-l)=pCopy(h);
@@ -892,5 +892,5 @@
 row_col_weight::~row_col_weight()
 {
-  if (ym)
+  if (ym!=0)
   {
     Free((ADDRESS)wcol, yn*sizeof(float));
Index: Singular/misc.cc
===================================================================
--- Singular/misc.cc	(revision af191b958ee3fe3243b1c9364cbf7700930e02ba)
+++ Singular/misc.cc	(revision 2753974d7f92c0c2a946d0bfae76c8bdf508b628)
@@ -719,4 +719,10 @@
               StringAppend("MDEBUG=%d,",MDEBUG);
 #endif
+#ifdef PDEBUG
+              StringAppend("PDEBUG,");
+#endif
+#ifdef KDEBUG
+              StringAppend("KDEBUG,");
+#endif
 #ifdef TEST_MAC_ORDER
               StringAppendS("mac_order,");
Index: Singular/polys.cc
===================================================================
--- Singular/polys.cc	(revision af191b958ee3fe3243b1c9364cbf7700930e02ba)
+++ Singular/polys.cc	(revision 2753974d7f92c0c2a946d0bfae76c8bdf508b628)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: polys.cc,v 1.21 1998-04-08 12:42:17 pohl Exp $ */
+/* $Id: polys.cc,v 1.22 1998-04-08 16:04:31 Singular Exp $ */
 
 /*
@@ -728,5 +728,5 @@
   for (i=0;i<length;i++)
   {
-    if (actHeads[i])
+    if (actHeads[i]!=NULL)
     {
       newOrder[i] = SchreyerOrd[pGetComp(actHeads[i])-1];
@@ -772,8 +772,8 @@
   int i;
   int* newOrder=
-    (int*)Alloc((length+maxSchreyer-indexShift)*sizeof(int));
-
-  for (i=0;i<length+maxSchreyer-indexShift;i++)
-    newOrder[i]=0;
+    (int*)Alloc0((length+maxSchreyer-indexShift)*sizeof(int));
+
+  //for (i=0;i<length+maxSchreyer-indexShift;i++)
+  //  newOrder[i]=0;
   for (i=indexShift;i<maxSchreyer;i++)
   {
@@ -832,5 +832,5 @@
     {
       indexShift = comps;
-      if (!indexShift) indexShift = 1;
+      if (indexShift==0) indexShift = 1;
       SchreyerOrd = (int*)Alloc((indexShift+length)*sizeof(int));
       maxSchreyer = length+indexShift;
@@ -1718,4 +1718,29 @@
 
 /*2
+* returns TRUE if the head term of b is a multiple of the head term of a
+*/
+#if defined(macintosh)
+BOOLEAN pDivisibleBy(poly a, poly b)
+{
+  if ((a!=NULL)&&(( pGetComp(a)==0) || ( pGetComp(a) ==  pGetComp(b))))
+  {
+    int i=pVariables;
+    Exponent_t *e1=&( pGetExp(a,1));
+    Exponent_t *e2=&( pGetExp(b,1));
+    if ((*e1) > (*e2)) return FALSE;
+    do
+    {
+      i--;
+      if (i == 0) return TRUE;
+      e1++;
+      e2++;
+     } while ((*e1) <= (*e2));
+   }
+   return FALSE;
+}
+#endif
+
+
+/*2
 * assumes that the head term of b is a multiple of the head term of a
 * and return the multiplicant *m
@@ -1908,9 +1933,9 @@
   number  nn;
 
-  P = (polyset)Alloc(5*sizeof(poly));
-  for (i=0; i<5; i++)
-  {
-    P[i] = NULL;
-  }
+  P = (polyset)Alloc0(5*sizeof(poly));
+  //for (i=0; i<5; i++)
+  //{
+  //  P[i] = NULL;
+  //}
   pCancelPolyByMonom(p1,p2,&P,&SizeOfSet);
   p = P[0];
Index: Singular/sing_dbm.cc
===================================================================
--- Singular/sing_dbm.cc	(revision af191b958ee3fe3243b1c9364cbf7700930e02ba)
+++ Singular/sing_dbm.cc	(revision 2753974d7f92c0c2a946d0bfae76c8bdf508b628)
@@ -5,5 +5,5 @@
 //**************************************************************************/
 //
-// $Id: sing_dbm.cc,v 1.8 1997-08-13 13:51:42 Singular Exp $
+// $Id: sing_dbm.cc,v 1.9 1998-04-08 16:04:32 Singular Exp $
 //
 //**************************************************************************/
@@ -53,6 +53,8 @@
     return TRUE;
   }
-  if (((db = (DBM_info *)Alloc(sizeof *db)) != NULL)
-  &&((db->db = dbm_open(l->name, dbm_flags, 0664 )) != NULL ))
+  //if (((db = (DBM_info *)Alloc(sizeof *db)) != NULL)
+  //&&((db->db = dbm_open(l->name, dbm_flags, 0664 )) != NULL ))
+  db = (DBM_info *)Alloc(sizeof *db);
+  if((db->db = dbm_open(l->name, dbm_flags, 0664 )) != NULL )
   {
     db->first=1;
