comparison src/eval.c @ 659:d6a69271cb9a v7.0194

updated for version 7.0194
author vimboss
date Wed, 08 Feb 2006 09:20:24 +0000
parents bc95c6c4bac1
children 0137e7c3d31b
comparison
equal deleted inserted replaced
658:903088c7a7c6 659:d6a69271cb9a
6340 return NULL; 6340 return NULL;
6341 return HI2DI(hi); 6341 return HI2DI(hi);
6342 } 6342 }
6343 6343
6344 /* 6344 /*
6345 * Get a string item from a dictionary in allocated memory. 6345 * Get a string item from a dictionary.
6346 * When "save" is TRUE allocate memory for it.
6346 * Returns NULL if the entry doesn't exist or out of memory. 6347 * Returns NULL if the entry doesn't exist or out of memory.
6347 */ 6348 */
6348 char_u * 6349 char_u *
6349 get_dict_string(d, key) 6350 get_dict_string(d, key, save)
6350 dict_T *d; 6351 dict_T *d;
6351 char_u *key; 6352 char_u *key;
6353 int save;
6352 { 6354 {
6353 dictitem_T *di; 6355 dictitem_T *di;
6356 char_u *s;
6354 6357
6355 di = dict_find(d, key, -1); 6358 di = dict_find(d, key, -1);
6356 if (di == NULL) 6359 if (di == NULL)
6357 return NULL; 6360 return NULL;
6358 return vim_strsave(get_tv_string(&di->di_tv)); 6361 s = get_tv_string(&di->di_tv);
6362 if (save && s != NULL)
6363 s = vim_strsave(s);
6364 return s;
6359 } 6365 }
6360 6366
6361 /* 6367 /*
6362 * Get a number item from a dictionary. 6368 * Get a number item from a dictionary.
6363 * Returns 0 if the entry doesn't exist or out of memory. 6369 * Returns 0 if the entry doesn't exist or out of memory.
8012 static void 8018 static void
8013 f_complete_add(argvars, rettv) 8019 f_complete_add(argvars, rettv)
8014 typval_T *argvars; 8020 typval_T *argvars;
8015 typval_T *rettv; 8021 typval_T *rettv;
8016 { 8022 {
8017 char_u *s; 8023 char_u *word;
8018 8024 char_u *extra = NULL;
8019 s = get_tv_string_chk(&argvars[0]); 8025
8020 if (s != NULL) 8026 if (argvars[0].v_type == VAR_DICT && argvars[0].vval.v_dict != NULL)
8021 rettv->vval.v_number = ins_compl_add(s, -1, NULL, FORWARD, 0); 8027 {
8028 word = get_dict_string(argvars[0].vval.v_dict,
8029 (char_u *)"word", FALSE);
8030 extra = get_dict_string(argvars[0].vval.v_dict,
8031 (char_u *)"menu", FALSE);
8032 }
8033 else
8034 word = get_tv_string_chk(&argvars[0]);
8035 if (word != NULL)
8036 rettv->vval.v_number = ins_compl_add(word, -1, NULL, extra, 0, 0);
8022 } 8037 }
8023 8038
8024 /* 8039 /*
8025 * "complete_check()" function 8040 * "complete_check()" function
8026 */ 8041 */