diff options
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -35,7 +35,7 @@ evalquery(Term *database, Term *query, Binding **resultbindings) Goal *goals; Choicepoint *choicestack = nil; - clausenr = 0; + clausenr = 2; /* Start at two since 0 is for the facts in the database, and 1 is for queries */ /* The goal stack has the original query at the very bottom, protected by a goal there the ->goal field is nil. @@ -128,8 +128,8 @@ findclause(Term *database, Term *goal, Binding **bindings) Term *clause; Term *head; for(; database != nil; database = database->next){ - clausenr++; clause = copyterm(database, &clausenr); + clausenr++; clause->next = database->next; if(clause->tag == CompoundTerm && runestrcmp(clause->text, L":-") == 0 && clause->arity == 2) head = clause->children; @@ -215,9 +215,10 @@ equalterms(Term *a, Term *b) switch(a->tag){ case AtomTerm: - case VariableTerm: case StringTerm: return !runestrcmp(a->text, b->text); + case VariableTerm: + return (runestrcmp(a->text, b->text) == 0 && a->clausenr == b->clausenr); case NumberTerm: if(a->numbertype != b->numbertype) return 0; |