Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!decvax!microsof!uw-beaver!cornell!vax135!ariel!hou5f!hou5b!hou5c!hou5e!hou5a!hou5d!hogpc!houxm!mhuxa!mhuxi!mhuxt!eagle!claude
From: claude@eagle.UUCP
Newsgroups: net.lang.prolog
Subject: Fix for asserta bug in UNSW Prolog
Message-ID: <964@eagle.UUCP>
Date: Wed, 25-May-83 15:24:04 EDT
Article-I.D.: eagle.964
Posted: Wed May 25 15:24:04 1983
Date-Received: Sat, 28-May-83 01:06:28 EDT
Lines: 35


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/