Mercurial > vim
comparison src/eval.c @ 1851:e7f6ca5594cf v7.2.149
updated for version 7.2-149
author | vimboss |
---|---|
date | Wed, 22 Apr 2009 10:56:16 +0000 |
parents | e7633eb32cfd |
children | b88f0420148e |
comparison
equal
deleted
inserted
replaced
1850:eaecfa88c246 | 1851:e7f6ca5594cf |
---|---|
1283 int convert; | 1283 int convert; |
1284 { | 1284 { |
1285 typval_T tv; | 1285 typval_T tv; |
1286 char_u *retval; | 1286 char_u *retval; |
1287 garray_T ga; | 1287 garray_T ga; |
1288 #ifdef FEAT_FLOAT | |
1288 char_u numbuf[NUMBUFLEN]; | 1289 char_u numbuf[NUMBUFLEN]; |
1290 #endif | |
1289 | 1291 |
1290 if (eval0(arg, &tv, nextcmd, TRUE) == FAIL) | 1292 if (eval0(arg, &tv, nextcmd, TRUE) == FAIL) |
1291 retval = NULL; | 1293 retval = NULL; |
1292 else | 1294 else |
1293 { | 1295 { |
8016 | 8018 |
8017 | 8019 |
8018 /* execute the function if no errors detected and executing */ | 8020 /* execute the function if no errors detected and executing */ |
8019 if (evaluate && error == ERROR_NONE) | 8021 if (evaluate && error == ERROR_NONE) |
8020 { | 8022 { |
8021 rettv->v_type = VAR_NUMBER; /* default is number rettv */ | 8023 rettv->v_type = VAR_NUMBER; /* default rettv is number zero */ |
8024 rettv->vval.v_number = 0; | |
8022 error = ERROR_UNKNOWN; | 8025 error = ERROR_UNKNOWN; |
8023 | 8026 |
8024 if (!builtin_function(fname)) | 8027 if (!builtin_function(fname)) |
8025 { | 8028 { |
8026 /* | 8029 /* |
8266 l = argvars[1].vval.v_list; | 8269 l = argvars[1].vval.v_list; |
8267 if (l == NULL) | 8270 if (l == NULL) |
8268 return; | 8271 return; |
8269 li = l->lv_first; | 8272 li = l->lv_first; |
8270 } | 8273 } |
8271 rettv->vval.v_number = 0; /* Default: Success */ | |
8272 for (;;) | 8274 for (;;) |
8273 { | 8275 { |
8274 if (l == NULL) | 8276 if (l == NULL) |
8275 tv = &argvars[1]; /* append a string */ | 8277 tv = &argvars[1]; /* append a string */ |
8276 else if (li == NULL) | 8278 else if (li == NULL) |
8726 int argc = 0; | 8728 int argc = 0; |
8727 listitem_T *item; | 8729 listitem_T *item; |
8728 int dummy; | 8730 int dummy; |
8729 dict_T *selfdict = NULL; | 8731 dict_T *selfdict = NULL; |
8730 | 8732 |
8731 rettv->vval.v_number = 0; | |
8732 if (argvars[1].v_type != VAR_LIST) | 8733 if (argvars[1].v_type != VAR_LIST) |
8733 { | 8734 { |
8734 EMSG(_(e_listreq)); | 8735 EMSG(_(e_listreq)); |
8735 return; | 8736 return; |
8736 } | 8737 } |
9034 } | 9035 } |
9035 | 9036 |
9036 if (buttons == NULL || *buttons == NUL) | 9037 if (buttons == NULL || *buttons == NUL) |
9037 buttons = (char_u *)_("&Ok"); | 9038 buttons = (char_u *)_("&Ok"); |
9038 | 9039 |
9039 if (error) | 9040 if (!error) |
9040 rettv->vval.v_number = 0; | |
9041 else | |
9042 rettv->vval.v_number = do_dialog(type, NULL, message, buttons, | 9041 rettv->vval.v_number = do_dialog(type, NULL, message, buttons, |
9043 def, NULL); | 9042 def, NULL); |
9044 #else | |
9045 rettv->vval.v_number = 0; | |
9046 #endif | 9043 #endif |
9047 } | 9044 } |
9048 | 9045 |
9049 /* | 9046 /* |
9050 * "copy()" function | 9047 * "copy()" function |
9179 if (argvars[2].v_type != VAR_UNKNOWN) | 9176 if (argvars[2].v_type != VAR_UNKNOWN) |
9180 prepend = get_tv_string_buf(&argvars[2], buf); | 9177 prepend = get_tv_string_buf(&argvars[2], buf); |
9181 } | 9178 } |
9182 | 9179 |
9183 rettv->vval.v_number = cs_connection(num, dbpath, prepend); | 9180 rettv->vval.v_number = cs_connection(num, dbpath, prepend); |
9184 #else | |
9185 rettv->vval.v_number = 0; | |
9186 #endif | 9181 #endif |
9187 } | 9182 } |
9188 | 9183 |
9189 /* | 9184 /* |
9190 * "cursor(lnum, col)" function | 9185 * "cursor(lnum, col)" function |
9191 * | 9186 * |
9192 * Moves the cursor to the specified line and column | 9187 * Moves the cursor to the specified line and column. |
9188 * Returns 0 when the position could be set, -1 otherwise. | |
9193 */ | 9189 */ |
9194 /*ARGSUSED*/ | 9190 /*ARGSUSED*/ |
9195 static void | 9191 static void |
9196 f_cursor(argvars, rettv) | 9192 f_cursor(argvars, rettv) |
9197 typval_T *argvars; | 9193 typval_T *argvars; |
9200 long line, col; | 9196 long line, col; |
9201 #ifdef FEAT_VIRTUALEDIT | 9197 #ifdef FEAT_VIRTUALEDIT |
9202 long coladd = 0; | 9198 long coladd = 0; |
9203 #endif | 9199 #endif |
9204 | 9200 |
9201 rettv->vval.v_number = -1; | |
9205 if (argvars[1].v_type == VAR_UNKNOWN) | 9202 if (argvars[1].v_type == VAR_UNKNOWN) |
9206 { | 9203 { |
9207 pos_T pos; | 9204 pos_T pos; |
9208 | 9205 |
9209 if (list2fpos(argvars, &pos, NULL) == FAIL) | 9206 if (list2fpos(argvars, &pos, NULL) == FAIL) |
9244 if (has_mbyte) | 9241 if (has_mbyte) |
9245 mb_adjust_cursor(); | 9242 mb_adjust_cursor(); |
9246 #endif | 9243 #endif |
9247 | 9244 |
9248 curwin->w_set_curswant = TRUE; | 9245 curwin->w_set_curswant = TRUE; |
9246 rettv->vval.v_number = 0; | |
9249 } | 9247 } |
9250 | 9248 |
9251 /* | 9249 /* |
9252 * "deepcopy()" function | 9250 * "deepcopy()" function |
9253 */ | 9251 */ |
9289 typval_T *argvars; | 9287 typval_T *argvars; |
9290 typval_T *rettv; | 9288 typval_T *rettv; |
9291 { | 9289 { |
9292 #ifdef FEAT_AUTOCMD | 9290 #ifdef FEAT_AUTOCMD |
9293 rettv->vval.v_number = did_filetype; | 9291 rettv->vval.v_number = did_filetype; |
9294 #else | |
9295 rettv->vval.v_number = 0; | |
9296 #endif | 9292 #endif |
9297 } | 9293 } |
9298 | 9294 |
9299 /* | 9295 /* |
9300 * "diff_filler()" function | 9296 * "diff_filler()" function |
9603 static void | 9599 static void |
9604 f_extend(argvars, rettv) | 9600 f_extend(argvars, rettv) |
9605 typval_T *argvars; | 9601 typval_T *argvars; |
9606 typval_T *rettv; | 9602 typval_T *rettv; |
9607 { | 9603 { |
9608 rettv->vval.v_number = 0; | |
9609 if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_LIST) | 9604 if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_LIST) |
9610 { | 9605 { |
9611 list_T *l1, *l2; | 9606 list_T *l1, *l2; |
9612 listitem_T *item; | 9607 listitem_T *item; |
9613 long before; | 9608 long before; |
9731 * executed in the sandbox it would be OK, but it probably happens later, | 9726 * executed in the sandbox it would be OK, but it probably happens later, |
9732 * when "sandbox" is no longer set. */ | 9727 * when "sandbox" is no longer set. */ |
9733 if (check_secure()) | 9728 if (check_secure()) |
9734 return; | 9729 return; |
9735 | 9730 |
9736 rettv->vval.v_number = 0; | |
9737 keys = get_tv_string(&argvars[0]); | 9731 keys = get_tv_string(&argvars[0]); |
9738 if (*keys != NUL) | 9732 if (*keys != NUL) |
9739 { | 9733 { |
9740 if (argvars[1].v_type != VAR_UNKNOWN) | 9734 if (argvars[1].v_type != VAR_UNKNOWN) |
9741 { | 9735 { |
9899 int rem; | 9893 int rem; |
9900 int todo; | 9894 int todo; |
9901 char_u *ermsg = map ? (char_u *)"map()" : (char_u *)"filter()"; | 9895 char_u *ermsg = map ? (char_u *)"map()" : (char_u *)"filter()"; |
9902 int save_did_emsg; | 9896 int save_did_emsg; |
9903 | 9897 |
9904 rettv->vval.v_number = 0; | |
9905 if (argvars[0].v_type == VAR_LIST) | 9898 if (argvars[0].v_type == VAR_LIST) |
9906 { | 9899 { |
9907 if ((l = argvars[0].vval.v_list) == NULL | 9900 if ((l = argvars[0].vval.v_list) == NULL |
9908 || (map && tv_check_lock(l->lv_lock, ermsg))) | 9901 || (map && tv_check_lock(l->lv_lock, ermsg))) |
9909 return; | 9902 return; |
10082 else if (f > 0x7fffffff) | 10075 else if (f > 0x7fffffff) |
10083 rettv->vval.v_number = 0x7fffffff; | 10076 rettv->vval.v_number = 0x7fffffff; |
10084 else | 10077 else |
10085 rettv->vval.v_number = (varnumber_T)f; | 10078 rettv->vval.v_number = (varnumber_T)f; |
10086 } | 10079 } |
10087 else | |
10088 rettv->vval.v_number = 0; | |
10089 } | 10080 } |
10090 | 10081 |
10091 /* | 10082 /* |
10092 * "floor({float})" function | 10083 * "floor({float})" function |
10093 */ | 10084 */ |
10217 linenr_T lnum; | 10208 linenr_T lnum; |
10218 | 10209 |
10219 lnum = get_tv_lnum(argvars); | 10210 lnum = get_tv_lnum(argvars); |
10220 if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count) | 10211 if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count) |
10221 rettv->vval.v_number = foldLevel(lnum); | 10212 rettv->vval.v_number = foldLevel(lnum); |
10222 else | 10213 #endif |
10223 #endif | |
10224 rettv->vval.v_number = 0; | |
10225 } | 10214 } |
10226 | 10215 |
10227 /* | 10216 /* |
10228 * "foldtext()" function | 10217 * "foldtext()" function |
10229 */ | 10218 */ |
10335 static void | 10324 static void |
10336 f_foreground(argvars, rettv) | 10325 f_foreground(argvars, rettv) |
10337 typval_T *argvars; | 10326 typval_T *argvars; |
10338 typval_T *rettv; | 10327 typval_T *rettv; |
10339 { | 10328 { |
10340 rettv->vval.v_number = 0; | |
10341 #ifdef FEAT_GUI | 10329 #ifdef FEAT_GUI |
10342 if (gui.in_use) | 10330 if (gui.in_use) |
10343 gui_mch_set_foreground(); | 10331 gui_mch_set_foreground(); |
10344 #else | 10332 #else |
10345 # ifdef WIN32 | 10333 # ifdef WIN32 |
10357 typval_T *argvars; | 10345 typval_T *argvars; |
10358 typval_T *rettv; | 10346 typval_T *rettv; |
10359 { | 10347 { |
10360 char_u *s; | 10348 char_u *s; |
10361 | 10349 |
10362 rettv->vval.v_number = 0; | |
10363 s = get_tv_string(&argvars[0]); | 10350 s = get_tv_string(&argvars[0]); |
10364 if (s == NULL || *s == NUL || VIM_ISDIGIT(*s)) | 10351 if (s == NULL || *s == NUL || VIM_ISDIGIT(*s)) |
10365 EMSG2(_(e_invarg2), s); | 10352 EMSG2(_(e_invarg2), s); |
10366 /* Don't check an autoload name for existence here. */ | 10353 /* Don't check an autoload name for existence here. */ |
10367 else if (vim_strchr(s, AUTOLOAD_CHAR) == NULL && !function_exists(s)) | 10354 else if (vim_strchr(s, AUTOLOAD_CHAR) == NULL && !function_exists(s)) |
10427 else | 10414 else |
10428 EMSG2(_(e_listdictarg), "get()"); | 10415 EMSG2(_(e_listdictarg), "get()"); |
10429 | 10416 |
10430 if (tv == NULL) | 10417 if (tv == NULL) |
10431 { | 10418 { |
10432 if (argvars[2].v_type == VAR_UNKNOWN) | 10419 if (argvars[2].v_type != VAR_UNKNOWN) |
10433 rettv->vval.v_number = 0; | |
10434 else | |
10435 copy_tv(&argvars[2], rettv); | 10420 copy_tv(&argvars[2], rettv); |
10436 } | 10421 } |
10437 else | 10422 else |
10438 copy_tv(tv, rettv); | 10423 copy_tv(tv, rettv); |
10439 } | 10424 } |
10454 int retlist; | 10439 int retlist; |
10455 typval_T *rettv; | 10440 typval_T *rettv; |
10456 { | 10441 { |
10457 char_u *p; | 10442 char_u *p; |
10458 | 10443 |
10459 if (retlist) | 10444 if (retlist && rettv_list_alloc(rettv) == FAIL) |
10460 { | 10445 return; |
10461 if (rettv_list_alloc(rettv) == FAIL) | |
10462 return; | |
10463 } | |
10464 else | |
10465 rettv->vval.v_number = 0; | |
10466 | 10446 |
10467 if (buf == NULL || buf->b_ml.ml_mfp == NULL || start < 0) | 10447 if (buf == NULL || buf->b_ml.ml_mfp == NULL || start < 0) |
10468 return; | 10448 return; |
10469 | 10449 |
10470 if (!retlist) | 10450 if (!retlist) |
11007 { | 10987 { |
11008 #ifdef FEAT_SEARCH_EXTRA | 10988 #ifdef FEAT_SEARCH_EXTRA |
11009 dict_T *dict; | 10989 dict_T *dict; |
11010 matchitem_T *cur = curwin->w_match_head; | 10990 matchitem_T *cur = curwin->w_match_head; |
11011 | 10991 |
11012 rettv->vval.v_number = 0; | |
11013 | |
11014 if (rettv_list_alloc(rettv) == OK) | 10992 if (rettv_list_alloc(rettv) == OK) |
11015 { | 10993 { |
11016 while (cur != NULL) | 10994 while (cur != NULL) |
11017 { | 10995 { |
11018 dict = dict_alloc(); | 10996 dict = dict_alloc(); |
11087 { | 11065 { |
11088 #ifdef FEAT_QUICKFIX | 11066 #ifdef FEAT_QUICKFIX |
11089 win_T *wp; | 11067 win_T *wp; |
11090 #endif | 11068 #endif |
11091 | 11069 |
11092 rettv->vval.v_number = 0; | |
11093 #ifdef FEAT_QUICKFIX | 11070 #ifdef FEAT_QUICKFIX |
11094 if (rettv_list_alloc(rettv) == OK) | 11071 if (rettv_list_alloc(rettv) == OK) |
11095 { | 11072 { |
11096 wp = NULL; | 11073 wp = NULL; |
11097 if (argvars[0].v_type != VAR_UNKNOWN) /* getloclist() */ | 11074 if (argvars[0].v_type != VAR_UNKNOWN) /* getloclist() */ |
11933 static void | 11910 static void |
11934 f_has_key(argvars, rettv) | 11911 f_has_key(argvars, rettv) |
11935 typval_T *argvars; | 11912 typval_T *argvars; |
11936 typval_T *rettv; | 11913 typval_T *rettv; |
11937 { | 11914 { |
11938 rettv->vval.v_number = 0; | |
11939 if (argvars[0].v_type != VAR_DICT) | 11915 if (argvars[0].v_type != VAR_DICT) |
11940 { | 11916 { |
11941 EMSG(_(e_dictreq)); | 11917 EMSG(_(e_dictreq)); |
11942 return; | 11918 return; |
11943 } | 11919 } |
12050 else | 12026 else |
12051 /* string given: remove all matching entries */ | 12027 /* string given: remove all matching entries */ |
12052 n = del_history_entry(get_histtype(str), | 12028 n = del_history_entry(get_histtype(str), |
12053 get_tv_string_buf(&argvars[1], buf)); | 12029 get_tv_string_buf(&argvars[1], buf)); |
12054 rettv->vval.v_number = n; | 12030 rettv->vval.v_number = n; |
12055 #else | |
12056 rettv->vval.v_number = 0; | |
12057 #endif | 12031 #endif |
12058 } | 12032 } |
12059 | 12033 |
12060 /* | 12034 /* |
12061 * "histget()" function | 12035 * "histget()" function |
12413 { | 12387 { |
12414 listitem_T *li; | 12388 listitem_T *li; |
12415 int selected; | 12389 int selected; |
12416 int mouse_used; | 12390 int mouse_used; |
12417 | 12391 |
12418 rettv->vval.v_number = 0; | |
12419 #ifdef NO_CONSOLE_INPUT | 12392 #ifdef NO_CONSOLE_INPUT |
12420 /* While starting up, there is no place to enter text. */ | 12393 /* While starting up, there is no place to enter text. */ |
12421 if (no_console_input()) | 12394 if (no_console_input()) |
12422 return; | 12395 return; |
12423 #endif | 12396 #endif |
12462 if (ga_userinput.ga_len > 0) | 12435 if (ga_userinput.ga_len > 0) |
12463 { | 12436 { |
12464 --ga_userinput.ga_len; | 12437 --ga_userinput.ga_len; |
12465 restore_typeahead((tasave_T *)(ga_userinput.ga_data) | 12438 restore_typeahead((tasave_T *)(ga_userinput.ga_data) |
12466 + ga_userinput.ga_len); | 12439 + ga_userinput.ga_len); |
12467 rettv->vval.v_number = 0; /* OK */ | 12440 /* default return is zero == OK */ |
12468 } | 12441 } |
12469 else if (p_verbose > 1) | 12442 else if (p_verbose > 1) |
12470 { | 12443 { |
12471 verb_msg((char_u *)_("called inputrestore() more often than inputsave()")); | 12444 verb_msg((char_u *)_("called inputrestore() more often than inputsave()")); |
12472 rettv->vval.v_number = 1; /* Failed */ | 12445 rettv->vval.v_number = 1; /* Failed */ |
12486 if (ga_grow(&ga_userinput, 1) == OK) | 12459 if (ga_grow(&ga_userinput, 1) == OK) |
12487 { | 12460 { |
12488 save_typeahead((tasave_T *)(ga_userinput.ga_data) | 12461 save_typeahead((tasave_T *)(ga_userinput.ga_data) |
12489 + ga_userinput.ga_len); | 12462 + ga_userinput.ga_len); |
12490 ++ga_userinput.ga_len; | 12463 ++ga_userinput.ga_len; |
12491 rettv->vval.v_number = 0; /* OK */ | 12464 /* default return is zero == OK */ |
12492 } | 12465 } |
12493 else | 12466 else |
12494 rettv->vval.v_number = 1; /* Failed */ | 12467 rettv->vval.v_number = 1; /* Failed */ |
12495 } | 12468 } |
12496 | 12469 |
12520 long before = 0; | 12493 long before = 0; |
12521 listitem_T *item; | 12494 listitem_T *item; |
12522 list_T *l; | 12495 list_T *l; |
12523 int error = FALSE; | 12496 int error = FALSE; |
12524 | 12497 |
12525 rettv->vval.v_number = 0; | |
12526 if (argvars[0].v_type != VAR_LIST) | 12498 if (argvars[0].v_type != VAR_LIST) |
12527 EMSG2(_(e_listarg), "insert()"); | 12499 EMSG2(_(e_listarg), "insert()"); |
12528 else if ((l = argvars[0].vval.v_list) != NULL | 12500 else if ((l = argvars[0].vval.v_list) != NULL |
12529 && !tv_check_lock(l->lv_lock, (char_u *)"insert()")) | 12501 && !tv_check_lock(l->lv_lock, (char_u *)"insert()")) |
12530 { | 12502 { |
12639 listitem_T *li; | 12611 listitem_T *li; |
12640 listitem_T *li2; | 12612 listitem_T *li2; |
12641 dict_T *d; | 12613 dict_T *d; |
12642 int todo; | 12614 int todo; |
12643 | 12615 |
12644 rettv->vval.v_number = 0; | |
12645 if (argvars[0].v_type != VAR_DICT) | 12616 if (argvars[0].v_type != VAR_DICT) |
12646 { | 12617 { |
12647 EMSG(_(e_dictreq)); | 12618 EMSG(_(e_dictreq)); |
12648 return; | 12619 return; |
12649 } | 12620 } |
12727 typval_T *rettv; | 12698 typval_T *rettv; |
12728 { | 12699 { |
12729 garray_T ga; | 12700 garray_T ga; |
12730 char_u *sep; | 12701 char_u *sep; |
12731 | 12702 |
12732 rettv->vval.v_number = 0; | |
12733 if (argvars[0].v_type != VAR_LIST) | 12703 if (argvars[0].v_type != VAR_LIST) |
12734 { | 12704 { |
12735 EMSG(_(e_listreq)); | 12705 EMSG(_(e_listreq)); |
12736 return; | 12706 return; |
12737 } | 12707 } |
12825 char_u **string_result; | 12795 char_u **string_result; |
12826 int nr_result; | 12796 int nr_result; |
12827 #endif | 12797 #endif |
12828 | 12798 |
12829 rettv->v_type = type; | 12799 rettv->v_type = type; |
12830 if (type == VAR_NUMBER) | 12800 if (type != VAR_NUMBER) |
12831 rettv->vval.v_number = 0; | |
12832 else | |
12833 rettv->vval.v_string = NULL; | 12801 rettv->vval.v_string = NULL; |
12834 | 12802 |
12835 if (check_restricted() || check_secure()) | 12803 if (check_restricted() || check_secure()) |
12836 return; | 12804 return; |
12837 | 12805 |
13768 static void | 13736 static void |
13769 f_pumvisible(argvars, rettv) | 13737 f_pumvisible(argvars, rettv) |
13770 typval_T *argvars; | 13738 typval_T *argvars; |
13771 typval_T *rettv; | 13739 typval_T *rettv; |
13772 { | 13740 { |
13773 rettv->vval.v_number = 0; | |
13774 #ifdef FEAT_INS_EXPAND | 13741 #ifdef FEAT_INS_EXPAND |
13775 if (pum_visible()) | 13742 if (pum_visible()) |
13776 rettv->vval.v_number = 1; | 13743 rettv->vval.v_number = 1; |
13777 #endif | 13744 #endif |
13778 } | 13745 } |
13802 end = get_tv_number_chk(&argvars[1], &error); | 13769 end = get_tv_number_chk(&argvars[1], &error); |
13803 if (argvars[2].v_type != VAR_UNKNOWN) | 13770 if (argvars[2].v_type != VAR_UNKNOWN) |
13804 stride = get_tv_number_chk(&argvars[2], &error); | 13771 stride = get_tv_number_chk(&argvars[2], &error); |
13805 } | 13772 } |
13806 | 13773 |
13807 rettv->vval.v_number = 0; | |
13808 if (error) | 13774 if (error) |
13809 return; /* type error; errmsg already given */ | 13775 return; /* type error; errmsg already given */ |
13810 if (stride == 0) | 13776 if (stride == 0) |
13811 EMSG(_("E726: Stride is zero")); | 13777 EMSG(_("E726: Stride is zero")); |
13812 else if (stride > 0 ? end + 1 < start : end - 1 > start) | 13778 else if (stride > 0 ? end + 1 < start : end - 1 > start) |
14191 static void | 14157 static void |
14192 f_remote_foreground(argvars, rettv) | 14158 f_remote_foreground(argvars, rettv) |
14193 typval_T *argvars; | 14159 typval_T *argvars; |
14194 typval_T *rettv; | 14160 typval_T *rettv; |
14195 { | 14161 { |
14196 rettv->vval.v_number = 0; | |
14197 #ifdef FEAT_CLIENTSERVER | 14162 #ifdef FEAT_CLIENTSERVER |
14198 # ifdef WIN32 | 14163 # ifdef WIN32 |
14199 /* On Win32 it's done in this application. */ | 14164 /* On Win32 it's done in this application. */ |
14200 { | 14165 { |
14201 char_u *server_name = get_tv_string_chk(&argvars[0]); | 14166 char_u *server_name = get_tv_string_chk(&argvars[0]); |
14247 { | 14212 { |
14248 s = serverGetReply((HWND)n, FALSE, FALSE, FALSE); | 14213 s = serverGetReply((HWND)n, FALSE, FALSE, FALSE); |
14249 rettv->vval.v_number = (s != NULL); | 14214 rettv->vval.v_number = (s != NULL); |
14250 } | 14215 } |
14251 # else | 14216 # else |
14252 rettv->vval.v_number = 0; | |
14253 if (check_connection() == FAIL) | 14217 if (check_connection() == FAIL) |
14254 return; | 14218 return; |
14255 | 14219 |
14256 rettv->vval.v_number = serverPeekReply(X_DISPLAY, | 14220 rettv->vval.v_number = serverPeekReply(X_DISPLAY, |
14257 serverStrToWin(serverid), &s); | 14221 serverStrToWin(serverid), &s); |
14336 long end; | 14300 long end; |
14337 char_u *key; | 14301 char_u *key; |
14338 dict_T *d; | 14302 dict_T *d; |
14339 dictitem_T *di; | 14303 dictitem_T *di; |
14340 | 14304 |
14341 rettv->vval.v_number = 0; | |
14342 if (argvars[0].v_type == VAR_DICT) | 14305 if (argvars[0].v_type == VAR_DICT) |
14343 { | 14306 { |
14344 if (argvars[2].v_type != VAR_UNKNOWN) | 14307 if (argvars[2].v_type != VAR_UNKNOWN) |
14345 EMSG2(_(e_toomanyarg), "remove()"); | 14308 EMSG2(_(e_toomanyarg), "remove()"); |
14346 else if ((d = argvars[0].vval.v_dict) != NULL | 14309 else if ((d = argvars[0].vval.v_dict) != NULL |
14694 typval_T *rettv; | 14657 typval_T *rettv; |
14695 { | 14658 { |
14696 list_T *l; | 14659 list_T *l; |
14697 listitem_T *li, *ni; | 14660 listitem_T *li, *ni; |
14698 | 14661 |
14699 rettv->vval.v_number = 0; | |
14700 if (argvars[0].v_type != VAR_LIST) | 14662 if (argvars[0].v_type != VAR_LIST) |
14701 EMSG2(_(e_listarg), "reverse()"); | 14663 EMSG2(_(e_listarg), "reverse()"); |
14702 else if ((l = argvars[0].vval.v_list) != NULL | 14664 else if ((l = argvars[0].vval.v_list) != NULL |
14703 && !tv_check_lock(l->lv_lock, (char_u *)"reverse()")) | 14665 && !tv_check_lock(l->lv_lock, (char_u *)"reverse()")) |
14704 { | 14666 { |
15046 { | 15008 { |
15047 pos_T match_pos; | 15009 pos_T match_pos; |
15048 int lnum = 0; | 15010 int lnum = 0; |
15049 int col = 0; | 15011 int col = 0; |
15050 | 15012 |
15051 rettv->vval.v_number = 0; | |
15052 | |
15053 if (rettv_list_alloc(rettv) == FAIL) | 15013 if (rettv_list_alloc(rettv) == FAIL) |
15054 return; | 15014 return; |
15055 | 15015 |
15056 if (searchpair_cmn(argvars, &match_pos) > 0) | 15016 if (searchpair_cmn(argvars, &match_pos) > 0) |
15057 { | 15017 { |
15234 int lnum = 0; | 15194 int lnum = 0; |
15235 int col = 0; | 15195 int col = 0; |
15236 int n; | 15196 int n; |
15237 int flags = 0; | 15197 int flags = 0; |
15238 | 15198 |
15239 rettv->vval.v_number = 0; | |
15240 | |
15241 if (rettv_list_alloc(rettv) == FAIL) | 15199 if (rettv_list_alloc(rettv) == FAIL) |
15242 return; | 15200 return; |
15243 | 15201 |
15244 n = search_cmn(argvars, &match_pos, &flags); | 15202 n = search_cmn(argvars, &match_pos, &flags); |
15245 if (n > 0) | 15203 if (n > 0) |
15321 aco_save_T aco; | 15279 aco_save_T aco; |
15322 char_u *varname, *bufvarname; | 15280 char_u *varname, *bufvarname; |
15323 typval_T *varp; | 15281 typval_T *varp; |
15324 char_u nbuf[NUMBUFLEN]; | 15282 char_u nbuf[NUMBUFLEN]; |
15325 | 15283 |
15326 rettv->vval.v_number = 0; | |
15327 | |
15328 if (check_restricted() || check_secure()) | 15284 if (check_restricted() || check_secure()) |
15329 return; | 15285 return; |
15330 (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ | 15286 (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ |
15331 varname = get_tv_string_chk(&argvars[1]); | 15287 varname = get_tv_string_chk(&argvars[1]); |
15332 buf = get_buf_tv(&argvars[0]); | 15288 buf = get_buf_tv(&argvars[0]); |
15402 li = l->lv_first; | 15358 li = l->lv_first; |
15403 } | 15359 } |
15404 else | 15360 else |
15405 line = get_tv_string_chk(&argvars[1]); | 15361 line = get_tv_string_chk(&argvars[1]); |
15406 | 15362 |
15407 rettv->vval.v_number = 0; /* OK */ | 15363 /* default result is zero == OK */ |
15408 for (;;) | 15364 for (;;) |
15409 { | 15365 { |
15410 if (l != NULL) | 15366 if (l != NULL) |
15411 { | 15367 { |
15412 /* list argument, get next string */ | 15368 /* list argument, get next string */ |
15715 } | 15671 } |
15716 | 15672 |
15717 /* | 15673 /* |
15718 * "setwinvar()" and "settabwinvar()" functions | 15674 * "setwinvar()" and "settabwinvar()" functions |
15719 */ | 15675 */ |
15676 /*ARGSUSED*/ | |
15720 static void | 15677 static void |
15721 setwinvar(argvars, rettv, off) | 15678 setwinvar(argvars, rettv, off) |
15722 typval_T *argvars; | 15679 typval_T *argvars; |
15723 typval_T *rettv; | 15680 typval_T *rettv; |
15724 int off; | 15681 int off; |
15730 #endif | 15687 #endif |
15731 char_u *varname, *winvarname; | 15688 char_u *varname, *winvarname; |
15732 typval_T *varp; | 15689 typval_T *varp; |
15733 char_u nbuf[NUMBUFLEN]; | 15690 char_u nbuf[NUMBUFLEN]; |
15734 tabpage_T *tp; | 15691 tabpage_T *tp; |
15735 | |
15736 rettv->vval.v_number = 0; | |
15737 | 15692 |
15738 if (check_restricted() || check_secure()) | 15693 if (check_restricted() || check_secure()) |
15739 return; | 15694 return; |
15740 | 15695 |
15741 #ifdef FEAT_WINDOWS | 15696 #ifdef FEAT_WINDOWS |
15945 listitem_T *li; | 15900 listitem_T *li; |
15946 listitem_T **ptrs; | 15901 listitem_T **ptrs; |
15947 long len; | 15902 long len; |
15948 long i; | 15903 long i; |
15949 | 15904 |
15950 rettv->vval.v_number = 0; | |
15951 if (argvars[0].v_type != VAR_LIST) | 15905 if (argvars[0].v_type != VAR_LIST) |
15952 EMSG2(_(e_listarg), "sort()"); | 15906 EMSG2(_(e_listarg), "sort()"); |
15953 else | 15907 else |
15954 { | 15908 { |
15955 l = argvars[0].vval.v_list; | 15909 l = argvars[0].vval.v_list; |
16868 static void | 16822 static void |
16869 f_tabpagebuflist(argvars, rettv) | 16823 f_tabpagebuflist(argvars, rettv) |
16870 typval_T *argvars; | 16824 typval_T *argvars; |
16871 typval_T *rettv; | 16825 typval_T *rettv; |
16872 { | 16826 { |
16873 #ifndef FEAT_WINDOWS | 16827 #ifdef FEAT_WINDOWS |
16874 rettv->vval.v_number = 0; | |
16875 #else | |
16876 tabpage_T *tp; | 16828 tabpage_T *tp; |
16877 win_T *wp = NULL; | 16829 win_T *wp = NULL; |
16878 | 16830 |
16879 if (argvars[0].v_type == VAR_UNKNOWN) | 16831 if (argvars[0].v_type == VAR_UNKNOWN) |
16880 wp = firstwin; | 16832 wp = firstwin; |
16882 { | 16834 { |
16883 tp = find_tabpage((int)get_tv_number(&argvars[0])); | 16835 tp = find_tabpage((int)get_tv_number(&argvars[0])); |
16884 if (tp != NULL) | 16836 if (tp != NULL) |
16885 wp = (tp == curtab) ? firstwin : tp->tp_firstwin; | 16837 wp = (tp == curtab) ? firstwin : tp->tp_firstwin; |
16886 } | 16838 } |
16887 if (wp == NULL) | 16839 if (wp != NULL && rettv_list_alloc(rettv) != FAIL) |
16888 rettv->vval.v_number = 0; | 16840 { |
16889 else | 16841 for (; wp != NULL; wp = wp->w_next) |
16890 { | 16842 if (list_append_number(rettv->vval.v_list, |
16891 if (rettv_list_alloc(rettv) == FAIL) | |
16892 rettv->vval.v_number = 0; | |
16893 else | |
16894 { | |
16895 for (; wp != NULL; wp = wp->w_next) | |
16896 if (list_append_number(rettv->vval.v_list, | |
16897 wp->w_buffer->b_fnum) == FAIL) | 16843 wp->w_buffer->b_fnum) == FAIL) |
16898 break; | 16844 break; |
16899 } | |
16900 } | 16845 } |
16901 #endif | 16846 #endif |
16902 } | 16847 } |
16903 | 16848 |
16904 | 16849 |
17022 char_u fname[MAXPATHL + 1]; | 16967 char_u fname[MAXPATHL + 1]; |
17023 tagname_T tn; | 16968 tagname_T tn; |
17024 int first; | 16969 int first; |
17025 | 16970 |
17026 if (rettv_list_alloc(rettv) == FAIL) | 16971 if (rettv_list_alloc(rettv) == FAIL) |
17027 { | |
17028 rettv->vval.v_number = 0; | |
17029 return; | 16972 return; |
17030 } | |
17031 | 16973 |
17032 for (first = TRUE; ; first = FALSE) | 16974 for (first = TRUE; ; first = FALSE) |
17033 if (get_tagfname(&tn, first, fname) == FAIL | 16975 if (get_tagfname(&tn, first, fname) == FAIL |
17034 || list_append_string(rettv->vval.v_list, fname, -1) == FAIL) | 16976 || list_append_string(rettv->vval.v_list, fname, -1) == FAIL) |
17035 break; | 16977 break; |
17399 rettv->vval.v_string = vim_strsave(str); | 17341 rettv->vval.v_string = vim_strsave(str); |
17400 | 17342 |
17401 /* A non-zero number or non-empty string argument: reset mode. */ | 17343 /* A non-zero number or non-empty string argument: reset mode. */ |
17402 if (non_zero_arg(&argvars[0])) | 17344 if (non_zero_arg(&argvars[0])) |
17403 curbuf->b_visual_mode_eval = NUL; | 17345 curbuf->b_visual_mode_eval = NUL; |
17404 #else | |
17405 rettv->vval.v_number = 0; /* return anything, it won't work anyway */ | |
17406 #endif | 17346 #endif |
17407 } | 17347 } |
17408 | 17348 |
17409 /* | 17349 /* |
17410 * "winbufnr(nr)" function | 17350 * "winbufnr(nr)" function |