Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site mit-eddie.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!ihnp4!mit-eddie!jfw
From: jfw@mit-eddie.UUCP (John Woods)
Newsgroups: net.sources
Subject: XLISP 1.2+ Initialization Bug
Message-ID: <2749@mit-eddie.UUCP>
Date: Fri, 21-Sep-84 18:38:03 EDT
Article-I.D.: mit-eddi.2749
Posted: Fri Sep 21 18:38:03 1984
Date-Received: Tue, 25-Sep-84 21:45:35 EDT
Distribution: net.sources
Organization: MIT, Cambridge, MA
Lines: 48

There is a bug in XLISP's initialization code, which caused the value of a
subr to become smashed (it turns out that I did not find this until I added
a couple of new functions).  What happens is:  xlsubr creates a new subr object
and then calls xlputprop.  xlputprop creates some new list elements, but if
it just happens to need a gc(), xlsubr forgot to save away it's subr on the
lisp stack (and xlputprop assumes that it's inputs were protected by eval()).
The fix:  Replace, in xlsubr.c, these functions with this new code:


		    /***************************************
		    *  xlsubr - define a builtin function  *
		    ***************************************/

xlsubr(sname,subr)
  char *sname; struct node *(*subr)();
{
    struct node *sym, newsubr;
    struct node *oldstk = xlsave(&newsubr,NULL);

    sym = xlenter(sname);              /* Enter the symbol */

    (newsubr.n_ptr = newnode(SUBR))->n_subr = subr;
    xlputprop(sym,newsubr.n_ptr,Subrprop);
    xlstack = oldstk;
}

		    /*********************************************
		    *  xlfsubr - define a builtin funny function *
		    **********************************************/

xlfsubr(sname,fsubr)
  char *sname; struct node *(*fsubr)();
{
    struct node *sym, newsubr;
    struct node *oldstk = xlsave(&newsubr,NULL);

    sym = xlenter(sname);              /* Enter the symbol */

    (newsubr.n_ptr = newnode(FSUBR))->n_subr = fsubr;
    xlputprop(sym,newsubr.n_ptr,Fsubrprop);
    xlstack = oldstk;
}

-- 
John Woods, Charles River Data Systems
decvax!frog!john, mit-eddie!jfw, JFW@MIT-XX

" `The Ego posits itself'...Rubbish!"	-M.P.