diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-06-14 07:09:53 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-06-14 07:09:53 -0700 |
commit | 3d685d1985cd06cb0bcbb53cca66ab3239f4ea06 (patch) | |
tree | 82c8320650752cfe40f1fbdeba93dc004b6c9991 | |
parent | 0ca6b880539ca0ebd2faa784e0bab9a928a91332 (diff) | |
download | txr-3d685d1985cd06cb0bcbb53cca66ab3239f4ea06.tar.gz txr-3d685d1985cd06cb0bcbb53cca66ab3239f4ea06.tar.bz2 txr-3d685d1985cd06cb0bcbb53cca66ab3239f4ea06.zip |
carray-refset: bugfix: support negative indexing.
* ffi.c (carray_refset): Support negative indexing by adding
the length of the array to a negative index value.
This is already done in carray_ref.
-rw-r--r-- | ffi.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -4829,6 +4829,9 @@ val carray_refset(val carray, val idx, val newval) struct carray *scry = carray_struct_checked(self, carray); cnum ix = c_num(idx); + if (ix < 0) + ix += scry->nelem; + if (ix < 0 || (scry->nelem >= 0 && ix >= scry->nelem)) { uw_throwf(error_s, lit("~a: ~s: index ~s out of bounds"), self, carray, idx, nao); |