/*
*	icalc - complex-expression parser
*
*	These are the routines to implement user-functions.
*	Structure definition is in complex.h.
*
*	(C) Martin W Scott, 1991.
*/
#include "complex.h"
#include "memory.h"

Symbol *findsym(sl, s)
	SymList *sl;
	char *s;
{
	if (sl)
		if (!strcmp(s,sl->sym->name))
			return sl->sym;
		else
			return findsym(sl->next, s);
	else
		return NULL;
}


void clear_ufunc(func)
	UserFunc *func;
{
	RemKey **oldkey = rem_setkey(&func->remkey);

	rem_freeall();
	func->tree = NULL;
	rem_setkey(oldkey);
}


void init_ufunc(func)		/* reset fields of user function */
	UserFunc *func;
{
	func->remkey = NULL;
	func->params = NULL;
}

SymList *addparam(sl, s)	/* add symbol (parameter) to list */
	SymList *sl;
	Symbol *s;
{
	SymList *newsl;

	newsl = rem_malloc(sizeof(SymList));
	newsl->sym = s;
	newsl->next = sl;
	return newsl;
}
