diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-01-26 16:20:10 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-01-26 16:20:10 -0800 |
commit | fbe0c77a06a711bd746261406e47c16c55e660a8 (patch) | |
tree | a068b5fab79f0d49356c658bf94ad5f17bd15e0f /lib.c | |
parent | 9fc7ba486d0a17cb4503319f0bb2c675f96ea0c1 (diff) | |
download | txr-fbe0c77a06a711bd746261406e47c16c55e660a8.tar.gz txr-fbe0c77a06a711bd746261406e47c16c55e660a8.tar.bz2 txr-fbe0c77a06a711bd746261406e47c16c55e660a8.zip |
* lib.c (listref, listref_l): Negative indices must have semantics
consistent with vecref and ranges.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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)) |