Message-ID: <bnews.decvax.482>
Newsgroups: net.sources
Path: utzoo!decvax!betz
X-Path: utzoo!decvax!betz
From: decvax!betz
Date: Thu Apr 21 08:10:56 1983
Subject: A third patch for xlisp
Posted: Wed Apr 20 09:22:04 1983
Received: Thu Apr 21 08:10:56 1983

It looks like 'defun' has a problem with its function definition getting
clobbered during garbage collection.  Here is a new copy of it that fixes
the problem.  Replace this routine in the module called 'xlsubr.c'.

/* defun - builtin function defun */
static struct node *defun(args)
  struct node *args;
{
    struct node *oldstk,arg,sym,fargs,fun;

    /* create a new stack frame */
    oldstk = xlsave(&arg,&sym,&fargs,&fun,NULL);

    /* initialize */
    arg.n_ptr = args;

    /* get the function symbol */
    sym.n_ptr = xlmatch(SYM,&arg.n_ptr);

    /* get the formal argument list */
    fargs.n_ptr = xlmatch(LIST,&arg.n_ptr);

    /* create a new function definition */
    fun.n_ptr = newnode(LIST);
    fun.n_ptr->n_listvalue = fargs.n_ptr;
    fun.n_ptr->n_listnext = arg.n_ptr;

    /* make the symbol point to a new function definition */
    assign(sym.n_ptr,fun.n_ptr);

    /* restore the previous stack frame */
    xlstack = oldstk;

    /* return the function symbol */
    return (sym.n_ptr);
}
