comparison src/eval.c @ 7877:7fbd2de703a9 v7.4.1235

commit https://github.com/vim/vim/commit/11e0afa00a8e6c0aa1d50f760b5d5cb62dade038 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Feb 1 22:41:00 2016 +0100 patch 7.4.1235 Problem: Missing change to eval.c. Solution: Include that change.
author Christian Brabandt <cb@256bit.org>
date Mon, 01 Feb 2016 22:45:06 +0100
parents 6b0891de44a9
children 98a96e0ca73b
comparison
equal deleted inserted replaced
7876:93f747af7b58 7877:7fbd2de703a9
812 static char_u * make_expanded_name(char_u *in_start, char_u *expr_start, char_u *expr_end, char_u *in_end); 812 static char_u * make_expanded_name(char_u *in_start, char_u *expr_start, char_u *expr_end, char_u *in_end);
813 static int eval_isnamec(int c); 813 static int eval_isnamec(int c);
814 static int eval_isnamec1(int c); 814 static int eval_isnamec1(int c);
815 static int get_var_tv(char_u *name, int len, typval_T *rettv, dictitem_T **dip, int verbose, int no_autoload); 815 static int get_var_tv(char_u *name, int len, typval_T *rettv, dictitem_T **dip, int verbose, int no_autoload);
816 static int handle_subscript(char_u **arg, typval_T *rettv, int evaluate, int verbose); 816 static int handle_subscript(char_u **arg, typval_T *rettv, int evaluate, int verbose);
817 static typval_T *alloc_tv(void);
818 static typval_T *alloc_string_tv(char_u *string); 817 static typval_T *alloc_string_tv(char_u *string);
819 static void init_tv(typval_T *varp); 818 static void init_tv(typval_T *varp);
820 static long get_tv_number(typval_T *varp); 819 static long get_tv_number(typval_T *varp);
821 #ifdef FEAT_FLOAT 820 #ifdef FEAT_FLOAT
822 static float_T get_tv_float(typval_T *varp); 821 static float_T get_tv_float(typval_T *varp);
10063 char_u buf1[NUMBUFLEN]; 10062 char_u buf1[NUMBUFLEN];
10064 char_u *p; 10063 char_u *p;
10065 int port; 10064 int port;
10066 int json_mode = FALSE; 10065 int json_mode = FALSE;
10067 10066
10067 /* default: fail */
10068 rettv->vval.v_number = -1;
10069
10068 address = get_tv_string(&argvars[0]); 10070 address = get_tv_string(&argvars[0]);
10069 mode = get_tv_string_buf(&argvars[1], buf1); 10071 mode = get_tv_string_buf(&argvars[1], buf1);
10070 if (argvars[2].v_type != VAR_UNKNOWN) 10072 if (argvars[2].v_type != VAR_UNKNOWN)
10071 { 10073 {
10072 callback = get_callback(&argvars[2]); 10074 callback = get_callback(&argvars[2]);
10364 } 10366 }
10365 ch_idx = tv->vval.v_number; 10367 ch_idx = tv->vval.v_number;
10366 10368
10367 if (!channel_is_open(ch_idx)) 10369 if (!channel_is_open(ch_idx))
10368 { 10370 {
10369 EMSGN(_("E999: not an open channel"), ch_idx); 10371 EMSGN(_("E906: not an open channel"), ch_idx);
10370 return -1; 10372 return -1;
10371 } 10373 }
10372 return ch_idx; 10374 return ch_idx;
10373 } 10375 }
10374 10376
14098 js_read_T reader; 14100 js_read_T reader;
14099 14101
14100 reader.js_buf = get_tv_string(&argvars[0]); 14102 reader.js_buf = get_tv_string(&argvars[0]);
14101 reader.js_eof = TRUE; 14103 reader.js_eof = TRUE;
14102 reader.js_used = 0; 14104 reader.js_used = 0;
14103 json_decode(&reader, rettv); 14105 if (json_decode(&reader, rettv) == FAIL)
14106 EMSG(_(e_invarg));
14104 } 14107 }
14105 14108
14106 /* 14109 /*
14107 * "jsonencode()" function 14110 * "jsonencode()" function
14108 */ 14111 */
16894 */ 16897 */
16895 static void 16898 static void
16896 f_sendexpr(typval_T *argvars, typval_T *rettv) 16899 f_sendexpr(typval_T *argvars, typval_T *rettv)
16897 { 16900 {
16898 char_u *text; 16901 char_u *text;
16899 char_u *resp; 16902 typval_T *listtv;
16900 typval_T typetv;
16901 int ch_idx; 16903 int ch_idx;
16904 int id;
16902 16905
16903 /* return an empty string by default */ 16906 /* return an empty string by default */
16904 rettv->v_type = VAR_STRING; 16907 rettv->v_type = VAR_STRING;
16905 rettv->vval.v_string = NULL; 16908 rettv->vval.v_string = NULL;
16906 16909
16907 text = json_encode_nr_expr(channel_get_id(), &argvars[1]); 16910 id = channel_get_id();
16911 text = json_encode_nr_expr(id, &argvars[1]);
16908 if (text == NULL) 16912 if (text == NULL)
16909 return; 16913 return;
16910 16914
16911 ch_idx = send_common(argvars, text, "sendexpr"); 16915 ch_idx = send_common(argvars, text, "sendexpr");
16912 if (ch_idx >= 0) 16916 if (ch_idx >= 0)
16913 { 16917 {
16914 /* TODO: read until the whole JSON message is received */ 16918 if (channel_read_json_block(ch_idx, id, &listtv) == OK)
16915 /* TODO: only use the message with the right message ID */ 16919 {
16916 /* TODO: check sequence number */ 16920 if (listtv->v_type == VAR_LIST)
16917 resp = channel_read_block(ch_idx); 16921 {
16918 if (resp != NULL) 16922 list_T *list = listtv->vval.v_list;
16919 { 16923
16920 channel_decode_json(resp, &typetv, rettv, NULL); 16924 if (list->lv_len == 2)
16921 vim_free(resp); 16925 {
16926 /* Move the item from the list and then change the type to
16927 * avoid the value being freed. */
16928 *rettv = list->lv_last->li_tv;
16929 list->lv_last->li_tv.v_type = VAR_NUMBER;
16930 }
16931 }
16932 clear_tv(listtv);
16922 } 16933 }
16923 } 16934 }
16924 } 16935 }
16925 16936
16926 /* 16937 /*
20921 20932
20922 /* 20933 /*
20923 * Allocate memory for a variable type-value, and make it empty (0 or NULL 20934 * Allocate memory for a variable type-value, and make it empty (0 or NULL
20924 * value). 20935 * value).
20925 */ 20936 */
20926 static typval_T * 20937 typval_T *
20927 alloc_tv(void) 20938 alloc_tv(void)
20928 { 20939 {
20929 return (typval_T *)alloc_clear((unsigned)sizeof(typval_T)); 20940 return (typval_T *)alloc_clear((unsigned)sizeof(typval_T));
20930 } 20941 }
20931 20942