Skip to content

Commit e677df8

Browse files
committed
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)
1 parent 359ad1a commit e677df8

16 files changed

Lines changed: 1066 additions & 1071 deletions

src/evalfunc.c

Lines changed: 0 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#endif
2626

2727
static char *e_listblobarg = N_("E899: Argument of %s must be a List or Blob");
28-
static char *e_stringreq = N_("E928: String required");
2928

3029
#ifdef FEAT_FLOAT
3130
static void f_abs(typval_T *argvars, typval_T *rettv);
@@ -141,11 +140,9 @@ static void f_getftime(typval_T *argvars, typval_T *rettv);
141140
static void f_getftype(typval_T *argvars, typval_T *rettv);
142141
static void f_getjumplist(typval_T *argvars, typval_T *rettv);
143142
static void f_getline(typval_T *argvars, typval_T *rettv);
144-
static void f_getloclist(typval_T *argvars UNUSED, typval_T *rettv UNUSED);
145143
static void f_getpid(typval_T *argvars, typval_T *rettv);
146144
static void f_getcurpos(typval_T *argvars, typval_T *rettv);
147145
static void f_getpos(typval_T *argvars, typval_T *rettv);
148-
static void f_getqflist(typval_T *argvars, typval_T *rettv);
149146
static void f_getreg(typval_T *argvars, typval_T *rettv);
150147
static void f_getregtype(typval_T *argvars, typval_T *rettv);
151148
static void f_gettabinfo(typval_T *argvars, typval_T *rettv);
@@ -279,9 +276,7 @@ static void f_setcmdpos(typval_T *argvars, typval_T *rettv);
279276
static void f_setenv(typval_T *argvars, typval_T *rettv);
280277
static void f_setfperm(typval_T *argvars, typval_T *rettv);
281278
static void f_setline(typval_T *argvars, typval_T *rettv);
282-
static void f_setloclist(typval_T *argvars, typval_T *rettv);
283279
static void f_setpos(typval_T *argvars, typval_T *rettv);
284-
static void f_setqflist(typval_T *argvars, typval_T *rettv);
285280
static void f_setreg(typval_T *argvars, typval_T *rettv);
286281
static void f_settagstack(typval_T *argvars, typval_T *rettv);
287282
#ifdef FEAT_CRYPT
@@ -4771,49 +4766,6 @@ f_getline(typval_T *argvars, typval_T *rettv)
47714766
get_buffer_lines(curbuf, lnum, end, retlist, rettv);
47724767
}
47734768

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-
48174769
/*
48184770
* "getpid()" function
48194771
*/
@@ -4894,17 +4846,6 @@ f_getpos(typval_T *argvars, typval_T *rettv)
48944846
getpos_both(argvars, rettv, FALSE);
48954847
}
48964848

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-
}
4907-
49084849
/*
49094850
* "getreg()" function
49104851
*/
@@ -9625,90 +9566,6 @@ f_setline(typval_T *argvars, typval_T *rettv)
96259566
set_buffer_lines(curbuf, lnum, FALSE, &argvars[1], rettv);
96269567
}
96279568

9628-
/*
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-
97129569
/*
97139570
* "setpos()" function
97149571
*/
@@ -9752,15 +9609,6 @@ f_setpos(typval_T *argvars, typval_T *rettv)
97529609
}
97539610
}
97549611

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-
}
9763-
97649612
/*
97659613
* "setreg()" function
97669614
*/

src/globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,7 @@ EXTERN char e_illvar[] INIT(= N_("E461: Illegal variable name: %s"));
15501550
EXTERN char e_cannot_mod[] INIT(= N_("E995: Cannot modify existing variable"));
15511551
EXTERN char e_readonlyvar[] INIT(= N_("E46: Cannot change read-only variable \"%s\""));
15521552
EXTERN char e_readonlysbx[] INIT(= N_("E794: Cannot set variable in the sandbox: \"%s\""));
1553+
EXTERN char e_stringreq[] INIT(= N_("E928: String required"));
15531554
EXTERN char e_emptykey[] INIT(= N_("E713: Cannot use empty key for Dictionary"));
15541555
EXTERN char e_dictreq[] INIT(= N_("E715: Dictionary required"));
15551556
EXTERN char e_listidx[] INIT(= N_("E684: list index out of range: %ld"));

0 commit comments

Comments
 (0)