- Extra checks:

* For incomplete protocols, better handling of dangling labels.
  * For termSubTerm better handling of NULL cases.
This commit is contained in:
ccremers 2005-08-11 12:56:36 +00:00
parent c8d2222c58
commit cee11bc0af
2 changed files with 70 additions and 39 deletions

View File

@ -503,41 +503,48 @@ arachne_runs_agree (const System sys, const Claimlist cl, const Termmap runs)
int run;
run = termmapGet (runs, role);
if (run != -1)
{
#ifdef DEBUG
if (run < 0 || run >= sys->maxruns)
{
globalError++;
eprintf ("Run mapping %i out of bounds for role ", run);
termPrint (role);
eprintf (" and label ");
termPrint (label);
eprintf ("\n");
eprintf ("This label has sendrole ");
termPrint (linfo->sendrole);
eprintf (" and readrole ");
termPrint (linfo->readrole);
eprintf ("\n");
globalError--;
error ("Run mapping is out of bounds.");
}
if (run < 0 || run >= sys->maxruns)
{
globalError++;
eprintf ("Run mapping %i out of bounds for role ", run);
termPrint (role);
eprintf (" and label ");
termPrint (label);
eprintf ("\n");
eprintf ("This label has sendrole ");
termPrint (linfo->sendrole);
eprintf (" and readrole ");
termPrint (linfo->readrole);
eprintf ("\n");
globalError--;
error ("Run mapping is out of bounds.");
}
#endif
rd = sys->runs[run].start;
rd_res = NULL;
i = 0;
while (i < sys->runs[run].step && rd != NULL)
{
if (isTermEqual (rd->label, label))
rd = sys->runs[run].start;
rd_res = NULL;
i = 0;
while (i < sys->runs[run].step && rd != NULL)
{
rd_res = rd;
rd = NULL;
if (isTermEqual (rd->label, label))
{
rd_res = rd;
rd = NULL;
}
else
{
rd = rd->next;
}
i++;
}
else
{
rd = rd->next;
}
i++;
return rd_res;
}
else
{
return NULL;
}
return rd_res;
}
// Main

View File

@ -237,6 +237,7 @@ isTermEqualFn (Term term1, Term term2)
/**
*@param t Term to be checked for a subterm.
*@param tsub Subterm.
* Note that if t is non-null and tsub is null, it is a valid subterm.
*@return True iff tsub is a subterm of t.
*/
int
@ -246,15 +247,39 @@ termSubTerm (Term t, Term tsub)
tsub = deVar (tsub);
if (isTermEqual (t, tsub))
return 1;
if (realTermLeaf (t))
return 0;
if (realTermTuple (t))
return (termSubTerm (TermOp1 (t), tsub)
|| termSubTerm (TermOp2 (t), tsub));
{
return 1;
}
else
return (termSubTerm (TermOp (t), tsub)
|| termSubTerm (TermKey (t), tsub));
{
if (t == NULL)
{
return 0;
}
else
{
if (tsub == NULL)
{
return 1;
}
else
{
if (realTermLeaf (t))
{
return 0;
}
else
{
if (realTermTuple (t))
return (termSubTerm (TermOp1 (t), tsub)
|| termSubTerm (TermOp2 (t), tsub));
else
return (termSubTerm (TermOp (t), tsub)
|| termSubTerm (TermKey (t), tsub));
}
}
}
}
}
//! See if a term is an interm of another.
@ -1301,7 +1326,6 @@ termPrintDiff (Term t1, Term t2)
}
}
}
}
}
}