comparison src/evalfunc.c @ 17488:bba80d61ea73 v8.1.1742

patch 8.1.1742: still some match functions in evalfunc.c commit https://github.com/vim/vim/commit/7dfb016d25e3e3e1f4411026dda21d1536f21acc Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jul 24 16:00:39 2019 +0200 patch 8.1.1742: still some match functions in evalfunc.c Problem: Still some match functions in evalfunc.c. Solution: Move them to highlight.c.
author Bram Moolenaar <Bram@vim.org>
date Wed, 24 Jul 2019 16:15:05 +0200
parents f1fd0b0b335c
children 74b6674b99fd
comparison
equal deleted inserted replaced
17487:a9fd9cb70c4f 17488:bba80d61ea73
72 #endif 72 #endif
73 static void f_changenr(typval_T *argvars, typval_T *rettv); 73 static void f_changenr(typval_T *argvars, typval_T *rettv);
74 static void f_char2nr(typval_T *argvars, typval_T *rettv); 74 static void f_char2nr(typval_T *argvars, typval_T *rettv);
75 static void f_chdir(typval_T *argvars, typval_T *rettv); 75 static void f_chdir(typval_T *argvars, typval_T *rettv);
76 static void f_cindent(typval_T *argvars, typval_T *rettv); 76 static void f_cindent(typval_T *argvars, typval_T *rettv);
77 static void f_clearmatches(typval_T *argvars, typval_T *rettv);
78 static void f_col(typval_T *argvars, typval_T *rettv); 77 static void f_col(typval_T *argvars, typval_T *rettv);
79 #if defined(FEAT_INS_EXPAND) 78 #if defined(FEAT_INS_EXPAND)
80 static void f_complete(typval_T *argvars, typval_T *rettv); 79 static void f_complete(typval_T *argvars, typval_T *rettv);
81 static void f_complete_add(typval_T *argvars, typval_T *rettv); 80 static void f_complete_add(typval_T *argvars, typval_T *rettv);
82 static void f_complete_check(typval_T *argvars, typval_T *rettv); 81 static void f_complete_check(typval_T *argvars, typval_T *rettv);
312 static void f_setcmdpos(typval_T *argvars, typval_T *rettv); 311 static void f_setcmdpos(typval_T *argvars, typval_T *rettv);
313 static void f_setenv(typval_T *argvars, typval_T *rettv); 312 static void f_setenv(typval_T *argvars, typval_T *rettv);
314 static void f_setfperm(typval_T *argvars, typval_T *rettv); 313 static void f_setfperm(typval_T *argvars, typval_T *rettv);
315 static void f_setline(typval_T *argvars, typval_T *rettv); 314 static void f_setline(typval_T *argvars, typval_T *rettv);
316 static void f_setloclist(typval_T *argvars, typval_T *rettv); 315 static void f_setloclist(typval_T *argvars, typval_T *rettv);
317 static void f_setmatches(typval_T *argvars, typval_T *rettv);
318 static void f_setpos(typval_T *argvars, typval_T *rettv); 316 static void f_setpos(typval_T *argvars, typval_T *rettv);
319 static void f_setqflist(typval_T *argvars, typval_T *rettv); 317 static void f_setqflist(typval_T *argvars, typval_T *rettv);
320 static void f_setreg(typval_T *argvars, typval_T *rettv); 318 static void f_setreg(typval_T *argvars, typval_T *rettv);
321 static void f_settabvar(typval_T *argvars, typval_T *rettv); 319 static void f_settabvar(typval_T *argvars, typval_T *rettv);
322 static void f_settabwinvar(typval_T *argvars, typval_T *rettv); 320 static void f_settabwinvar(typval_T *argvars, typval_T *rettv);
2207 } 2205 }
2208 return win; 2206 return win;
2209 } 2207 }
2210 2208
2211 /* 2209 /*
2212 * "clearmatches()" function
2213 */
2214 static void
2215 f_clearmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
2216 {
2217 #ifdef FEAT_SEARCH_EXTRA
2218 win_T *win = get_optional_window(argvars, 0);
2219
2220 if (win != NULL)
2221 clear_matches(win);
2222 #endif
2223 }
2224
2225 /*
2226 * "col(string)" function 2210 * "col(string)" function
2227 */ 2211 */
2228 static void 2212 static void
2229 f_col(typval_T *argvars, typval_T *rettv) 2213 f_col(typval_T *argvars, typval_T *rettv)
2230 { 2214 {
10739 if (win != NULL) 10723 if (win != NULL)
10740 set_qf_ll_list(win, &argvars[1], &argvars[2], &argvars[3], rettv); 10724 set_qf_ll_list(win, &argvars[1], &argvars[2], &argvars[3], rettv);
10741 } 10725 }
10742 10726
10743 /* 10727 /*
10744 * "setmatches()" function
10745 */
10746 static void
10747 f_setmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
10748 {
10749 #ifdef FEAT_SEARCH_EXTRA
10750 list_T *l;
10751 listitem_T *li;
10752 dict_T *d;
10753 list_T *s = NULL;
10754 win_T *win = get_optional_window(argvars, 1);
10755
10756 rettv->vval.v_number = -1;
10757 if (argvars[0].v_type != VAR_LIST)
10758 {
10759 emsg(_(e_listreq));
10760 return;
10761 }
10762 if (win == NULL)
10763 return;
10764
10765 if ((l = argvars[0].vval.v_list) != NULL)
10766 {
10767 /* To some extent make sure that we are dealing with a list from
10768 * "getmatches()". */
10769 li = l->lv_first;
10770 while (li != NULL)
10771 {
10772 if (li->li_tv.v_type != VAR_DICT
10773 || (d = li->li_tv.vval.v_dict) == NULL)
10774 {
10775 emsg(_(e_invarg));
10776 return;
10777 }
10778 if (!(dict_find(d, (char_u *)"group", -1) != NULL
10779 && (dict_find(d, (char_u *)"pattern", -1) != NULL
10780 || dict_find(d, (char_u *)"pos1", -1) != NULL)
10781 && dict_find(d, (char_u *)"priority", -1) != NULL
10782 && dict_find(d, (char_u *)"id", -1) != NULL))
10783 {
10784 emsg(_(e_invarg));
10785 return;
10786 }
10787 li = li->li_next;
10788 }
10789
10790 clear_matches(win);
10791 li = l->lv_first;
10792 while (li != NULL)
10793 {
10794 int i = 0;
10795 char buf[30]; // use 30 to avoid compiler warning
10796 dictitem_T *di;
10797 char_u *group;
10798 int priority;
10799 int id;
10800 char_u *conceal;
10801
10802 d = li->li_tv.vval.v_dict;
10803 if (dict_find(d, (char_u *)"pattern", -1) == NULL)
10804 {
10805 if (s == NULL)
10806 {
10807 s = list_alloc();
10808 if (s == NULL)
10809 return;
10810 }
10811
10812 /* match from matchaddpos() */
10813 for (i = 1; i < 9; i++)
10814 {
10815 sprintf((char *)buf, (char *)"pos%d", i);
10816 if ((di = dict_find(d, (char_u *)buf, -1)) != NULL)
10817 {
10818 if (di->di_tv.v_type != VAR_LIST)
10819 return;
10820
10821 list_append_tv(s, &di->di_tv);
10822 s->lv_refcount++;
10823 }
10824 else
10825 break;
10826 }
10827 }
10828
10829 group = dict_get_string(d, (char_u *)"group", TRUE);
10830 priority = (int)dict_get_number(d, (char_u *)"priority");
10831 id = (int)dict_get_number(d, (char_u *)"id");
10832 conceal = dict_find(d, (char_u *)"conceal", -1) != NULL
10833 ? dict_get_string(d, (char_u *)"conceal", TRUE)
10834 : NULL;
10835 if (i == 0)
10836 {
10837 match_add(win, group,
10838 dict_get_string(d, (char_u *)"pattern", FALSE),
10839 priority, id, NULL, conceal);
10840 }
10841 else
10842 {
10843 match_add(win, group, NULL, priority, id, s, conceal);
10844 list_unref(s);
10845 s = NULL;
10846 }
10847 vim_free(group);
10848 vim_free(conceal);
10849
10850 li = li->li_next;
10851 }
10852 rettv->vval.v_number = 0;
10853 }
10854 #endif
10855 }
10856
10857 /*
10858 * "setpos()" function 10728 * "setpos()" function
10859 */ 10729 */
10860 static void 10730 static void
10861 f_setpos(typval_T *argvars, typval_T *rettv) 10731 f_setpos(typval_T *argvars, typval_T *rettv)
10862 { 10732 {