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

View File

@ -237,6 +237,7 @@ isTermEqualFn (Term term1, Term term2)
/** /**
*@param t Term to be checked for a subterm. *@param t Term to be checked for a subterm.
*@param tsub 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. *@return True iff tsub is a subterm of t.
*/ */
int int
@ -246,15 +247,39 @@ termSubTerm (Term t, Term tsub)
tsub = deVar (tsub); tsub = deVar (tsub);
if (isTermEqual (t, tsub)) if (isTermEqual (t, tsub))
return 1; {
if (realTermLeaf (t)) return 1;
return 0; }
if (realTermTuple (t))
return (termSubTerm (TermOp1 (t), tsub)
|| termSubTerm (TermOp2 (t), tsub));
else 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. //! See if a term is an interm of another.
@ -1301,7 +1326,6 @@ termPrintDiff (Term t1, Term t2)
} }
} }
} }
} }
} }
} }