Skip to content

Commit cd39bbc

Browse files
committed
patch 7.4.1343
Problem: Can't compile with +job but without +channel. (Andrei Olsen) Solution: Move get_job_options up and adjust #ifdef.
1 parent e74e8e7 commit cd39bbc

File tree

2 files changed

+64
-60
lines changed

2 files changed

+64
-60
lines changed

src/eval.c

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -9850,6 +9850,68 @@ f_ceil(typval_T *argvars, typval_T *rettv)
98509850
}
98519851
#endif
98529852

9853+
#if defined(FEAT_CHANNEL) || defined(FEAT_JOB)
9854+
/*
9855+
* Get a callback from "arg". It can be a Funcref or a function name.
9856+
* When "arg" is zero return an empty string.
9857+
* Return NULL for an invalid argument.
9858+
*/
9859+
static char_u *
9860+
get_callback(typval_T *arg)
9861+
{
9862+
if (arg->v_type == VAR_FUNC || arg->v_type == VAR_STRING)
9863+
return arg->vval.v_string;
9864+
if (arg->v_type == VAR_NUMBER && arg->vval.v_number == 0)
9865+
return (char_u *)"";
9866+
EMSG(_("E999: Invalid callback argument"));
9867+
return NULL;
9868+
}
9869+
9870+
/*
9871+
* Get the option entries from "dict", and parse them.
9872+
* If an option value is invalid return FAIL.
9873+
*/
9874+
static int
9875+
get_job_options(dict_T *dict, jobopt_T *opt)
9876+
{
9877+
dictitem_T *item;
9878+
char_u *mode;
9879+
9880+
if (dict == NULL)
9881+
return OK;
9882+
9883+
if ((item = dict_find(dict, (char_u *)"mode", -1)) != NULL)
9884+
{
9885+
mode = get_tv_string(&item->di_tv);
9886+
if (STRCMP(mode, "nl") == 0)
9887+
opt->jo_mode = MODE_NL;
9888+
else if (STRCMP(mode, "raw") == 0)
9889+
opt->jo_mode = MODE_RAW;
9890+
else if (STRCMP(mode, "js") == 0)
9891+
opt->jo_mode = MODE_JS;
9892+
else if (STRCMP(mode, "json") == 0)
9893+
opt->jo_mode = MODE_JSON;
9894+
else
9895+
{
9896+
EMSG2(_(e_invarg2), mode);
9897+
return FAIL;
9898+
}
9899+
}
9900+
9901+
if ((item = dict_find(dict, (char_u *)"callback", -1)) != NULL)
9902+
{
9903+
opt->jo_callback = get_callback(&item->di_tv);
9904+
if (opt->jo_callback == NULL)
9905+
{
9906+
EMSG2(_(e_invarg2), "callback");
9907+
return FAIL;
9908+
}
9909+
}
9910+
9911+
return OK;
9912+
}
9913+
#endif
9914+
98539915
#ifdef FEAT_CHANNEL
98549916
/*
98559917
* Get the channel from the argument.
@@ -9887,22 +9949,6 @@ f_ch_close(typval_T *argvars, typval_T *rettv UNUSED)
98879949
channel_close(channel);
98889950
}
98899951

9890-
/*
9891-
* Get a callback from "arg". It can be a Funcref or a function name.
9892-
* When "arg" is zero return an empty string.
9893-
* Return NULL for an invalid argument.
9894-
*/
9895-
static char_u *
9896-
get_callback(typval_T *arg)
9897-
{
9898-
if (arg->v_type == VAR_FUNC || arg->v_type == VAR_STRING)
9899-
return arg->vval.v_string;
9900-
if (arg->v_type == VAR_NUMBER && arg->vval.v_number == 0)
9901-
return (char_u *)"";
9902-
EMSG(_("E999: Invalid callback argument"));
9903-
return NULL;
9904-
}
9905-
99069952
/*
99079953
* "ch_logfile()" function
99089954
*/
@@ -9929,50 +9975,6 @@ f_ch_logfile(typval_T *argvars, typval_T *rettv UNUSED)
99299975
ch_logfile(file);
99309976
}
99319977

9932-
/*
9933-
* Get the option entries from "dict", and parse them.
9934-
* If an option value is invalid return FAIL.
9935-
*/
9936-
static int
9937-
get_job_options(dict_T *dict, jobopt_T *opt)
9938-
{
9939-
dictitem_T *item;
9940-
char_u *mode;
9941-
9942-
if (dict == NULL)
9943-
return OK;
9944-
9945-
if ((item = dict_find(dict, (char_u *)"mode", -1)) != NULL)
9946-
{
9947-
mode = get_tv_string(&item->di_tv);
9948-
if (STRCMP(mode, "nl") == 0)
9949-
opt->jo_mode = MODE_NL;
9950-
else if (STRCMP(mode, "raw") == 0)
9951-
opt->jo_mode = MODE_RAW;
9952-
else if (STRCMP(mode, "js") == 0)
9953-
opt->jo_mode = MODE_JS;
9954-
else if (STRCMP(mode, "json") == 0)
9955-
opt->jo_mode = MODE_JSON;
9956-
else
9957-
{
9958-
EMSG2(_(e_invarg2), mode);
9959-
return FAIL;
9960-
}
9961-
}
9962-
9963-
if ((item = dict_find(dict, (char_u *)"callback", -1)) != NULL)
9964-
{
9965-
opt->jo_callback = get_callback(&item->di_tv);
9966-
if (opt->jo_callback == NULL)
9967-
{
9968-
EMSG2(_(e_invarg2), "callback");
9969-
return FAIL;
9970-
}
9971-
}
9972-
9973-
return OK;
9974-
}
9975-
99769978
/*
99779979
* "ch_open()" function
99789980
*/

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,8 @@ static char *(features[]) =
747747

748748
static int included_patches[] =
749749
{ /* Add new patch number below this line */
750+
/**/
751+
1343,
750752
/**/
751753
1342,
752754
/**/

0 commit comments

Comments
 (0)