iris

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

commit fd3af754458188e6727981c9746ab96379225a67
parent 8e03ac1edfcf6737f23930a6a19527fcdc4b9dc0
Author: sin <sin@2f30.org>
Date:   Wed, 14 May 2014 17:00:01 +0100

addsym() should return the existing object

Diffstat:
Msym.c | 12+++++++-----
Msym.h | 2+-
2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/sym.c b/sym.c @@ -17,20 +17,22 @@ struct symtab { size_t sz; } symtab; -int +struct object * addsym(const char *s, struct object *o) { + struct object *otmp; struct symentry *se; - if (lookupsym(s)) - return 0; + otmp = lookupsym(s); + if (otmp) + return otmp; if (symtab.sz + 1 > LEN(symtab.e)) - return -1; + return NULL; se = &symtab.e[symtab.sz]; se->s = s; se->o = o; symtab.sz++; - return 0; + return o; } struct object * diff --git a/sym.h b/sym.h @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ struct object; -int addsym(const char *, struct object *); +struct object *addsym(const char *, struct object *); struct object *lookupsym(const char *);