Index: Singular/ffields.cc
===================================================================
--- Singular/ffields.cc	(revision 537f9371dff741b30e45db9d08cd35ed20d5f36f)
+++ Singular/ffields.cc	(revision a5189bc0c3a81e46d3450fdaaeff50a529e8a5b7)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: ffields.cc,v 1.27 2000-10-19 15:00:11 obachman Exp $ */
+/* $Id: ffields.cc,v 1.28 2000-12-05 11:15:08 obachman Exp $ */
 /*
 * ABSTRACT: finite fields with a none-prime number of elements (via tables)
@@ -180,4 +180,7 @@
 number nfInit (int i)
 {
+  // Hmm .. this is just to prevent initialization
+  // from nfInitChar to go into an infinite loop
+  if (i==0) return (number)nfCharQ;
   while (i <  0)    i += nfCharP;
   while (i >= nfCharP) i -= nfCharP;
Index: Singular/mpsr_Get.cc
===================================================================
--- Singular/mpsr_Get.cc	(revision 537f9371dff741b30e45db9d08cd35ed20d5f36f)
+++ Singular/mpsr_Get.cc	(revision a5189bc0c3a81e46d3450fdaaeff50a529e8a5b7)
@@ -3,5 +3,5 @@
 ****************************************/
 
-/* $Id: mpsr_Get.cc,v 1.32 2000-08-14 12:56:42 obachman Exp $ */
+/* $Id: mpsr_Get.cc,v 1.33 2000-12-05 11:15:08 obachman Exp $ */
 /***************************************************************
  *
@@ -343,5 +343,5 @@
     }
 
-    mpsr_SetCurrRingHdl(mlv.r);
+    mpsr_SetCurrRingHdl(&mlv);
 
     lv = mlv.lv;
@@ -917,10 +917,10 @@
     if (status == mpsr_Success)
     {
-#ifdef MPSR_DEBUG
-      //command cmd = (command) mlv.lv->data;
-      //fprintf(stdout, "Dump got %s \n", cmd->arg1.name);
-      //fflush(stdout);
+#ifdef MPSR_DEBUG_DUMP
+      command cmd = (command) mlv.lv->data;
+      fprintf(stdout, "Dump got %s \n", cmd->arg1.name);
+      fflush(stdout);
 #endif
-      mpsr_SetCurrRingHdl(mlv.r);
+      mpsr_SetCurrRingHdl(&mlv);
       if (mlv.lv != NULL)
       {
Index: Singular/mpsr_Get.h
===================================================================
--- Singular/mpsr_Get.h	(revision 537f9371dff741b30e45db9d08cd35ed20d5f36f)
+++ Singular/mpsr_Get.h	(revision a5189bc0c3a81e46d3450fdaaeff50a529e8a5b7)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: mpsr_Get.h,v 1.10 2000-08-14 12:56:42 obachman Exp $ */
+/* $Id: mpsr_Get.h,v 1.11 2000-12-05 11:15:09 obachman Exp $ */
 /***************************************************************
  *
@@ -52,5 +52,5 @@
 extern mpsr_Status_t mpsr_MergeLeftv(mpsr_leftv mlv1, mpsr_leftv mlv2);
 extern void mpsr_MapLeftv(leftv l, ring from_ring, ring to_ring);
-extern void mpsr_SetCurrRingHdl(ring r);
+extern void mpsr_SetCurrRingHdl(mpsr_leftv mlv);
 extern idhdl mpsr_FindIdhdl(char *name, ring &r);
 
Index: Singular/mpsr_GetMisc.cc
===================================================================
--- Singular/mpsr_GetMisc.cc	(revision 537f9371dff741b30e45db9d08cd35ed20d5f36f)
+++ Singular/mpsr_GetMisc.cc	(revision a5189bc0c3a81e46d3450fdaaeff50a529e8a5b7)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: mpsr_GetMisc.cc,v 1.21 2000-10-19 15:00:17 obachman Exp $ */
+/* $Id: mpsr_GetMisc.cc,v 1.22 2000-12-05 11:15:09 obachman Exp $ */
 
 /***************************************************************
@@ -283,7 +283,8 @@
 // if one is found, then this one is set to the new global ring
 // otherwise, a ring name is generated, and a new idhdl is created
-void mpsr_SetCurrRingHdl(ring r)
+void mpsr_SetCurrRingHdl(mpsr_leftv mlv)
 {
   idhdl h = IDROOT, rh = NULL;
+  ring r = mlv->r;
 
   if (r == NULL)
@@ -315,4 +316,8 @@
     if (currRingHdl != NULL && IDRING(currRingHdl) != currRing)
       mpsr_SetCurrRing(IDRING(currRingHdl), TRUE);
+
+    // reset debug field so that RingOfLm does not complain
+    // this does nothing on !PDEBUG
+    p_SetRingOfLeftv(mlv->lv, IDRING(rh));
 
     rSetHdl(rh, TRUE);
@@ -339,6 +344,6 @@
 
 
-int gringcounter = 0;
-char grname[14];
+static int gringcounter = 0;
+static char grname[14];
 
 static char* GenerateRingName()
Index: Singular/mpsr_Put.cc
===================================================================
--- Singular/mpsr_Put.cc	(revision 537f9371dff741b30e45db9d08cd35ed20d5f36f)
+++ Singular/mpsr_Put.cc	(revision a5189bc0c3a81e46d3450fdaaeff50a529e8a5b7)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: mpsr_Put.cc,v 1.22 2000-08-14 12:56:43 obachman Exp $ */
+/* $Id: mpsr_Put.cc,v 1.23 2000-12-05 11:15:09 obachman Exp $ */
 
 /***************************************************************
@@ -570,6 +570,6 @@
     {
       failr(mpsr_PutLeftv(link, (leftv) h, NULL));
-#ifdef MPSR_DEBUG
-      //Print("Dumped Proc %s\n", IDID(h));
+#ifdef MPSR_DEBUG_DUMP
+      Print("Dumped Proc %s\n", IDID(h));
 #endif
     }
@@ -601,6 +601,6 @@
 #endif
 
-#ifdef MPSR_DEBUG
-      //Print("Dumped %s\n", IDID(h));
+#ifdef MPSR_DEBUG_DUMP
+      Print("Dumped %s\n", IDID(h));
 #endif
       if (IDTYP(h) == RING_CMD || IDTYP(h) == QRING_CMD ||
@@ -643,6 +643,6 @@
           if (mpsr_PutLeftv(link, lv, r) != mpsr_Success) break;
 #endif
-#ifdef MPSR_DEBUG
-          //Print("Dumped %s\n", IDID(h2));
+#ifdef MPSR_DEBUG_DUMP
+          Print("Dumped %s\n", IDID(h2));
 #endif
           h2 = h2->next;
Index: Singular/pDebug.cc
===================================================================
--- Singular/pDebug.cc	(revision 537f9371dff741b30e45db9d08cd35ed20d5f36f)
+++ Singular/pDebug.cc	(revision a5189bc0c3a81e46d3450fdaaeff50a529e8a5b7)
@@ -7,5 +7,5 @@
  *  Author:  obachman (Olaf Bachmann)
  *  Created: 8/00
- *  Version: $Id: pDebug.cc,v 1.15 2000-11-17 14:07:12 Singular Exp $
+ *  Version: $Id: pDebug.cc,v 1.16 2000-12-05 11:15:09 obachman Exp $
  *******************************************************************/
 
