iris

small scheme interpreter
git clone git://git.2f30.org/iris
Log | Files | Refs | LICENSE

commit 177e080cb456b170a1609e5c32e0487f64bef209
parent 0777b3260e1fc1593e9fdb4e898958b1d7bf73a4
Author: sin <sin@2f30.org>
Date:   Mon, 19 May 2014 11:26:23 +0100

Don't modify the object in place

Diffstat:
Mparser.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/parser.c b/parser.c @@ -517,7 +517,7 @@ dodiff(struct object *o, struct object *n) static struct object * evaldiff(struct object *o) { - struct object *n; + struct object *n, *newn; if (o->type != OPair) return NULL; @@ -529,11 +529,13 @@ evaldiff(struct object *o) return n; if (n->type != OInteger) return error("expected integer"); + newn = newobject(); + memcpy(newn, n, sizeof(*newn)); if (!caddr(o)) { - n->d.n.v *= -1; - return n; + newn->d.n.v *= -1; + return newn; } - return dodiff(cddr(o), n); + return dodiff(cddr(o), newn); } static struct object *