1
0
forked from aniani/vim

patch 8.1.0735: cannot handle binary data

Problem:    Cannot handle binary data.
Solution:   Add the Blob type. (Yasuhiro Matsumoto, closes #3638)
This commit is contained in:
Bram Moolenaar
2019-01-12 22:47:31 +01:00
parent e3c74d249a
commit 6e5ea8d2a9
27 changed files with 1354 additions and 114 deletions

View File

@@ -195,8 +195,10 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
{
char_u numbuf[NUMBUFLEN];
char_u *res;
blob_T *b;
list_T *l;
dict_T *d;
int i;
switch (val->v_type)
{
@@ -233,6 +235,25 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
EMSG(_(e_invarg));
return FAIL;
case VAR_BLOB:
b = val->vval.v_blob;
if (b == NULL || b->bv_ga.ga_len == 0)
ga_concat(gap, (char_u *)"[]");
else
{
ga_append(gap, '[');
for (i = 0; i < b->bv_ga.ga_len; i++)
{
if (i > 0)
ga_concat(gap, (char_u *)",");
vim_snprintf((char *)numbuf, NUMBUFLEN, "%d",
(int)blob_get(b, i));
ga_concat(gap, numbuf);
}
ga_append(gap, ']');
}
break;
case VAR_LIST:
l = val->vval.v_list;
if (l == NULL)