diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib.c | 5 |
2 files changed, 9 insertions, 1 deletions
@@ -1,5 +1,10 @@ 2012-01-26 Kaz Kylheku <kaz@kylheku.com> + * lib.c (listref, listref_l): Negative indices must have semantics + consistent with vecref and ranges. + +2012-01-26 Kaz Kylheku <kaz@kylheku.com> + * lib.c (cat_str): Throw error if one of the list elements is not a character or string instead of silently returning nil. @@ -310,7 +310,7 @@ val sixth(val cons) val listref(val list, val ind) { if (lt(ind, zero)) - return nil; + ind = plus(ind, length_list(list)); for (; gt(ind, zero); ind = minus(ind, one)) list = cdr(list); return car(list); @@ -321,6 +321,9 @@ val *listref_l(val list, val ind) val olist = list; val oind = ind; + if (lt(ind, zero)) + ind = plus(ind, length_list(list)); + for (; gt(ind, zero) && list; ind = minus(ind, one)) list = cdr(list); if (consp(list)) |