summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-05-07 16:38:24 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-07 16:38:24 +0100
commitac4174e166dd76c72907caa76db0e7cd878ac667 (patch)
tree8f45dbf6515b163074ab1301f86650696459274d
parent48a8a833033e10fc1eba96f2fc8dd19c2408eddf (diff)
patch 8.2.4909: MODE_ enum entries names are too genericv8.2.4909
Problem: MODE_ enum entries names are too generic. Solution: use CH_MODE_.
-rw-r--r--src/channel.c74
-rw-r--r--src/job.c12
-rw-r--r--src/structs.h10
-rw-r--r--src/terminal.c9
-rw-r--r--src/version.c2
5 files changed, 56 insertions, 51 deletions
diff --git a/src/channel.c b/src/channel.c
index d6782e9182..52dfaafb3e 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1274,7 +1274,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
// writing output to a buffer. Default mode is NL.
if (!(opt->jo_set & JO_OUT_MODE))
- channel->ch_part[PART_OUT].ch_mode = MODE_NL;
+ channel->ch_part[PART_OUT].ch_mode = CH_MODE_NL;
if (opt->jo_set & JO_OUT_BUF)
{
buf = buflist_findnr(opt->jo_io_buf[PART_OUT]);
@@ -1320,7 +1320,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
// writing err to a buffer. Default mode is NL.
if (!(opt->jo_set & JO_ERR_MODE))
- channel->ch_part[PART_ERR].ch_mode = MODE_NL;
+ channel->ch_part[PART_ERR].ch_mode = CH_MODE_NL;
if (opt->jo_io[PART_ERR] == JIO_OUT)
buf = channel->ch_part[PART_OUT].ch_bufref.br_buf;
else if (opt->jo_set & JO_ERR_BUF)
@@ -1445,7 +1445,7 @@ channel_open_func(typval_T *argvars)
// parse options
clear_job_options(&opt);
- opt.jo_mode = MODE_JSON;
+ opt.jo_mode = CH_MODE_JSON;
opt.jo_timeout = 2000;
if (get_job_options(&argvars[1], &opt,
JO_MODE_ALL + JO_CB_ALL + JO_TIMEOUT_ALL
@@ -2051,9 +2051,9 @@ channel_collapse(channel_T *channel, ch_part_T part, int want_nl)
last_node = node->rq_next;
len = node->rq_buflen + last_node->rq_buflen;
- if (want_nl || mode == MODE_LSP)
+ if (want_nl || mode == CH_MODE_LSP)
while (last_node->rq_next != NULL
- && (mode == MODE_LSP
+ && (mode == CH_MODE_LSP
|| channel_first_nl(last_node) == NULL))
{
last_node = last_node->rq_next;
@@ -2118,7 +2118,7 @@ channel_save(channel_T *channel, ch_part_T part, char_u *buf, int len,
return FAIL; // out of memory
}
- if (channel->ch_part[part].ch_mode == MODE_NL)
+ if (channel->ch_part[part].ch_mode == CH_MODE_NL)
{
// Drop any CR before a NL.
p = node->rq_buffer;
@@ -2309,7 +2309,7 @@ channel_parse_json(channel_T *channel, ch_part_T part)
reader.js_cookie = channel;
reader.js_cookie_arg = part;
- if (chanpart->ch_mode == MODE_LSP)
+ if (chanpart->ch_mode == CH_MODE_LSP)
status = channel_process_lsp_http_hdr(&reader);
// When a message is incomplete we wait for a short while for more to
@@ -2320,20 +2320,20 @@ channel_parse_json(channel_T *channel, ch_part_T part)
{
++emsg_silent;
status = json_decode(&reader, &listtv,
- chanpart->ch_mode == MODE_JS ? JSON_JS : 0);
+ chanpart->ch_mode == CH_MODE_JS ? JSON_JS : 0);
--emsg_silent;
}
if (status == OK)
{
// Only accept the response when it is a list with at least two
// items.
- if (chanpart->ch_mode == MODE_LSP && listtv.v_type != VAR_DICT)
+ if (chanpart->ch_mode == CH_MODE_LSP && listtv.v_type != VAR_DICT)
{
ch_error(channel, "Did not receive a LSP dict, discarding");
clear_tv(&listtv);
}
- else if (chanpart->ch_mode != MODE_LSP &&
- (listtv.v_type != VAR_LIST || listtv.vval.v_list->lv_len < 2))
+ else if (chanpart->ch_mode != CH_MODE_LSP
+ && (listtv.v_type != VAR_LIST || listtv.vval.v_list->lv_len < 2))
{
if (listtv.v_type != VAR_LIST)
ch_error(channel, "Did not receive a list, discarding");
@@ -2563,7 +2563,7 @@ channel_get_json(
list_T *l;
typval_T *tv;
- if (channel->ch_part[part].ch_mode != MODE_LSP)
+ if (channel->ch_part[part].ch_mode != CH_MODE_LSP)
{
l = item->jq_value->vval.v_list;
CHECK_LIST_MATERIALIZE(l);
@@ -2684,7 +2684,8 @@ channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv)
{
char_u *cmd = argv[0].vval.v_string;
char_u *arg;
- int options = channel->ch_part[part].ch_mode == MODE_JS ? JSON_JS : 0;
+ int options = channel->ch_part[part].ch_mode == CH_MODE_JS
+ ? JSON_JS : 0;
if (argv[1].v_type != VAR_STRING)
{
@@ -2964,7 +2965,8 @@ channel_use_json_head(channel_T *channel, ch_part_T part)
{
ch_mode_T ch_mode = channel->ch_part[part].ch_mode;
- return ch_mode == MODE_JSON || ch_mode == MODE_JS || ch_mode == MODE_LSP;
+ return ch_mode == CH_MODE_JSON || ch_mode == CH_MODE_JS
+ || ch_mode == CH_MODE_LSP;
}
/*
@@ -3021,7 +3023,7 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
// Get any json message in the queue.
if (channel_get_json(channel, part, -1, FALSE, &listtv) == FAIL)
{
- if (ch_mode == MODE_LSP)
+ if (ch_mode == CH_MODE_LSP)
// In the "lsp" mode, the http header and the json payload may
// be received in multiple messages. So concatenate all the
// received messages.
@@ -3033,7 +3035,7 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
return FALSE;
}
- if (ch_mode == MODE_LSP)
+ if (ch_mode == CH_MODE_LSP)
{
dict_T *d = listtv->vval.v_dict;
dictitem_T *di;
@@ -3092,7 +3094,7 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
return FALSE;
}
- if (ch_mode == MODE_NL)
+ if (ch_mode == CH_MODE_NL)
{
char_u *nl = NULL;
char_u *buf;
@@ -3169,7 +3171,7 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
}
}
- if (seq_nr > 0 && (ch_mode != MODE_LSP || called_otc))
+ if (seq_nr > 0 && (ch_mode != CH_MODE_LSP || called_otc))
{
if (!called_otc)
{
@@ -3356,11 +3358,11 @@ channel_part_info(channel_T *channel, dict_T *dict, char *name, ch_part_T part)
STRCPY(namebuf + tail, "mode");
switch (chanpart->ch_mode)
{
- case MODE_NL: s = "NL"; break;
- case MODE_RAW: s = "RAW"; break;
- case MODE_JSON: s = "JSON"; break;
- case MODE_JS: s = "JS"; break;
- case MODE_LSP: s = "LSP"; break;
+ case CH_MODE_NL: s = "NL"; break;
+ case CH_MODE_RAW: s = "RAW"; break;
+ case CH_MODE_JSON: s = "JSON"; break;
+ case CH_MODE_JS: s = "JS"; break;
+ case CH_MODE_LSP: s = "LSP"; break;
}
dict_add_string(dict, namebuf, (char_u *)s);
@@ -3901,18 +3903,18 @@ channel_read_block(
readq_T *node;
ch_log(channel, "Blocking %s read, timeout: %d msec",
- mode == MODE_RAW ? "RAW" : "NL", timeout);
+ mode == CH_MODE_RAW ? "RAW" : "NL", timeout);
while (TRUE)
{
node = channel_peek(channel, part);
if (node != NULL)
{
- if (mode == MODE_RAW || (mode == MODE_NL
+ if (mode == CH_MODE_RAW || (mode == CH_MODE_NL
&& channel_first_nl(node) != NULL))
// got a complete message
break;
- if (channel_collapse(channel, part, mode == MODE_NL) == OK)
+ if (channel_collapse(channel, part, mode == CH_MODE_NL) == OK)
continue;
// If not blocking or nothing more is coming then return what we
// have.
@@ -3932,7 +3934,7 @@ channel_read_block(
}
// We have a complete message now.
- if (mode == MODE_RAW || outlen != NULL)
+ if (mode == CH_MODE_RAW || outlen != NULL)
{
msg = channel_get_all(channel, part, outlen);
}
@@ -4014,7 +4016,7 @@ channel_read_json_block(
for (;;)
{
- if (mode == MODE_LSP)
+ if (mode == CH_MODE_LSP)
// In the "lsp" mode, the http header and the json payload may be
// received in multiple messages. So concatenate all the received
// messages.
@@ -4201,7 +4203,7 @@ common_channel_read(typval_T *argvars, typval_T *rettv, int raw, int blob)
vim_free(p);
}
}
- else if (raw || mode == MODE_RAW || mode == MODE_NL)
+ else if (raw || mode == CH_MODE_RAW || mode == CH_MODE_NL)
rettv->vval.v_string = channel_read_block(channel, part,
timeout, raw, NULL);
else
@@ -4578,13 +4580,13 @@ ch_expr_common(typval_T *argvars, typval_T *rettv, int eval)
part_send = channel_part_send(channel);
ch_mode = channel_get_mode(channel, part_send);
- if (ch_mode == MODE_RAW || ch_mode == MODE_NL)
+ if (ch_mode == CH_MODE_RAW || ch_mode == CH_MODE_NL)
{
emsg(_(e_cannot_use_evalexpr_sendexpr_with_raw_or_nl_channel));
return;
}
- if (ch_mode == MODE_LSP)
+ if (ch_mode == CH_MODE_LSP)
{
dict_T *d;
dictitem_T *di;
@@ -4637,7 +4639,7 @@ ch_expr_common(typval_T *argvars, typval_T *rettv, int eval)
{
id = ++channel->ch_last_msg_id;
text = json_encode_nr_expr(id, &argvars[1],
- (ch_mode == MODE_JS ? JSON_JS : 0) | JSON_NL);
+ (ch_mode == CH_MODE_JS ? JSON_JS : 0) | JSON_NL);
}
if (text == NULL)
return;
@@ -4654,7 +4656,7 @@ ch_expr_common(typval_T *argvars, typval_T *rettv, int eval)
if (channel_read_json_block(channel, part_read, timeout, id, &listtv)
== OK)
{
- if (ch_mode == MODE_LSP)
+ if (ch_mode == CH_MODE_LSP)
{
*rettv = *listtv;
// Change the type to avoid the value being freed.
@@ -4674,7 +4676,7 @@ ch_expr_common(typval_T *argvars, typval_T *rettv, int eval)
}
}
free_job_options(&opt);
- if (ch_mode == MODE_LSP && !eval && callback_present)
+ if (ch_mode == CH_MODE_LSP && !eval && callback_present)
{
// if ch_sendexpr() is used to send a LSP message and a callback
// function is specified, then return the generated identifier for the
@@ -5126,13 +5128,13 @@ channel_part_read(channel_T *channel)
/*
* Return the mode of "channel"/"part"
- * If "channel" is invalid returns MODE_JSON.
+ * If "channel" is invalid returns CH_MODE_JSON.
*/
static ch_mode_T
channel_get_mode(channel_T *channel, ch_part_T part)
{
if (channel == NULL)
- return MODE_JSON;
+ return CH_MODE_JSON;
return channel->ch_part[part].ch_mode;
}
diff --git a/src/job.c b/src/job.c
index e12f687f55..5fbc2fdc67 100644
--- a/src/job.c
+++ b/src/job.c
@@ -24,15 +24,15 @@ handle_mode(typval_T *item, jobopt_T *opt, ch_mode_T *modep, int jo)
opt->jo_set |= jo;
if (STRCMP(val, "nl") == 0)
- *modep = MODE_NL;
+ *modep = CH_MODE_NL;
else if (STRCMP(val, "raw") == 0)
- *modep = MODE_RAW;
+ *modep = CH_MODE_RAW;
else if (STRCMP(val, "js") == 0)
- *modep = MODE_JS;
+ *modep = CH_MODE_JS;
else if (STRCMP(val, "json") == 0)
- *modep = MODE_JSON;
+ *modep = CH_MODE_JSON;
else if (STRCMP(val, "lsp") == 0)
- *modep = MODE_LSP;
+ *modep = CH_MODE_LSP;
else
{
semsg(_(e_invalid_argument_str), val);
@@ -1307,7 +1307,7 @@ job_start(
{
// Default mode is NL.
clear_job_options(&opt);
- opt.jo_mode = MODE_NL;
+ opt.jo_mode = CH_MODE_NL;
if (get_job_options(&argvars[1], &opt,
JO_MODE_ALL + JO_CB_ALL + JO_TIMEOUT_ALL + JO_STOPONEXIT
+ JO_EXIT_CB + JO_OUT_IO + JO_BLOCK_WRITE,
diff --git a/src/structs.h b/src/structs.h
index 1a607c65e1..fd1a92555d 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -2198,11 +2198,11 @@ struct cbq_S
// mode for a channel
typedef enum
{
- MODE_NL = 0,
- MODE_RAW,
- MODE_JSON,
- MODE_JS,
- MODE_LSP // Language Server Protocol (http + json)
+ CH_MODE_NL = 0,
+ CH_MODE_RAW,
+ CH_MODE_JSON,
+ CH_MODE_JS,
+ CH_MODE_LSP // Language Server Protocol (http + json)
} ch_mode_T;
typedef enum {
diff --git a/src/terminal.c b/src/terminal.c
index 658d5e0b91..6cac1a8ea2 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -326,7 +326,8 @@ set_term_and_win_size(term_T *term, jobopt_T *opt)
vim_snprintf((char *)buf, 100, "%dx%d",
term->tl_rows, term->tl_cols);
- set_option_value((char_u *)"termwinsize", 0L, buf, OPT_LOCAL);
+ set_option_value_give_err((char_u *)"termwinsize",
+ 0L, buf, OPT_LOCAL);
}
}
}
@@ -340,9 +341,9 @@ init_job_options(jobopt_T *opt)
{
clear_job_options(opt);
- opt->jo_mode = MODE_RAW;
- opt->jo_out_mode = MODE_RAW;
- opt->jo_err_mode = MODE_RAW;
+ opt->jo_mode = CH_MODE_RAW;
+ opt->jo_out_mode = CH_MODE_RAW;
+ opt->jo_err_mode = CH_MODE_RAW;
opt->jo_set = JO_MODE | JO_OUT_MODE | JO_ERR_MODE;
}
diff --git a/src/version.c b/src/version.c
index 1eb14d0e7e..79e89aa623 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4909,
+/**/
4908,
/**/
4907,