Mercurial > vim
diff src/eval.c @ 15589:44ea60ca593b v8.1.0802
patch 8.1.0802: negative index doesn't work for Blob
commit https://github.com/vim/vim/commit/a5be9b62480a6f338a72c01e57c9edd0bca8048b
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 24 12:31:44 2019 +0100
patch 8.1.0802: negative index doesn't work for Blob
Problem: Negative index doesn't work for Blob.
Solution: Make it work, add a test. (closes https://github.com/vim/vim/issues/3856)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 24 Jan 2019 12:45:05 +0100 |
parents | c2382f0d1279 |
children | e26caeb30026 |
line wrap: on
line diff
--- 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;