Mercurial > vim
comparison src/json.c @ 7864:6b0891de44a9 v7.4.1229
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 31 20:24:32 2016 +0100
patch 7.4.1229
Problem: "eval" and "expr" channel commands don't work yet.
Solution: Implement them. Update the error numbers. Also add "redraw".
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 31 Jan 2016 20:30:04 +0100 |
parents | 6f81cf49da14 |
children | 17e6ff1a74f1 |
comparison
equal
deleted
inserted
replaced
7863:e18a688b2e3b | 7864:6b0891de44a9 |
---|---|
29 | 29 |
30 /* Store bytes in the growarray. */ | 30 /* Store bytes in the growarray. */ |
31 ga_init2(&ga, 1, 4000); | 31 ga_init2(&ga, 1, 4000); |
32 json_encode_item(&ga, val, get_copyID()); | 32 json_encode_item(&ga, val, get_copyID()); |
33 return ga.ga_data; | 33 return ga.ga_data; |
34 } | |
35 | |
36 /* | |
37 * Encode ["nr", "val"] into a JSON format string. | |
38 * Returns NULL when out of memory. | |
39 */ | |
40 char_u * | |
41 json_encode_nr_expr(int nr, typval_T *val) | |
42 { | |
43 typval_T listtv; | |
44 typval_T nrtv; | |
45 char_u *text; | |
46 | |
47 nrtv.v_type = VAR_NUMBER; | |
48 nrtv.vval.v_number = nr; | |
49 if (rettv_list_alloc(&listtv) == FAIL) | |
50 return NULL; | |
51 if (list_append_tv(listtv.vval.v_list, &nrtv) == FAIL | |
52 || list_append_tv(listtv.vval.v_list, val) == FAIL) | |
53 { | |
54 list_unref(listtv.vval.v_list); | |
55 return NULL; | |
56 } | |
57 | |
58 text = json_encode(&listtv); | |
59 list_unref(listtv.vval.v_list); | |
60 return text; | |
34 } | 61 } |
35 | 62 |
36 static void | 63 static void |
37 write_string(garray_T *gap, char_u *str) | 64 write_string(garray_T *gap, char_u *str) |
38 { | 65 { |