0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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 #3856)
This commit is contained in:
Bram Moolenaar
2019-01-24 12:31:44 +01:00
parent fb1199d934
commit a5be9b6248
5 changed files with 20 additions and 6 deletions

View File

@@ -72,8 +72,12 @@ blob_copy(typval_T *from, typval_T *to)
int len = from->vval.v_blob->bv_ga.ga_len;
if (len > 0)
{
to->vval.v_blob->bv_ga.ga_data =
vim_memsave(from->vval.v_blob->bv_ga.ga_data, len);
if (to->vval.v_blob->bv_ga.ga_data == NULL)
len = 0;
}
to->vval.v_blob->bv_ga.ga_len = len;
}
return ret;
@@ -112,7 +116,7 @@ blob_len(blob_T *b)
* Get byte "idx" in blob "b".
* Caller must check that "idx" is valid.
*/
char_u
int
blob_get(blob_T *b, int idx)
{
return ((char_u*)b->bv_ga.ga_data)[idx];