fix nth_instance: fix bugs and actually add two versions (obs from Theofrastos Mantadelis)

This commit is contained in:
Vítor Manuel de Morais Santos Costa
2009-11-18 13:06:37 +00:00
parent f31aeff952
commit a316090f8c
4 changed files with 40 additions and 21 deletions

View File

@@ -7132,12 +7132,12 @@ Yap_NthClause(PredEntry *ap, Int ncls)
yamop **jlbl = NULL;
/* search every clause */
if (ncls == 1)
if (ncls > ap->cs.p_code.NOfClauses)
return NULL;
else if (ncls == 1)
return to_clause(ap->cs.p_code.FirstClause,ap);
else if (ncls == ap->cs.p_code.NOfClauses)
return to_clause(ap->cs.p_code.LastClause,ap);
else if (ncls > ap->cs.p_code.NOfClauses)
return NULL;
else if (ncls < 0)
return NULL;