diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-01-24 12:31:44 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-01-24 12:31:44 +0100 |
commit | a5be9b62480a6f338a72c01e57c9edd0bca8048b (patch) | |
tree | 175b99b7f3066c78c025858a4278c4359854a3f7 /src/eval.c | |
parent | fb1199d934a27d338b18fe914e328346f093d3f6 (diff) |
patch 8.1.0802: negative index doesn't work for Blobv8.1.0802
Problem: Negative index doesn't work for Blob.
Solution: Make it work, add a test. (closes #3856)
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/eval.c b/src/eval.c index dac086f856..f111dc4312 100644 --- a/src/eval.c +++ b/src/eval.c @@ -4723,12 +4723,13 @@ eval_index( } else { - // The resulting variable is a string of a single - // character. If the index is too big or negative the - // result is empty. + // The resulting variable is a byte value. + // If the index is too big or negative that is an error. + if (n1 < 0) + n1 = len + n1; if (n1 < len && n1 >= 0) { - int v = (int)blob_get(rettv->vval.v_blob, n1); + int v = blob_get(rettv->vval.v_blob, n1); clear_tv(rettv); rettv->v_type = VAR_NUMBER; |