comparison src/eval.c @ 344:7033303ea0c0 v7.0089

updated for version 7.0089
author vimboss
date Tue, 21 Jun 2005 22:37:39 +0000
parents bfd8935d6200
children 25dd5036f2b0
comparison
equal deleted inserted replaced
343:607cff4bc0cb 344:7033303ea0c0
538 static void f_setqflist __ARGS((typval_T *argvars, typval_T *rettv)); 538 static void f_setqflist __ARGS((typval_T *argvars, typval_T *rettv));
539 static void f_setreg __ARGS((typval_T *argvars, typval_T *rettv)); 539 static void f_setreg __ARGS((typval_T *argvars, typval_T *rettv));
540 static void f_setwinvar __ARGS((typval_T *argvars, typval_T *rettv)); 540 static void f_setwinvar __ARGS((typval_T *argvars, typval_T *rettv));
541 static void f_simplify __ARGS((typval_T *argvars, typval_T *rettv)); 541 static void f_simplify __ARGS((typval_T *argvars, typval_T *rettv));
542 static void f_sort __ARGS((typval_T *argvars, typval_T *rettv)); 542 static void f_sort __ARGS((typval_T *argvars, typval_T *rettv));
543 static void f_spellbadword __ARGS((typval_T *argvars, typval_T *rettv));
544 static void f_spellsuggest __ARGS((typval_T *argvars, typval_T *rettv));
543 static void f_split __ARGS((typval_T *argvars, typval_T *rettv)); 545 static void f_split __ARGS((typval_T *argvars, typval_T *rettv));
544 #ifdef HAVE_STRFTIME 546 #ifdef HAVE_STRFTIME
545 static void f_strftime __ARGS((typval_T *argvars, typval_T *rettv)); 547 static void f_strftime __ARGS((typval_T *argvars, typval_T *rettv));
546 #endif 548 #endif
547 static void f_stridx __ARGS((typval_T *argvars, typval_T *rettv)); 549 static void f_stridx __ARGS((typval_T *argvars, typval_T *rettv));
6349 {"setqflist", 1, 2, f_setqflist}, 6351 {"setqflist", 1, 2, f_setqflist},
6350 {"setreg", 2, 3, f_setreg}, 6352 {"setreg", 2, 3, f_setreg},
6351 {"setwinvar", 3, 3, f_setwinvar}, 6353 {"setwinvar", 3, 3, f_setwinvar},
6352 {"simplify", 1, 1, f_simplify}, 6354 {"simplify", 1, 1, f_simplify},
6353 {"sort", 1, 2, f_sort}, 6355 {"sort", 1, 2, f_sort},
6356 {"spellbadword", 0, 0, f_spellbadword},
6357 {"spellsuggest", 1, 2, f_spellsuggest},
6354 {"split", 1, 3, f_split}, 6358 {"split", 1, 3, f_split},
6355 #ifdef HAVE_STRFTIME 6359 #ifdef HAVE_STRFTIME
6356 {"strftime", 1, 2, f_strftime}, 6360 {"strftime", 1, 2, f_strftime},
6357 #endif 6361 #endif
6358 {"stridx", 2, 3, f_stridx}, 6362 {"stridx", 2, 3, f_stridx},
13067 } 13071 }
13068 } 13072 }
13069 13073
13070 vim_free(ptrs); 13074 vim_free(ptrs);
13071 } 13075 }
13076 }
13077
13078 /*
13079 * "spellbadword()" function
13080 */
13081 /* ARGSUSED */
13082 static void
13083 f_spellbadword(argvars, rettv)
13084 typval_T *argvars;
13085 typval_T *rettv;
13086 {
13087 int attr;
13088 char_u *ptr;
13089 int len;
13090
13091 rettv->vval.v_string = NULL;
13092 rettv->v_type = VAR_STRING;
13093
13094 #ifdef FEAT_SYN_HL
13095 /* Find the start of the badly spelled word. */
13096 if (spell_move_to(FORWARD, TRUE, TRUE) == FAIL)
13097 return;
13098
13099 /* Get the length of the word and copy it. */
13100 ptr = ml_get_cursor();
13101 len = spell_check(curwin, ptr, &attr);
13102 rettv->vval.v_string = vim_strnsave(ptr, len);
13103 #endif
13104 }
13105
13106 /*
13107 * "spellsuggest()" function
13108 */
13109 static void
13110 f_spellsuggest(argvars, rettv)
13111 typval_T *argvars;
13112 typval_T *rettv;
13113 {
13114 char_u *str;
13115 int maxcount;
13116 garray_T ga;
13117 list_T *l;
13118 listitem_T *li;
13119 int i;
13120
13121 l = list_alloc();
13122 if (l == NULL)
13123 return;
13124 rettv->v_type = VAR_LIST;
13125 rettv->vval.v_list = l;
13126 ++l->lv_refcount;
13127
13128 #ifdef FEAT_SYN_HL
13129 if (curwin->w_p_spell && *curbuf->b_p_spl != NUL)
13130 {
13131 str = get_tv_string(&argvars[0]);
13132 if (argvars[1].v_type != VAR_UNKNOWN)
13133 {
13134 maxcount = get_tv_number(&argvars[1]);
13135 if (maxcount <= 0)
13136 return;
13137 }
13138 else
13139 maxcount = 25;
13140
13141 spell_suggest_list(&ga, str, maxcount);
13142
13143 for (i = 0; i < ga.ga_len; ++i)
13144 {
13145 str = ((char_u **)ga.ga_data)[i];
13146
13147 li = listitem_alloc();
13148 if (li == NULL)
13149 vim_free(str);
13150 else
13151 {
13152 li->li_tv.v_type = VAR_STRING;
13153 li->li_tv.v_lock = 0;
13154 li->li_tv.vval.v_string = str;
13155 list_append(l, li);
13156 }
13157 }
13158 ga_clear(&ga);
13159 }
13160 #endif
13072 } 13161 }
13073 13162
13074 static void 13163 static void
13075 f_split(argvars, rettv) 13164 f_split(argvars, rettv)
13076 typval_T *argvars; 13165 typval_T *argvars;
16000 * "name" == func, "fudi.fd_dict" == NULL 16089 * "name" == func, "fudi.fd_dict" == NULL
16001 * dict.func new dictionary entry 16090 * dict.func new dictionary entry
16002 * "name" == NULL, "fudi.fd_dict" set, 16091 * "name" == NULL, "fudi.fd_dict" set,
16003 * "fudi.fd_di" == NULL, "fudi.fd_newkey" == func 16092 * "fudi.fd_di" == NULL, "fudi.fd_newkey" == func
16004 * dict.func existing dict entry with a Funcref 16093 * dict.func existing dict entry with a Funcref
16005 * "name" == fname, "fudi.fd_dict" set, 16094 * "name" == func, "fudi.fd_dict" set,
16006 * "fudi.fd_di" set, "fudi.fd_newkey" == NULL 16095 * "fudi.fd_di" set, "fudi.fd_newkey" == NULL
16007 * dict.func existing dict entry that's not a Funcref 16096 * dict.func existing dict entry that's not a Funcref
16008 * "name" == NULL, "fudi.fd_dict" set, 16097 * "name" == NULL, "fudi.fd_dict" set,
16009 * "fudi.fd_di" set, "fudi.fd_newkey" == NULL 16098 * "fudi.fd_di" set, "fudi.fd_newkey" == NULL
16010 */ 16099 */
16093 } 16182 }
16094 p = skipwhite(p + 1); 16183 p = skipwhite(p + 1);
16095 16184
16096 ga_init2(&newargs, (int)sizeof(char_u *), 3); 16185 ga_init2(&newargs, (int)sizeof(char_u *), 3);
16097 ga_init2(&newlines, (int)sizeof(char_u *), 3); 16186 ga_init2(&newlines, (int)sizeof(char_u *), 3);
16187
16188 if (!eap->skip)
16189 {
16190 /* Check the name of the function. */
16191 if (name != NULL)
16192 arg = name;
16193 else
16194 arg = fudi.fd_newkey;
16195 if (arg != NULL)
16196 {
16197 if (*arg == K_SPECIAL)
16198 j = 3;
16199 else
16200 j = 0;
16201 while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j])
16202 : eval_isnamec(arg[j])))
16203 ++j;
16204 if (arg[j] != NUL)
16205 emsg_funcname(_(e_invarg2), arg);
16206 }
16207 }
16098 16208
16099 /* 16209 /*
16100 * Isolate the arguments: "arg1, arg2, ...)" 16210 * Isolate the arguments: "arg1, arg2, ...)"
16101 */ 16211 */
16102 while (*p != ')') 16212 while (*p != ')')
16184 if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL) 16294 if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL)
16185 EMSG(_(e_funcdict)); 16295 EMSG(_(e_funcdict));
16186 else if (name != NULL && find_func(name) != NULL) 16296 else if (name != NULL && find_func(name) != NULL)
16187 emsg_funcname(e_funcexts, name); 16297 emsg_funcname(e_funcexts, name);
16188 } 16298 }
16299
16300 if (!eap->skip && did_emsg)
16301 goto erret;
16189 16302
16190 msg_putchar('\n'); /* don't overwrite the function name */ 16303 msg_putchar('\n'); /* don't overwrite the function name */
16191 cmdline_row = msg_row; 16304 cmdline_row = msg_row;
16192 } 16305 }
16193 16306