Index: Singular/iparith.cc
===================================================================
--- Singular/iparith.cc	(revision c0eb11ed4b9c2fcf9078e34ece905585ee5ec7b2)
+++ Singular/iparith.cc	(revision 29d768383fe7ec64b0b6f904e4082d94b5a0cd82)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: iparith.cc,v 1.344 2005-04-13 16:43:12 Singular Exp $ */
+/* $Id: iparith.cc,v 1.345 2005-04-18 15:10:04 Singular Exp $ */
 
 /*
@@ -35,4 +35,5 @@
 #include "stairc.h"
 #include "maps.h"
+#include "maps_ip.h"
 #include "syz.h"
 #include "weight.h"
@@ -45,5 +46,5 @@
 #include "units.h"
 #include "janet.h"
-#include "../kernel/GMPrat.h"
+#include "GMPrat.h"
 #ifdef HAVE_FACTORY
 #include "clapsing.h"
@@ -4781,4 +4782,5 @@
 {
   monomexpr=(poly)w->Data();
+  poly p=(poly)v->Data();
   #if 0
   if (pLength(monomexpr)>1)
@@ -4789,8 +4791,17 @@
   }
   #endif
-  if (!(ringvar=pVar((poly)v->Data())))
-  {
-    WerrorS("ringvar expected");
-    return TRUE;
+  if (!(ringvar=pVar(p)))
+  {
+    if (rField_is_Extension(currRing))
+    {
+      assume(currRing->algring!=NULL);
+      lnumber n=(lnumber)pGetCoeff(p);
+      ringvar=-p_Var(n->z,currRing->algring);
+    }
+    if(ringvar==0)
+    {
+      WerrorS("ringvar/par expected");
+      return TRUE;
+    }
   }
   return FALSE;
@@ -4802,9 +4813,14 @@
   BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
   if (nok) return TRUE;
-  if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
-    res->data = pSubst((poly)u->CopyD(res->rtyp),ringvar,monomexpr);
+  if (ringvar>0)
+  {
+    if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
+      res->data = pSubst((poly)u->CopyD(res->rtyp),ringvar,monomexpr);
+    else
+      res->data= pSubstPoly((poly)u->Data(),ringvar,monomexpr);
+  }
   else
   {
-    res->data= pSubstPoly((poly)u->Data(),ringvar,monomexpr);
+    res->data=pSubstPar((poly)u->Data(),-ringvar,monomexpr);
   }
   return FALSE;
@@ -4816,8 +4832,15 @@
   BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
   if (nok) return TRUE;
-  if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
-    res->data = idSubst((ideal)u->CopyD(res->rtyp),ringvar,monomexpr);
+  if (ringvar>0)
+  {
+    if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
+      res->data = idSubst((ideal)u->CopyD(res->rtyp),ringvar,monomexpr);
+    else
+      res->data = idSubstPoly((ideal)u->Data(),ringvar,monomexpr);
+  }
   else
-    res->data = idSubstPoly((ideal)u->Data(),ringvar,monomexpr);
+  {
+    res->data = idSubstPar((ideal)u->Data(),-ringvar,monomexpr);
+  }
   return FALSE;
 }
Index: Singular/maps_ip.cc
===================================================================
--- Singular/maps_ip.cc	(revision c0eb11ed4b9c2fcf9078e34ece905585ee5ec7b2)
+++ Singular/maps_ip.cc	(revision 29d768383fe7ec64b0b6f904e4082d94b5a0cd82)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: maps_ip.cc,v 1.6 2004-09-23 07:39:27 Singular Exp $ */
+/* $Id: maps_ip.cc,v 1.7 2005-04-18 15:10:06 Singular Exp $ */
 /*
 * ABSTRACT - the mapping of polynomials to other rings
@@ -20,4 +20,5 @@
 #include "lists.h"
 #include "maps.h"
+#include "maps_ip.h"
 #include "prCopy.h"
 
Index: Singular/maps_ip.h
===================================================================
--- Singular/maps_ip.h	(revision 29d768383fe7ec64b0b6f904e4082d94b5a0cd82)
+++ Singular/maps_ip.h	(revision 29d768383fe7ec64b0b6f904e4082d94b5a0cd82)
@@ -0,0 +1,16 @@
+#ifndef MAPS_IP_H
+#define MAPS_IP_H
+/****************************************
+*  Computer Algebra System SINGULAR     *
+****************************************/
+/* $Id: maps_ip.h,v 1.1 2005-04-18 15:10:04 Singular Exp $ */
+/*
+* ABSTRACT - the mapping of polynomials to other rings
+*/
+#include "structs.h"
+
+poly pSubstPoly(poly p, int var, poly image);
+poly pSubstPar(poly p, int par, poly image);
+ideal  idSubstPoly(ideal id, int n, poly e);
+ideal  idSubstPar(ideal id, int n, poly e);
+#endif
