[net.lang.prolog] Fix for asserta bug in UNSW Prolog

claude@eagle.UUCP (05/25/83)

The following definition of the builtin "asserta" replaces the
old definition in the file "prolog/srce/p_meta.c". The old
could cause the system to crash if "asserta" was called with
no clauses previously defined for the given predicate.

Claude
eagle!claude



static
asserta PREDICATE
{
	register pval rval;
	register atom *x;
	var **old_vc, *vc[MAXVAR];

	if (iscompound(arg[0]))
	{
		argn = 0;
		old_vc = varcell;
		varcell = vc;
		rval = mkclause(arg[0], frame[0]);
		rval -> g.nvars = argn;
		x = (atom *) rval -> g.goal[0] -> c.term[0];
		rval -> g.rest = VAL(x);
		VAL(x) = (clause *) rval;
		same_proc = 0;
		varcell = old_vc;
		argn = 0;
		return(TRUE);
	}
	else fail1176
Relay-Version: version B 2.10 beta 3/