@@ -356,5 +356,91 @@
         pDivisibleBy_ShortFalse, (unsigned long) ((double)pDivisibleBy_ShortFalse*((double)100)/(double)pDivisibleBy_FALSE));
 }
-#endif
+
+#if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM)
+
+#include "ideals.h"
+#include "lists.h"
+#include "ipid.h"
+
+
+void p_SetRingOfPoly(poly p, ring r)
+{
+  while (p != NULL)
+  {
+    p_SetRingOfLm(p, r);
+    pIter(p);
+  }
+}
+
+void p_SetRingOfIdeal(ideal id, ring r)
+{
+  if (id == NULL) return;
+  
+  int i, n = id->ncols*id->nrows;
+  
+  for (i=0; i<n; i++)
+  {
+    p_SetRingOfPoly(id->m[i], r);
+  }
+}
+
+void p_SetRingOfList(lists L, ring r)
+{
+  int i;
+  for (i=0; i<L->nr; i++)
+  {
+    p_SetRingOfLeftv(&(L->m[i]), r);
+  }
+}
+
+void p_SetRingOfCommand(command cmd, ring r)
+{
+  if (cmd->op == PROC_CMD && cmd->argc == 2)
+    p_SetRingOfLeftv(&(cmd->arg2), r);
+  else if (cmd->argc > 0)
+  {
+    p_SetRingOfLeftv(&(cmd->arg1), r);
+    if (cmd->argc > 1)
+    {
+      p_SetRingOfLeftv(&(cmd->arg2), r);
+      if (cmd->argc > 2)
+        p_SetRingOfLeftv(&(cmd->arg3), r);
+    }
+  }
+}
+
+void p_SetRingOfLeftv(leftv l, ring r)
+{
+  while (l != NULL)
+  {
+    switch(l->rtyp)
+    {
+        case POLY_CMD:
+        case VECTOR_CMD:
+          p_SetRingOfPoly((poly) l->data, r);  
+      break;
+
+      case IDEAL_CMD:
+      case MODUL_CMD:
+      case MATRIX_CMD:
+      case MAP_CMD:
+        p_SetRingOfIdeal((ideal) l->data, r);
+        break;
+
+        case LIST_CMD:
+          p_SetRingOfList((lists) l->data, r);
+          break;
+
+        case COMMAND:
+          p_SetRingOfCommand((command)l->data, r);
+        default:
+          break;
+    }
+    l = l->next;
+  }
+}
+#endif // (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM)
+
+#endif // PDEBUG
 
 #endif // PDEBUG_CC
