Added some safety checks and a missing deVar to the code that localises terms.
This commit is contained in:
parent
69c0486376
commit
b56c66db0b
13
src/system.c
13
src/system.c
@ -453,12 +453,15 @@ run_localize (const System sys, const int rid, Termlist fromlist,
|
|||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
t = substlist->term;
|
t = substlist->term;
|
||||||
if (t->subst != NULL)
|
if (t != NULL)
|
||||||
{
|
{
|
||||||
t->subst = termLocal (t->subst, fromlist, tolist);
|
if (t->subst != NULL)
|
||||||
sys->runs[rid].substitutions =
|
{
|
||||||
termlistAdd (sys->runs[rid].substitutions, t);
|
t->subst = termLocal (t->subst, fromlist, tolist);
|
||||||
}
|
sys->runs[rid].substitutions =
|
||||||
|
termlistAdd (sys->runs[rid].substitutions, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
substlist = substlist->next;
|
substlist = substlist->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -629,14 +629,18 @@ termlistLength (Termlist tl)
|
|||||||
*\sa termlistLocal()
|
*\sa termlistLocal()
|
||||||
*/
|
*/
|
||||||
Term
|
Term
|
||||||
termLocal (const Term t, Termlist fromlist, Termlist tolist)
|
termLocal (const Term tPre, Termlist fromlist, Termlist tolist)
|
||||||
{
|
{
|
||||||
if (t == NULL)
|
Term t;
|
||||||
|
|
||||||
|
if (tPre == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
t = deVar(tPre);
|
||||||
|
|
||||||
if (realTermLeaf (t))
|
if (realTermLeaf (t))
|
||||||
{
|
{
|
||||||
while (fromlist != NULL && tolist != NULL)
|
while ((fromlist != NULL) && (tolist != NULL))
|
||||||
{
|
{
|
||||||
if (isTermEqual (fromlist->term, t))
|
if (isTermEqual (fromlist->term, t))
|
||||||
{
|
{
|
||||||
@ -650,7 +654,9 @@ termLocal (const Term t, Termlist fromlist, Termlist tolist)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Term newt = termNodeDuplicate (t);
|
Term newt;
|
||||||
|
|
||||||
|
newt = termNodeDuplicate (t);
|
||||||
if (realTermTuple (t))
|
if (realTermTuple (t))
|
||||||
{
|
{
|
||||||
TermOp1 (newt) = termLocal (TermOp1 (t), fromlist, tolist);
|
TermOp1 (newt) = termLocal (TermOp1 (t), fromlist, tolist);
|
||||||
@ -658,8 +664,11 @@ termLocal (const Term t, Termlist fromlist, Termlist tolist)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TermOp (newt) = termLocal (TermOp (t), fromlist, tolist);
|
if (realTermEncrypt (t))
|
||||||
TermKey (newt) = termLocal (TermKey (t), fromlist, tolist);
|
{
|
||||||
|
TermOp (newt) = termLocal (TermOp (t), fromlist, tolist);
|
||||||
|
TermKey (newt) = termLocal (TermKey (t), fromlist, tolist);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return newt;
|
return newt;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user