diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-06-14 06:38:54 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-06-14 06:38:54 -0700 |
commit | 0ca6b880539ca0ebd2faa784e0bab9a928a91332 (patch) | |
tree | ef5478af20a198608b48516e1c8d519c451d521d /lib.c | |
parent | f9cd0b3815083f3827cd00b15e1ccf9a8706ad3c (diff) | |
download | txr-0ca6b880539ca0ebd2faa784e0bab9a928a91332.tar.gz txr-0ca6b880539ca0ebd2faa784e0bab9a928a91332.tar.bz2 txr-0ca6b880539ca0ebd2faa784e0bab9a928a91332.zip |
replace-list: negatives in index-list follow convention.
The index-list replacement isn't following the convention that
negative index values reference from the end of the target
sequence. Let's fix that.
* lib.c (replace_list): Likewise.
* txr.1: Documentation updated.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -1438,6 +1438,8 @@ val replace_list(val list, val items, val from, val to) self, nao); while (iter && seq_peek(&item_iter, &item) && seq_peek(&wh_iter, &wh)) { + if (minusp(wh)) + wh = plus(wh, len ? len : (len = length(list))); if (lt(wh, idx)) { seq_geti(&wh_iter); seq_geti(&item_iter); |