Index: Singular/polys-impl.h
===================================================================
--- Singular/polys-impl.h	(revision 537f9371dff741b30e45db9d08cd35ed20d5f36f)
+++ Singular/polys-impl.h	(revision a5189bc0c3a81e46d3450fdaaeff50a529e8a5b7)
@@ -4,5 +4,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: polys-impl.h,v 1.61 2000-11-03 14:50:22 obachman Exp $ */
+/* $Id: polys-impl.h,v 1.62 2000-12-05 11:15:10 obachman Exp $ */
 
 /***************************************************************
@@ -159,7 +159,9 @@
 #define pFalseReturn(cond)  do {if (! (cond)) return FALSE;} while (0)
 #if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM)
-#define p_SetRingOfPoly(p, r) omSetCustomOfAddr(p, r)
-#else
-#define p_SetRingOfPoly(p, r) ((void)0)
+#define p_SetRingOfLm(p, r) omSetCustomOfAddr(p, r)
+void p_SetRingOfLeftv(leftv l, ring r);
+#else
+#define p_SetRingOfLm(p, r) ((void)0)
+#define p_SetRingOfLeftv(l, r) ((void)0)
 #endif
 
@@ -172,5 +174,6 @@
 #define pPolyAssumeReturn(cond)      ((void)0)
 #define _pPolyAssumeReturn(cond,p,r) ((void)0)
-#define p_SetRingOfPoly(p, r)        ((void)0)
+#define p_SetRingOfLm(p, r)          ((void)0)
+#define p_SetRingOfLeftv(l, r)       ((void)0)
 #endif // defined(PDEBUG)
 
@@ -243,5 +246,5 @@
 {                                               \
   omTypeAllocBin(poly, p, bin);                 \
-  p_SetRingOfPoly(p, r);                        \
+  p_SetRingOfLm(p, r);                        \
 }                                               \
 while (0)
