diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2009-11-13 17:08:35 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2009-11-13 17:08:35 -0800 |
commit | b53f80bc65b8cb7d382f4c16b6218ccfcb579ef5 (patch) | |
tree | b82a941b3b1100c83f54f872e13055f3ae4d8a88 /lib.c | |
parent | 34020d9344dbce334486ea9c3f5babdc6fbcbe10 (diff) | |
download | txr-b53f80bc65b8cb7d382f4c16b6218ccfcb579ef5.tar.gz txr-b53f80bc65b8cb7d382f4c16b6218ccfcb579ef5.tar.bz2 txr-b53f80bc65b8cb7d382f4c16b6218ccfcb579ef5.zip |
* lib.c (symbolp): Bugfix: function crashed on NUM argument.
(lazy_str): Fix for gc correctness: object from make_obj must be
completely intialized before any gc-triggering operation is invoked,
otherwise the garbage collector will be traversing an object
whose fields contain old garbage.
(lazy_str_force_upto): Off-by-one error. To force the object
up to index position N, means forcing up to length N+1.
This bug can make it look like a lazy string is much shorter
than it really is.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -1043,7 +1043,7 @@ obj_t *intern(obj_t *str) obj_t *symbolp(obj_t *sym) { - return (sym == nil || sym->s.type == SYM) ? t : nil; + return (sym == nil || (is_ptr(sym) && sym->s.type == SYM)) ? t : nil; } obj_t *func_f0(obj_t *env, obj_t *(*fun)(obj_t *)) @@ -1385,6 +1385,7 @@ obj_t *lazy_str(obj_t *lst, obj_t *term, obj_t *limit) { obj_t *obj = make_obj(); obj->ls.type = LSTR; + obj->ls.opts = nil; /* Must init before calling something that can gc! */ term = or2(term, string(L"\n")); @@ -1428,7 +1429,7 @@ obj_t *lazy_str_force_upto(obj_t *lstr, obj_t *index) type_check(lstr, LSTR); lim = cdr(lstr->ls.opts); - while (gt(index, length_str(lstr->ls.prefix)) && lstr->ls.list && + while (ge(index, length_str(lstr->ls.prefix)) && lstr->ls.list && or2(nullp(lim),gt(lim,zero))) { obj_t *next = pop(&lstr->ls.list); |