Mercurial > vim
comparison src/evalfunc.c @ 17940:079e10a49ea1 v8.1.1966
patch 8.1.1966: some code in options.c fits better elsewhere
Commit: https://github.com/vim/vim/commit/e677df8d93772a705f40a94f3c871aee78fe4d99
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 2 22:31:11 2019 +0200
patch 8.1.1966: some code in options.c fits better elsewhere
Problem: Some code in options.c fits better elsewhere.
Solution: Move functions from options.c to other files. (Yegappan
Lakshmanan, closes #4889)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 02 Sep 2019 22:45:05 +0200 |
parents | 0cdb6ac20748 |
children | 664cc72f50c5 |
comparison
equal
deleted
inserted
replaced
17939:252ad11554ff | 17940:079e10a49ea1 |
---|---|
23 #ifdef MACOS_X | 23 #ifdef MACOS_X |
24 # include <time.h> // for time_t | 24 # include <time.h> // for time_t |
25 #endif | 25 #endif |
26 | 26 |
27 static char *e_listblobarg = N_("E899: Argument of %s must be a List or Blob"); | 27 static char *e_listblobarg = N_("E899: Argument of %s must be a List or Blob"); |
28 static char *e_stringreq = N_("E928: String required"); | |
29 | 28 |
30 #ifdef FEAT_FLOAT | 29 #ifdef FEAT_FLOAT |
31 static void f_abs(typval_T *argvars, typval_T *rettv); | 30 static void f_abs(typval_T *argvars, typval_T *rettv); |
32 static void f_acos(typval_T *argvars, typval_T *rettv); | 31 static void f_acos(typval_T *argvars, typval_T *rettv); |
33 #endif | 32 #endif |
139 static void f_getfsize(typval_T *argvars, typval_T *rettv); | 138 static void f_getfsize(typval_T *argvars, typval_T *rettv); |
140 static void f_getftime(typval_T *argvars, typval_T *rettv); | 139 static void f_getftime(typval_T *argvars, typval_T *rettv); |
141 static void f_getftype(typval_T *argvars, typval_T *rettv); | 140 static void f_getftype(typval_T *argvars, typval_T *rettv); |
142 static void f_getjumplist(typval_T *argvars, typval_T *rettv); | 141 static void f_getjumplist(typval_T *argvars, typval_T *rettv); |
143 static void f_getline(typval_T *argvars, typval_T *rettv); | 142 static void f_getline(typval_T *argvars, typval_T *rettv); |
144 static void f_getloclist(typval_T *argvars UNUSED, typval_T *rettv UNUSED); | |
145 static void f_getpid(typval_T *argvars, typval_T *rettv); | 143 static void f_getpid(typval_T *argvars, typval_T *rettv); |
146 static void f_getcurpos(typval_T *argvars, typval_T *rettv); | 144 static void f_getcurpos(typval_T *argvars, typval_T *rettv); |
147 static void f_getpos(typval_T *argvars, typval_T *rettv); | 145 static void f_getpos(typval_T *argvars, typval_T *rettv); |
148 static void f_getqflist(typval_T *argvars, typval_T *rettv); | |
149 static void f_getreg(typval_T *argvars, typval_T *rettv); | 146 static void f_getreg(typval_T *argvars, typval_T *rettv); |
150 static void f_getregtype(typval_T *argvars, typval_T *rettv); | 147 static void f_getregtype(typval_T *argvars, typval_T *rettv); |
151 static void f_gettabinfo(typval_T *argvars, typval_T *rettv); | 148 static void f_gettabinfo(typval_T *argvars, typval_T *rettv); |
152 static void f_gettagstack(typval_T *argvars, typval_T *rettv); | 149 static void f_gettagstack(typval_T *argvars, typval_T *rettv); |
153 static void f_getwininfo(typval_T *argvars, typval_T *rettv); | 150 static void f_getwininfo(typval_T *argvars, typval_T *rettv); |
277 static void f_setcharsearch(typval_T *argvars, typval_T *rettv); | 274 static void f_setcharsearch(typval_T *argvars, typval_T *rettv); |
278 static void f_setcmdpos(typval_T *argvars, typval_T *rettv); | 275 static void f_setcmdpos(typval_T *argvars, typval_T *rettv); |
279 static void f_setenv(typval_T *argvars, typval_T *rettv); | 276 static void f_setenv(typval_T *argvars, typval_T *rettv); |
280 static void f_setfperm(typval_T *argvars, typval_T *rettv); | 277 static void f_setfperm(typval_T *argvars, typval_T *rettv); |
281 static void f_setline(typval_T *argvars, typval_T *rettv); | 278 static void f_setline(typval_T *argvars, typval_T *rettv); |
282 static void f_setloclist(typval_T *argvars, typval_T *rettv); | |
283 static void f_setpos(typval_T *argvars, typval_T *rettv); | 279 static void f_setpos(typval_T *argvars, typval_T *rettv); |
284 static void f_setqflist(typval_T *argvars, typval_T *rettv); | |
285 static void f_setreg(typval_T *argvars, typval_T *rettv); | 280 static void f_setreg(typval_T *argvars, typval_T *rettv); |
286 static void f_settagstack(typval_T *argvars, typval_T *rettv); | 281 static void f_settagstack(typval_T *argvars, typval_T *rettv); |
287 #ifdef FEAT_CRYPT | 282 #ifdef FEAT_CRYPT |
288 static void f_sha256(typval_T *argvars, typval_T *rettv); | 283 static void f_sha256(typval_T *argvars, typval_T *rettv); |
289 #endif /* FEAT_CRYPT */ | 284 #endif /* FEAT_CRYPT */ |
4769 } | 4764 } |
4770 | 4765 |
4771 get_buffer_lines(curbuf, lnum, end, retlist, rettv); | 4766 get_buffer_lines(curbuf, lnum, end, retlist, rettv); |
4772 } | 4767 } |
4773 | 4768 |
4774 #ifdef FEAT_QUICKFIX | |
4775 static void | |
4776 get_qf_loc_list(int is_qf, win_T *wp, typval_T *what_arg, typval_T *rettv) | |
4777 { | |
4778 if (what_arg->v_type == VAR_UNKNOWN) | |
4779 { | |
4780 if (rettv_list_alloc(rettv) == OK) | |
4781 if (is_qf || wp != NULL) | |
4782 (void)get_errorlist(NULL, wp, -1, rettv->vval.v_list); | |
4783 } | |
4784 else | |
4785 { | |
4786 if (rettv_dict_alloc(rettv) == OK) | |
4787 if (is_qf || (wp != NULL)) | |
4788 { | |
4789 if (what_arg->v_type == VAR_DICT) | |
4790 { | |
4791 dict_T *d = what_arg->vval.v_dict; | |
4792 | |
4793 if (d != NULL) | |
4794 qf_get_properties(wp, d, rettv->vval.v_dict); | |
4795 } | |
4796 else | |
4797 emsg(_(e_dictreq)); | |
4798 } | |
4799 } | |
4800 } | |
4801 #endif | |
4802 | |
4803 /* | |
4804 * "getloclist()" function | |
4805 */ | |
4806 static void | |
4807 f_getloclist(typval_T *argvars UNUSED, typval_T *rettv UNUSED) | |
4808 { | |
4809 #ifdef FEAT_QUICKFIX | |
4810 win_T *wp; | |
4811 | |
4812 wp = find_win_by_nr_or_id(&argvars[0]); | |
4813 get_qf_loc_list(FALSE, wp, &argvars[1], rettv); | |
4814 #endif | |
4815 } | |
4816 | |
4817 /* | 4769 /* |
4818 * "getpid()" function | 4770 * "getpid()" function |
4819 */ | 4771 */ |
4820 static void | 4772 static void |
4821 f_getpid(typval_T *argvars UNUSED, typval_T *rettv) | 4773 f_getpid(typval_T *argvars UNUSED, typval_T *rettv) |
4890 */ | 4842 */ |
4891 static void | 4843 static void |
4892 f_getpos(typval_T *argvars, typval_T *rettv) | 4844 f_getpos(typval_T *argvars, typval_T *rettv) |
4893 { | 4845 { |
4894 getpos_both(argvars, rettv, FALSE); | 4846 getpos_both(argvars, rettv, FALSE); |
4895 } | |
4896 | |
4897 /* | |
4898 * "getqflist()" function | |
4899 */ | |
4900 static void | |
4901 f_getqflist(typval_T *argvars UNUSED, typval_T *rettv UNUSED) | |
4902 { | |
4903 #ifdef FEAT_QUICKFIX | |
4904 get_qf_loc_list(TRUE, NULL, &argvars[0], rettv); | |
4905 #endif | |
4906 } | 4847 } |
4907 | 4848 |
4908 /* | 4849 /* |
4909 * "getreg()" function | 4850 * "getreg()" function |
4910 */ | 4851 */ |
9624 | 9565 |
9625 set_buffer_lines(curbuf, lnum, FALSE, &argvars[1], rettv); | 9566 set_buffer_lines(curbuf, lnum, FALSE, &argvars[1], rettv); |
9626 } | 9567 } |
9627 | 9568 |
9628 /* | 9569 /* |
9629 * Used by "setqflist()" and "setloclist()" functions | |
9630 */ | |
9631 static void | |
9632 set_qf_ll_list( | |
9633 win_T *wp UNUSED, | |
9634 typval_T *list_arg UNUSED, | |
9635 typval_T *action_arg UNUSED, | |
9636 typval_T *what_arg UNUSED, | |
9637 typval_T *rettv) | |
9638 { | |
9639 #ifdef FEAT_QUICKFIX | |
9640 static char *e_invact = N_("E927: Invalid action: '%s'"); | |
9641 char_u *act; | |
9642 int action = 0; | |
9643 static int recursive = 0; | |
9644 #endif | |
9645 | |
9646 rettv->vval.v_number = -1; | |
9647 | |
9648 #ifdef FEAT_QUICKFIX | |
9649 if (list_arg->v_type != VAR_LIST) | |
9650 emsg(_(e_listreq)); | |
9651 else if (recursive != 0) | |
9652 emsg(_(e_au_recursive)); | |
9653 else | |
9654 { | |
9655 list_T *l = list_arg->vval.v_list; | |
9656 dict_T *d = NULL; | |
9657 int valid_dict = TRUE; | |
9658 | |
9659 if (action_arg->v_type == VAR_STRING) | |
9660 { | |
9661 act = tv_get_string_chk(action_arg); | |
9662 if (act == NULL) | |
9663 return; /* type error; errmsg already given */ | |
9664 if ((*act == 'a' || *act == 'r' || *act == ' ' || *act == 'f') && | |
9665 act[1] == NUL) | |
9666 action = *act; | |
9667 else | |
9668 semsg(_(e_invact), act); | |
9669 } | |
9670 else if (action_arg->v_type == VAR_UNKNOWN) | |
9671 action = ' '; | |
9672 else | |
9673 emsg(_(e_stringreq)); | |
9674 | |
9675 if (action_arg->v_type != VAR_UNKNOWN | |
9676 && what_arg->v_type != VAR_UNKNOWN) | |
9677 { | |
9678 if (what_arg->v_type == VAR_DICT) | |
9679 d = what_arg->vval.v_dict; | |
9680 else | |
9681 { | |
9682 emsg(_(e_dictreq)); | |
9683 valid_dict = FALSE; | |
9684 } | |
9685 } | |
9686 | |
9687 ++recursive; | |
9688 if (l != NULL && action && valid_dict && set_errorlist(wp, l, action, | |
9689 (char_u *)(wp == NULL ? ":setqflist()" : ":setloclist()"), | |
9690 d) == OK) | |
9691 rettv->vval.v_number = 0; | |
9692 --recursive; | |
9693 } | |
9694 #endif | |
9695 } | |
9696 | |
9697 /* | |
9698 * "setloclist()" function | |
9699 */ | |
9700 static void | |
9701 f_setloclist(typval_T *argvars, typval_T *rettv) | |
9702 { | |
9703 win_T *win; | |
9704 | |
9705 rettv->vval.v_number = -1; | |
9706 | |
9707 win = find_win_by_nr_or_id(&argvars[0]); | |
9708 if (win != NULL) | |
9709 set_qf_ll_list(win, &argvars[1], &argvars[2], &argvars[3], rettv); | |
9710 } | |
9711 | |
9712 /* | |
9713 * "setpos()" function | 9570 * "setpos()" function |
9714 */ | 9571 */ |
9715 static void | 9572 static void |
9716 f_setpos(typval_T *argvars, typval_T *rettv) | 9573 f_setpos(typval_T *argvars, typval_T *rettv) |
9717 { | 9574 { |
9748 } | 9605 } |
9749 else | 9606 else |
9750 emsg(_(e_invarg)); | 9607 emsg(_(e_invarg)); |
9751 } | 9608 } |
9752 } | 9609 } |
9753 } | |
9754 | |
9755 /* | |
9756 * "setqflist()" function | |
9757 */ | |
9758 static void | |
9759 f_setqflist(typval_T *argvars, typval_T *rettv) | |
9760 { | |
9761 set_qf_ll_list(NULL, &argvars[0], &argvars[1], &argvars[2], rettv); | |
9762 } | 9610 } |
9763 | 9611 |
9764 /* | 9612 /* |
9765 * "setreg()" function | 9613 * "setreg()" function |
9766 */ | 9614 */ |