comparison src/eval.c @ 625:81fe2ccc1207 v7.0179

updated for version 7.0179
author vimboss
date Thu, 12 Jan 2006 23:22:24 +0000
parents 7fe13e0f5dce
children 52c87a746f4a
comparison
equal deleted inserted replaced
624:91e7d4a7b3b0 625:81fe2ccc1207
652 static int eval_isnamec1 __ARGS((int c)); 652 static int eval_isnamec1 __ARGS((int c));
653 static int get_var_tv __ARGS((char_u *name, int len, typval_T *rettv, int verbose)); 653 static int get_var_tv __ARGS((char_u *name, int len, typval_T *rettv, int verbose));
654 static int handle_subscript __ARGS((char_u **arg, typval_T *rettv, int evaluate, int verbose)); 654 static int handle_subscript __ARGS((char_u **arg, typval_T *rettv, int evaluate, int verbose));
655 static typval_T *alloc_tv __ARGS((void)); 655 static typval_T *alloc_tv __ARGS((void));
656 static typval_T *alloc_string_tv __ARGS((char_u *string)); 656 static typval_T *alloc_string_tv __ARGS((char_u *string));
657 static void free_tv __ARGS((typval_T *varp));
658 static void init_tv __ARGS((typval_T *varp)); 657 static void init_tv __ARGS((typval_T *varp));
659 static long get_tv_number __ARGS((typval_T *varp)); 658 static long get_tv_number __ARGS((typval_T *varp));
660 static linenr_T get_tv_lnum __ARGS((typval_T *argvars)); 659 static linenr_T get_tv_lnum __ARGS((typval_T *argvars));
661 static linenr_T get_tv_lnum_buf __ARGS((typval_T *argvars, buf_T *buf)); 660 static linenr_T get_tv_lnum_buf __ARGS((typval_T *argvars, buf_T *buf));
662 static char_u *get_tv_string __ARGS((typval_T *varp)); 661 static char_u *get_tv_string __ARGS((typval_T *varp));
1321 return get_tv_number(&li->li_tv); 1320 return get_tv_number(&li->li_tv);
1322 } 1321 }
1323 #endif 1322 #endif
1324 1323
1325 /* 1324 /*
1326 * Top level evaluation function, 1325 * Top level evaluation function.
1326 * Returns an allocated typval_T with the result.
1327 * Returns NULL when there is an error.
1327 */ 1328 */
1328 typval_T * 1329 typval_T *
1329 eval_expr(arg, nextcmd) 1330 eval_expr(arg, nextcmd)
1330 char_u *arg; 1331 char_u *arg;
1331 char_u **nextcmd; 1332 char_u **nextcmd;
1332 { 1333 {
1333 typval_T *tv; 1334 typval_T *tv;
1334 1335
1335 tv = (typval_T *)alloc(sizeof(typval_T)); 1336 tv = (typval_T *)alloc(sizeof(typval_T));
1336 if (!tv) 1337 if (tv != NULL && eval0(arg, tv, nextcmd, TRUE) == FAIL)
1337 return NULL;
1338
1339 if (eval0(arg, tv, nextcmd, TRUE) == FAIL)
1340 { 1338 {
1341 vim_free(tv); 1339 vim_free(tv);
1342 return NULL; 1340 tv = NULL;
1343 } 1341 }
1344 1342
1345 return tv; 1343 return tv;
1346 } 1344 }
1347 1345
13928 if (str != NULL) 13926 if (str != NULL)
13929 { 13927 {
13930 /* Check the argument for spelling. */ 13928 /* Check the argument for spelling. */
13931 while (*str != NUL) 13929 while (*str != NUL)
13932 { 13930 {
13933 len = spell_check(curwin, str, &attr, &capcol); 13931 len = spell_check(curwin, str, &attr, &capcol, FALSE);
13934 if (attr != HLF_COUNT) 13932 if (attr != HLF_COUNT)
13935 { 13933 {
13936 word = str; 13934 word = str;
13937 break; 13935 break;
13938 } 13936 }
13994 } 13992 }
13995 } 13993 }
13996 else 13994 else
13997 maxcount = 25; 13995 maxcount = 25;
13998 13996
13999 spell_suggest_list(&ga, str, maxcount, need_capital); 13997 spell_suggest_list(&ga, str, maxcount, need_capital, FALSE);
14000 13998
14001 for (i = 0; i < ga.ga_len; ++i) 13999 for (i = 0; i < ga.ga_len; ++i)
14002 { 14000 {
14003 str = ((char_u **)ga.ga_data)[i]; 14001 str = ((char_u **)ga.ga_data)[i];
14004 14002
15902 } 15900 }
15903 15901
15904 /* 15902 /*
15905 * Free the memory for a variable type-value. 15903 * Free the memory for a variable type-value.
15906 */ 15904 */
15907 static void 15905 void
15908 free_tv(varp) 15906 free_tv(varp)
15909 typval_T *varp; 15907 typval_T *varp;
15910 { 15908 {
15911 if (varp != NULL) 15909 if (varp != NULL)
15912 { 15910 {
16908 } 16906 }
16909 16907
16910 if (ret != FAIL && ga.ga_data != NULL) 16908 if (ret != FAIL && ga.ga_data != NULL)
16911 { 16909 {
16912 if (eap->cmdidx == CMD_echomsg) 16910 if (eap->cmdidx == CMD_echomsg)
16911 {
16913 MSG_ATTR(ga.ga_data, echo_attr); 16912 MSG_ATTR(ga.ga_data, echo_attr);
16913 out_flush();
16914 }
16914 else if (eap->cmdidx == CMD_echoerr) 16915 else if (eap->cmdidx == CMD_echoerr)
16915 { 16916 {
16916 /* We don't want to abort following commands, restore did_emsg. */ 16917 /* We don't want to abort following commands, restore did_emsg. */
16917 save_did_emsg = did_emsg; 16918 save_did_emsg = did_emsg;
16918 EMSG((char_u *)ga.ga_data); 16919 EMSG((char_u *)ga.ga_data);