0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 7.4.1337

Problem:    Part of the change is missing.
Solution:   Add changes to eval.c
This commit is contained in:
Bram Moolenaar
2016-02-16 19:37:29 +01:00
parent 9a6e33a19b
commit ba093bc000
2 changed files with 63 additions and 26 deletions

View File

@@ -7535,7 +7535,7 @@ get_dict_string(dict_T *d, char_u *key, int save)
/* /*
* Get a number item from a dictionary. * Get a number item from a dictionary.
* Returns 0 if the entry doesn't exist or out of memory. * Returns 0 if the entry doesn't exist.
*/ */
long long
get_dict_number(dict_T *d, char_u *key) get_dict_number(dict_T *d, char_u *key)
@@ -9929,6 +9929,36 @@ f_ch_logfile(typval_T *argvars, typval_T *rettv UNUSED)
ch_logfile(file); ch_logfile(file);
} }
/*
* Get the "mode" entry from "dict", if it exists, and parse the mode name.
* If the mode is invalide return FAIL.
*/
static int
get_mode_arg(dict_T *dict, jobopt_T *opt)
{
dictitem_T *item;
char_u *mode;
if ((item = dict_find(dict, (char_u *)"mode", -1)) != NULL)
{
mode = get_tv_string(&item->di_tv);
if (STRCMP(mode, "nl") == 0)
opt->jo_mode = MODE_NL;
else if (STRCMP(mode, "raw") == 0)
opt->jo_mode = MODE_RAW;
else if (STRCMP(mode, "js") == 0)
opt->jo_mode = MODE_JS;
else if (STRCMP(mode, "json") == 0)
opt->jo_mode = MODE_JSON;
else
{
EMSG2(_(e_invarg2), mode);
return FAIL;
}
}
return OK;
}
/* /*
* "ch_open()" function * "ch_open()" function
*/ */
@@ -9936,14 +9966,13 @@ f_ch_logfile(typval_T *argvars, typval_T *rettv UNUSED)
f_ch_open(typval_T *argvars, typval_T *rettv) f_ch_open(typval_T *argvars, typval_T *rettv)
{ {
char_u *address; char_u *address;
char_u *mode;
char_u *callback = NULL; char_u *callback = NULL;
char_u *p; char_u *p;
char *rest; char *rest;
int port; int port;
int waittime = 0; int waittime = 0;
int timeout = 2000; int timeout = 2000;
ch_mode_T ch_mode = MODE_JSON; jobopt_T options;
channel_T *channel; channel_T *channel;
/* default: fail */ /* default: fail */
@@ -9974,27 +10003,15 @@ f_ch_open(typval_T *argvars, typval_T *rettv)
return; return;
} }
options.jo_mode = MODE_JSON;
if (argvars[1].v_type == VAR_DICT) if (argvars[1].v_type == VAR_DICT)
{ {
dict_T *dict = argvars[1].vval.v_dict; dict_T *dict = argvars[1].vval.v_dict;
dictitem_T *item; dictitem_T *item;
/* parse argdict */ /* parse argdict */
if ((item = dict_find(dict, (char_u *)"mode", -1)) != NULL) if (get_mode_arg(dict, &options) == FAIL)
{
mode = get_tv_string(&item->di_tv);
if (STRCMP(mode, "raw") == 0)
ch_mode = MODE_RAW;
else if (STRCMP(mode, "js") == 0)
ch_mode = MODE_JS;
else if (STRCMP(mode, "json") == 0)
ch_mode = MODE_JSON;
else
{
EMSG2(_(e_invarg2), mode);
return; return;
}
}
if ((item = dict_find(dict, (char_u *)"waittime", -1)) != NULL) if ((item = dict_find(dict, (char_u *)"waittime", -1)) != NULL)
waittime = get_tv_number(&item->di_tv); waittime = get_tv_number(&item->di_tv);
if ((item = dict_find(dict, (char_u *)"timeout", -1)) != NULL) if ((item = dict_find(dict, (char_u *)"timeout", -1)) != NULL)
@@ -10012,7 +10029,7 @@ f_ch_open(typval_T *argvars, typval_T *rettv)
if (channel != NULL) if (channel != NULL)
{ {
rettv->vval.v_channel = channel; rettv->vval.v_channel = channel;
channel_set_json_mode(channel, ch_mode); channel_set_mode(channel, options.jo_mode);
channel_set_timeout(channel, timeout); channel_set_timeout(channel, timeout);
if (callback != NULL && *callback != NUL) if (callback != NULL && *callback != NUL)
channel_set_callback(channel, callback); channel_set_callback(channel, callback);
@@ -14482,6 +14499,7 @@ f_job_start(typval_T *argvars UNUSED, typval_T *rettv)
#else #else
garray_T ga; garray_T ga;
#endif #endif
jobopt_T options;
rettv->v_type = VAR_JOB; rettv->v_type = VAR_JOB;
job = job_alloc(); job = job_alloc();
@@ -14490,6 +14508,23 @@ f_job_start(typval_T *argvars UNUSED, typval_T *rettv)
return; return;
rettv->vval.v_job->jv_status = JOB_FAILED; rettv->vval.v_job->jv_status = JOB_FAILED;
/* Default mode is NL. */
options.jo_mode = MODE_NL;
if (argvars[1].v_type != VAR_UNKNOWN)
{
dict_T *dict;
if (argvars[1].v_type != VAR_DICT)
{
EMSG(_(e_invarg));
return;
}
dict = argvars[1].vval.v_dict;
if (get_mode_arg(dict, &options) == FAIL)
return;
}
#ifndef USE_ARGV #ifndef USE_ARGV
ga_init2(&ga, (int)sizeof(char*), 20); ga_init2(&ga, (int)sizeof(char*), 20);
#endif #endif
@@ -14552,9 +14587,9 @@ f_job_start(typval_T *argvars UNUSED, typval_T *rettv)
#endif #endif
} }
#ifdef USE_ARGV #ifdef USE_ARGV
mch_start_job(argv, job); mch_start_job(argv, job, &options);
#else #else
mch_start_job((char *)cmd, job); mch_start_job((char *)cmd, job, &options);
#endif #endif
theend: theend:

View File

@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1337,
/**/ /**/
1336, 1336,
/**/ /**/