mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 9.0.0777: code is indented too much
Problem: Code is indented too much. Solution: Use an early return. (Yegappan Lakshmanan, closes #11386)
This commit is contained in:
committed by
Bram Moolenaar
parent
9d8620b519
commit
3f0092c141
96
src/change.c
96
src/change.c
@@ -28,43 +28,43 @@ change_warning(int col)
|
|||||||
{
|
{
|
||||||
static char *w_readonly = N_("W10: Warning: Changing a readonly file");
|
static char *w_readonly = N_("W10: Warning: Changing a readonly file");
|
||||||
|
|
||||||
if (curbuf->b_did_warn == FALSE
|
if (curbuf->b_did_warn
|
||||||
&& curbufIsChanged() == 0
|
|| curbufIsChanged()
|
||||||
&& !autocmd_busy
|
|| autocmd_busy
|
||||||
&& curbuf->b_p_ro)
|
|| !curbuf->b_p_ro)
|
||||||
{
|
return;
|
||||||
++curbuf_lock;
|
|
||||||
apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf);
|
|
||||||
--curbuf_lock;
|
|
||||||
if (!curbuf->b_p_ro)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Do what msg() does, but with a column offset if the warning should
|
++curbuf_lock;
|
||||||
// be after the mode message.
|
apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf);
|
||||||
msg_start();
|
--curbuf_lock;
|
||||||
if (msg_row == Rows - 1)
|
if (!curbuf->b_p_ro)
|
||||||
msg_col = col;
|
return;
|
||||||
msg_source(HL_ATTR(HLF_W));
|
|
||||||
msg_puts_attr(_(w_readonly), HL_ATTR(HLF_W) | MSG_HIST);
|
// Do what msg() does, but with a column offset if the warning should
|
||||||
|
// be after the mode message.
|
||||||
|
msg_start();
|
||||||
|
if (msg_row == Rows - 1)
|
||||||
|
msg_col = col;
|
||||||
|
msg_source(HL_ATTR(HLF_W));
|
||||||
|
msg_puts_attr(_(w_readonly), HL_ATTR(HLF_W) | MSG_HIST);
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_readonly), -1);
|
set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_readonly), -1);
|
||||||
#endif
|
#endif
|
||||||
msg_clr_eos();
|
msg_clr_eos();
|
||||||
(void)msg_end();
|
(void)msg_end();
|
||||||
if (msg_silent == 0 && !silent_mode
|
if (msg_silent == 0 && !silent_mode
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
&& time_for_testing != 1
|
&& time_for_testing != 1
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
out_flush();
|
out_flush();
|
||||||
ui_delay(1002L, TRUE); // give the user time to think about it
|
ui_delay(1002L, TRUE); // give the user time to think about it
|
||||||
}
|
|
||||||
curbuf->b_did_warn = TRUE;
|
|
||||||
redraw_cmdline = FALSE; // don't redraw and erase the message
|
|
||||||
if (msg_row < Rows - 1)
|
|
||||||
showmode();
|
|
||||||
}
|
}
|
||||||
|
curbuf->b_did_warn = TRUE;
|
||||||
|
redraw_cmdline = FALSE; // don't redraw and erase the message
|
||||||
|
if (msg_row < Rows - 1)
|
||||||
|
showmode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -159,25 +159,25 @@ check_recorded_changes(
|
|||||||
linenr_T lnume,
|
linenr_T lnume,
|
||||||
long xtra)
|
long xtra)
|
||||||
{
|
{
|
||||||
if (buf->b_recorded_changes != NULL && xtra != 0)
|
if (buf->b_recorded_changes == NULL || xtra == 0)
|
||||||
{
|
return;
|
||||||
listitem_T *li;
|
|
||||||
linenr_T prev_lnum;
|
|
||||||
linenr_T prev_lnume;
|
|
||||||
|
|
||||||
FOR_ALL_LIST_ITEMS(buf->b_recorded_changes, li)
|
listitem_T *li;
|
||||||
|
linenr_T prev_lnum;
|
||||||
|
linenr_T prev_lnume;
|
||||||
|
|
||||||
|
FOR_ALL_LIST_ITEMS(buf->b_recorded_changes, li)
|
||||||
|
{
|
||||||
|
prev_lnum = (linenr_T)dict_get_number(
|
||||||
|
li->li_tv.vval.v_dict, "lnum");
|
||||||
|
prev_lnume = (linenr_T)dict_get_number(
|
||||||
|
li->li_tv.vval.v_dict, "end");
|
||||||
|
if (prev_lnum >= lnum || prev_lnum > lnume || prev_lnume >= lnum)
|
||||||
{
|
{
|
||||||
prev_lnum = (linenr_T)dict_get_number(
|
// the current change is going to make the line number in
|
||||||
li->li_tv.vval.v_dict, "lnum");
|
// the older change invalid, flush now
|
||||||
prev_lnume = (linenr_T)dict_get_number(
|
invoke_listeners(curbuf);
|
||||||
li->li_tv.vval.v_dict, "end");
|
break;
|
||||||
if (prev_lnum >= lnum || prev_lnum > lnume || prev_lnume >= lnum)
|
|
||||||
{
|
|
||||||
// the current change is going to make the line number in
|
|
||||||
// the older change invalid, flush now
|
|
||||||
invoke_listeners(curbuf);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
484
src/channel.c
484
src/channel.c
@@ -203,44 +203,44 @@ ch_log_active(void)
|
|||||||
static void
|
static void
|
||||||
ch_log_lead(const char *what, channel_T *ch, ch_part_T part)
|
ch_log_lead(const char *what, channel_T *ch, ch_part_T part)
|
||||||
{
|
{
|
||||||
if (log_fd != NULL)
|
if (log_fd == NULL)
|
||||||
{
|
return;
|
||||||
#ifdef FEAT_RELTIME
|
|
||||||
proftime_T log_now;
|
|
||||||
|
|
||||||
profile_start(&log_now);
|
#ifdef FEAT_RELTIME
|
||||||
profile_sub(&log_now, &log_start);
|
proftime_T log_now;
|
||||||
fprintf(log_fd, "%s ", profile_msg(&log_now));
|
|
||||||
|
profile_start(&log_now);
|
||||||
|
profile_sub(&log_now, &log_start);
|
||||||
|
fprintf(log_fd, "%s ", profile_msg(&log_now));
|
||||||
#endif
|
#endif
|
||||||
if (ch != NULL)
|
if (ch != NULL)
|
||||||
{
|
{
|
||||||
if (part < PART_COUNT)
|
if (part < PART_COUNT)
|
||||||
fprintf(log_fd, "%son %d(%s): ",
|
fprintf(log_fd, "%son %d(%s): ",
|
||||||
what, ch->ch_id, part_names[part]);
|
what, ch->ch_id, part_names[part]);
|
||||||
else
|
|
||||||
fprintf(log_fd, "%son %d: ", what, ch->ch_id);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
fprintf(log_fd, "%s: ", what);
|
fprintf(log_fd, "%son %d: ", what, ch->ch_id);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
fprintf(log_fd, "%s: ", what);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef PROTO // prototype is in proto.h
|
#ifndef PROTO // prototype is in proto.h
|
||||||
void
|
void
|
||||||
ch_log(channel_T *ch, const char *fmt, ...)
|
ch_log(channel_T *ch, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
if (log_fd != NULL)
|
if (log_fd == NULL)
|
||||||
{
|
return;
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
ch_log_lead("", ch, PART_COUNT);
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
|
||||||
vfprintf(log_fd, fmt, ap);
|
ch_log_lead("", ch, PART_COUNT);
|
||||||
va_end(ap);
|
va_start(ap, fmt);
|
||||||
fputc('\n', log_fd);
|
vfprintf(log_fd, fmt, ap);
|
||||||
fflush(log_fd);
|
va_end(ap);
|
||||||
did_repeated_msg = 0;
|
fputc('\n', log_fd);
|
||||||
}
|
fflush(log_fd);
|
||||||
|
did_repeated_msg = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -250,18 +250,18 @@ ch_error(channel_T *ch, const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
|
|||||||
static void
|
static void
|
||||||
ch_error(channel_T *ch, const char *fmt, ...)
|
ch_error(channel_T *ch, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
if (log_fd != NULL)
|
if (log_fd == NULL)
|
||||||
{
|
return;
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
ch_log_lead("ERR ", ch, PART_COUNT);
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
|
||||||
vfprintf(log_fd, fmt, ap);
|
ch_log_lead("ERR ", ch, PART_COUNT);
|
||||||
va_end(ap);
|
va_start(ap, fmt);
|
||||||
fputc('\n', log_fd);
|
vfprintf(log_fd, fmt, ap);
|
||||||
fflush(log_fd);
|
va_end(ap);
|
||||||
did_repeated_msg = 0;
|
fputc('\n', log_fd);
|
||||||
}
|
fflush(log_fd);
|
||||||
|
did_repeated_msg = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MSWIN
|
#ifdef MSWIN
|
||||||
@@ -445,15 +445,15 @@ channel_free_channel(channel_T *channel)
|
|||||||
static void
|
static void
|
||||||
channel_free(channel_T *channel)
|
channel_free(channel_T *channel)
|
||||||
{
|
{
|
||||||
if (!in_free_unref_items)
|
if (in_free_unref_items)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (safe_to_invoke_callback == 0)
|
||||||
|
channel->ch_to_be_freed = TRUE;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (safe_to_invoke_callback == 0)
|
channel_free_contents(channel);
|
||||||
channel->ch_to_be_freed = TRUE;
|
channel_free_channel(channel);
|
||||||
else
|
|
||||||
{
|
|
||||||
channel_free_contents(channel);
|
|
||||||
channel_free_channel(channel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,16 +540,18 @@ channel_fd2channel(sock_T fd, ch_part_T *partp)
|
|||||||
channel_T *channel;
|
channel_T *channel;
|
||||||
ch_part_T part;
|
ch_part_T part;
|
||||||
|
|
||||||
if (fd != INVALID_FD)
|
if (fd == INVALID_FD)
|
||||||
FOR_ALL_CHANNELS(channel)
|
return NULL;
|
||||||
{
|
|
||||||
for (part = PART_SOCK; part < PART_IN; ++part)
|
FOR_ALL_CHANNELS(channel)
|
||||||
if (channel->ch_part[part].ch_fd == fd)
|
{
|
||||||
{
|
for (part = PART_SOCK; part < PART_IN; ++part)
|
||||||
*partp = part;
|
if (channel->ch_part[part].ch_fd == fd)
|
||||||
return channel;
|
{
|
||||||
}
|
*partp = part;
|
||||||
}
|
return channel;
|
||||||
|
}
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1214,21 +1216,22 @@ channel_find_buffer(char_u *name, int err, int msg)
|
|||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
buf = buflist_findname_exp(name);
|
buf = buflist_findname_exp(name);
|
||||||
}
|
}
|
||||||
if (buf == NULL)
|
|
||||||
{
|
|
||||||
buf = buflist_new(name == NULL || *name == NUL ? NULL : name,
|
|
||||||
NULL, (linenr_T)0, BLN_LISTED | BLN_NEW);
|
|
||||||
if (buf == NULL)
|
|
||||||
return NULL;
|
|
||||||
prepare_buffer(buf);
|
|
||||||
|
|
||||||
curbuf = buf;
|
if (buf != NULL)
|
||||||
if (msg)
|
return buf;
|
||||||
ml_replace(1, (char_u *)(err ? "Reading from channel error..."
|
|
||||||
: "Reading from channel output..."), TRUE);
|
buf = buflist_new(name == NULL || *name == NUL ? NULL : name,
|
||||||
changed_bytes(1, 0);
|
NULL, (linenr_T)0, BLN_LISTED | BLN_NEW);
|
||||||
curbuf = save_curbuf;
|
if (buf == NULL)
|
||||||
}
|
return NULL;
|
||||||
|
prepare_buffer(buf);
|
||||||
|
|
||||||
|
curbuf = buf;
|
||||||
|
if (msg)
|
||||||
|
ml_replace(1, (char_u *)(err ? "Reading from channel error..."
|
||||||
|
: "Reading from channel output..."), TRUE);
|
||||||
|
changed_bytes(1, 0);
|
||||||
|
curbuf = save_curbuf;
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@@ -1479,30 +1482,30 @@ ch_close_part(channel_T *channel, ch_part_T part)
|
|||||||
{
|
{
|
||||||
sock_T *fd = &channel->ch_part[part].ch_fd;
|
sock_T *fd = &channel->ch_part[part].ch_fd;
|
||||||
|
|
||||||
if (*fd != INVALID_FD)
|
if (*fd == INVALID_FD)
|
||||||
{
|
return;
|
||||||
if (part == PART_SOCK)
|
|
||||||
sock_close(*fd);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// When using a pty the same FD is set on multiple parts, only
|
|
||||||
// close it when the last reference is closed.
|
|
||||||
if ((part == PART_IN || channel->CH_IN_FD != *fd)
|
|
||||||
&& (part == PART_OUT || channel->CH_OUT_FD != *fd)
|
|
||||||
&& (part == PART_ERR || channel->CH_ERR_FD != *fd))
|
|
||||||
{
|
|
||||||
#ifdef MSWIN
|
|
||||||
if (channel->ch_named_pipe)
|
|
||||||
DisconnectNamedPipe((HANDLE)fd);
|
|
||||||
#endif
|
|
||||||
fd_close(*fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*fd = INVALID_FD;
|
|
||||||
|
|
||||||
// channel is closed, may want to end the job if it was the last
|
if (part == PART_SOCK)
|
||||||
channel->ch_to_be_closed &= ~(1U << part);
|
sock_close(*fd);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// When using a pty the same FD is set on multiple parts, only
|
||||||
|
// close it when the last reference is closed.
|
||||||
|
if ((part == PART_IN || channel->CH_IN_FD != *fd)
|
||||||
|
&& (part == PART_OUT || channel->CH_OUT_FD != *fd)
|
||||||
|
&& (part == PART_ERR || channel->CH_ERR_FD != *fd))
|
||||||
|
{
|
||||||
|
#ifdef MSWIN
|
||||||
|
if (channel->ch_named_pipe)
|
||||||
|
DisconnectNamedPipe((HANDLE)fd);
|
||||||
|
#endif
|
||||||
|
fd_close(*fd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
*fd = INVALID_FD;
|
||||||
|
|
||||||
|
// channel is closed, may want to end the job if it was the last
|
||||||
|
channel->ch_to_be_closed &= ~(1U << part);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1556,34 +1559,34 @@ channel_set_job(channel_T *channel, job_T *job, jobopt_T *options)
|
|||||||
|
|
||||||
channel_set_options(channel, options);
|
channel_set_options(channel, options);
|
||||||
|
|
||||||
if (job->jv_in_buf != NULL)
|
if (job->jv_in_buf == NULL)
|
||||||
{
|
return;
|
||||||
chanpart_T *in_part = &channel->ch_part[PART_IN];
|
|
||||||
|
|
||||||
set_bufref(&in_part->ch_bufref, job->jv_in_buf);
|
chanpart_T *in_part = &channel->ch_part[PART_IN];
|
||||||
ch_log(channel, "reading from buffer '%s'",
|
|
||||||
(char *)in_part->ch_bufref.br_buf->b_ffname);
|
set_bufref(&in_part->ch_bufref, job->jv_in_buf);
|
||||||
if (options->jo_set & JO_IN_TOP)
|
ch_log(channel, "reading from buffer '%s'",
|
||||||
|
(char *)in_part->ch_bufref.br_buf->b_ffname);
|
||||||
|
if (options->jo_set & JO_IN_TOP)
|
||||||
|
{
|
||||||
|
if (options->jo_in_top == 0 && !(options->jo_set & JO_IN_BOT))
|
||||||
{
|
{
|
||||||
if (options->jo_in_top == 0 && !(options->jo_set & JO_IN_BOT))
|
// Special mode: send last-but-one line when appending a line
|
||||||
{
|
// to the buffer.
|
||||||
// Special mode: send last-but-one line when appending a line
|
in_part->ch_bufref.br_buf->b_write_to_channel = TRUE;
|
||||||
// to the buffer.
|
in_part->ch_buf_append = TRUE;
|
||||||
in_part->ch_bufref.br_buf->b_write_to_channel = TRUE;
|
in_part->ch_buf_top =
|
||||||
in_part->ch_buf_append = TRUE;
|
in_part->ch_bufref.br_buf->b_ml.ml_line_count + 1;
|
||||||
in_part->ch_buf_top =
|
|
||||||
in_part->ch_bufref.br_buf->b_ml.ml_line_count + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
in_part->ch_buf_top = options->jo_in_top;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
in_part->ch_buf_top = 1;
|
in_part->ch_buf_top = options->jo_in_top;
|
||||||
if (options->jo_set & JO_IN_BOT)
|
|
||||||
in_part->ch_buf_bot = options->jo_in_bot;
|
|
||||||
else
|
|
||||||
in_part->ch_buf_bot = in_part->ch_bufref.br_buf->b_ml.ml_line_count;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
in_part->ch_buf_top = 1;
|
||||||
|
if (options->jo_set & JO_IN_BOT)
|
||||||
|
in_part->ch_buf_bot = options->jo_in_bot;
|
||||||
|
else
|
||||||
|
in_part->ch_buf_bot = in_part->ch_bufref.br_buf->b_ml.ml_line_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1599,18 +1602,18 @@ channel_set_req_callback(
|
|||||||
cbq_T *head = &channel->ch_part[part].ch_cb_head;
|
cbq_T *head = &channel->ch_part[part].ch_cb_head;
|
||||||
cbq_T *item = ALLOC_ONE(cbq_T);
|
cbq_T *item = ALLOC_ONE(cbq_T);
|
||||||
|
|
||||||
if (item != NULL)
|
if (item == NULL)
|
||||||
{
|
return;
|
||||||
copy_callback(&item->cq_callback, callback);
|
|
||||||
item->cq_seq_nr = id;
|
copy_callback(&item->cq_callback, callback);
|
||||||
item->cq_prev = head->cq_prev;
|
item->cq_seq_nr = id;
|
||||||
head->cq_prev = item;
|
item->cq_prev = head->cq_prev;
|
||||||
item->cq_next = NULL;
|
head->cq_prev = item;
|
||||||
if (item->cq_prev == NULL)
|
item->cq_next = NULL;
|
||||||
head->cq_next = item;
|
if (item->cq_prev == NULL)
|
||||||
else
|
head->cq_next = item;
|
||||||
item->cq_prev->cq_next = item;
|
else
|
||||||
}
|
item->cq_prev->cq_next = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2636,42 +2639,42 @@ channel_push_json(channel_T *channel, ch_part_T part, typval_T *rettv)
|
|||||||
|
|
||||||
newitem = ALLOC_ONE(jsonq_T);
|
newitem = ALLOC_ONE(jsonq_T);
|
||||||
if (newitem == NULL)
|
if (newitem == NULL)
|
||||||
|
{
|
||||||
clear_tv(rettv);
|
clear_tv(rettv);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
newitem->jq_value = alloc_tv();
|
||||||
|
if (newitem->jq_value == NULL)
|
||||||
|
{
|
||||||
|
vim_free(newitem);
|
||||||
|
clear_tv(rettv);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
newitem->jq_no_callback = FALSE;
|
||||||
|
*newitem->jq_value = *rettv;
|
||||||
|
if (item == NULL)
|
||||||
|
{
|
||||||
|
// append to the end
|
||||||
|
newitem->jq_prev = head->jq_prev;
|
||||||
|
head->jq_prev = newitem;
|
||||||
|
newitem->jq_next = NULL;
|
||||||
|
if (newitem->jq_prev == NULL)
|
||||||
|
head->jq_next = newitem;
|
||||||
|
else
|
||||||
|
newitem->jq_prev->jq_next = newitem;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newitem->jq_value = alloc_tv();
|
// append after "item"
|
||||||
if (newitem->jq_value == NULL)
|
newitem->jq_prev = item;
|
||||||
{
|
newitem->jq_next = item->jq_next;
|
||||||
vim_free(newitem);
|
item->jq_next = newitem;
|
||||||
clear_tv(rettv);
|
if (newitem->jq_next == NULL)
|
||||||
}
|
head->jq_prev = newitem;
|
||||||
else
|
else
|
||||||
{
|
newitem->jq_next->jq_prev = newitem;
|
||||||
newitem->jq_no_callback = FALSE;
|
|
||||||
*newitem->jq_value = *rettv;
|
|
||||||
if (item == NULL)
|
|
||||||
{
|
|
||||||
// append to the end
|
|
||||||
newitem->jq_prev = head->jq_prev;
|
|
||||||
head->jq_prev = newitem;
|
|
||||||
newitem->jq_next = NULL;
|
|
||||||
if (newitem->jq_prev == NULL)
|
|
||||||
head->jq_next = newitem;
|
|
||||||
else
|
|
||||||
newitem->jq_prev->jq_next = newitem;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// append after "item"
|
|
||||||
newitem->jq_prev = item;
|
|
||||||
newitem->jq_next = item->jq_next;
|
|
||||||
item->jq_next = newitem;
|
|
||||||
if (newitem->jq_next == NULL)
|
|
||||||
head->jq_prev = newitem;
|
|
||||||
else
|
|
||||||
newitem->jq_next->jq_prev = newitem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4184,56 +4187,56 @@ common_channel_read(typval_T *argvars, typval_T *rettv, int raw, int blob)
|
|||||||
if (opt.jo_set & JO_PART)
|
if (opt.jo_set & JO_PART)
|
||||||
part = opt.jo_part;
|
part = opt.jo_part;
|
||||||
channel = get_channel_arg(&argvars[0], TRUE, TRUE, part);
|
channel = get_channel_arg(&argvars[0], TRUE, TRUE, part);
|
||||||
if (channel != NULL)
|
if (channel == NULL)
|
||||||
|
goto theend;
|
||||||
|
|
||||||
|
if (part == PART_COUNT)
|
||||||
|
part = channel_part_read(channel);
|
||||||
|
mode = channel_get_mode(channel, part);
|
||||||
|
timeout = channel_get_timeout(channel, part);
|
||||||
|
if (opt.jo_set & JO_TIMEOUT)
|
||||||
|
timeout = opt.jo_timeout;
|
||||||
|
|
||||||
|
if (blob)
|
||||||
{
|
{
|
||||||
if (part == PART_COUNT)
|
int outlen = 0;
|
||||||
part = channel_part_read(channel);
|
char_u *p = channel_read_block(channel, part,
|
||||||
mode = channel_get_mode(channel, part);
|
timeout, TRUE, &outlen);
|
||||||
timeout = channel_get_timeout(channel, part);
|
if (p != NULL)
|
||||||
if (opt.jo_set & JO_TIMEOUT)
|
|
||||||
timeout = opt.jo_timeout;
|
|
||||||
|
|
||||||
if (blob)
|
|
||||||
{
|
{
|
||||||
int outlen = 0;
|
blob_T *b = blob_alloc();
|
||||||
char_u *p = channel_read_block(channel, part,
|
|
||||||
timeout, TRUE, &outlen);
|
|
||||||
if (p != NULL)
|
|
||||||
{
|
|
||||||
blob_T *b = blob_alloc();
|
|
||||||
|
|
||||||
if (b != NULL)
|
if (b != NULL)
|
||||||
|
{
|
||||||
|
b->bv_ga.ga_len = outlen;
|
||||||
|
if (ga_grow(&b->bv_ga, outlen) == FAIL)
|
||||||
|
blob_free(b);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
b->bv_ga.ga_len = outlen;
|
memcpy(b->bv_ga.ga_data, p, outlen);
|
||||||
if (ga_grow(&b->bv_ga, outlen) == FAIL)
|
rettv_blob_set(rettv, b);
|
||||||
blob_free(b);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memcpy(b->bv_ga.ga_data, p, outlen);
|
|
||||||
rettv_blob_set(rettv, b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
vim_free(p);
|
|
||||||
}
|
}
|
||||||
|
vim_free(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (raw || mode == CH_MODE_RAW || mode == CH_MODE_NL)
|
||||||
|
rettv->vval.v_string = channel_read_block(channel, part,
|
||||||
|
timeout, raw, NULL);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (opt.jo_set & JO_ID)
|
||||||
|
id = opt.jo_id;
|
||||||
|
channel_read_json_block(channel, part, timeout, id, &listtv);
|
||||||
|
if (listtv != NULL)
|
||||||
|
{
|
||||||
|
*rettv = *listtv;
|
||||||
|
vim_free(listtv);
|
||||||
}
|
}
|
||||||
else if (raw || mode == CH_MODE_RAW || mode == CH_MODE_NL)
|
|
||||||
rettv->vval.v_string = channel_read_block(channel, part,
|
|
||||||
timeout, raw, NULL);
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opt.jo_set & JO_ID)
|
rettv->v_type = VAR_SPECIAL;
|
||||||
id = opt.jo_id;
|
rettv->vval.v_number = VVAL_NONE;
|
||||||
channel_read_json_block(channel, part, timeout, id, &listtv);
|
|
||||||
if (listtv != NULL)
|
|
||||||
{
|
|
||||||
*rettv = *listtv;
|
|
||||||
vim_free(listtv);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rettv->v_type = VAR_SPECIAL;
|
|
||||||
rettv->vval.v_number = VVAL_NONE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4263,16 +4266,16 @@ channel_handle_events(int only_keep_open)
|
|||||||
for (part = PART_SOCK; part < PART_IN; ++part)
|
for (part = PART_SOCK; part < PART_IN; ++part)
|
||||||
{
|
{
|
||||||
fd = channel->ch_part[part].ch_fd;
|
fd = channel->ch_part[part].ch_fd;
|
||||||
if (fd != INVALID_FD)
|
if (fd == INVALID_FD)
|
||||||
{
|
continue;
|
||||||
int r = channel_wait(channel, fd, 0);
|
|
||||||
|
|
||||||
if (r == CW_READY)
|
int r = channel_wait(channel, fd, 0);
|
||||||
channel_read(channel, part, "channel_handle_events");
|
|
||||||
else if (r == CW_ERROR)
|
if (r == CW_READY)
|
||||||
ch_close_part_on_error(channel, part, TRUE,
|
channel_read(channel, part, "channel_handle_events");
|
||||||
"channel_handle_events");
|
else if (r == CW_ERROR)
|
||||||
}
|
ch_close_part_on_error(channel, part, TRUE,
|
||||||
|
"channel_handle_events");
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef __HAIKU__
|
# ifdef __HAIKU__
|
||||||
@@ -4318,17 +4321,17 @@ channel_set_nonblock(channel_T *channel, ch_part_T part)
|
|||||||
chanpart_T *ch_part = &channel->ch_part[part];
|
chanpart_T *ch_part = &channel->ch_part[part];
|
||||||
int fd = ch_part->ch_fd;
|
int fd = ch_part->ch_fd;
|
||||||
|
|
||||||
if (fd != INVALID_FD)
|
if (fd == INVALID_FD)
|
||||||
{
|
return;
|
||||||
#ifdef MSWIN
|
|
||||||
u_long val = 1;
|
|
||||||
|
|
||||||
ioctlsocket(fd, FIONBIO, &val);
|
#ifdef MSWIN
|
||||||
|
u_long val = 1;
|
||||||
|
|
||||||
|
ioctlsocket(fd, FIONBIO, &val);
|
||||||
#else
|
#else
|
||||||
(void)fcntl(fd, F_SETFL, O_NONBLOCK);
|
(void)fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||||
#endif
|
#endif
|
||||||
ch_part->ch_nonblocking = TRUE;
|
ch_part->ch_nonblocking = TRUE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -5218,7 +5221,7 @@ f_ch_close_in(typval_T *argvars, typval_T *rettv UNUSED)
|
|||||||
void
|
void
|
||||||
f_ch_getbufnr(typval_T *argvars, typval_T *rettv)
|
f_ch_getbufnr(typval_T *argvars, typval_T *rettv)
|
||||||
{
|
{
|
||||||
channel_T *channel;
|
channel_T *channel;
|
||||||
|
|
||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
|
|
||||||
@@ -5228,23 +5231,22 @@ f_ch_getbufnr(typval_T *argvars, typval_T *rettv)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0);
|
channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0);
|
||||||
if (channel != NULL)
|
if (channel == NULL)
|
||||||
{
|
return;
|
||||||
char_u *what = tv_get_string(&argvars[1]);
|
|
||||||
int part;
|
|
||||||
|
|
||||||
if (STRCMP(what, "err") == 0)
|
char_u *what = tv_get_string(&argvars[1]);
|
||||||
part = PART_ERR;
|
int part;
|
||||||
else if (STRCMP(what, "out") == 0)
|
if (STRCMP(what, "err") == 0)
|
||||||
part = PART_OUT;
|
part = PART_ERR;
|
||||||
else if (STRCMP(what, "in") == 0)
|
else if (STRCMP(what, "out") == 0)
|
||||||
part = PART_IN;
|
part = PART_OUT;
|
||||||
else
|
else if (STRCMP(what, "in") == 0)
|
||||||
part = PART_SOCK;
|
part = PART_IN;
|
||||||
if (channel->ch_part[part].ch_bufref.br_buf != NULL)
|
else
|
||||||
rettv->vval.v_number =
|
part = PART_SOCK;
|
||||||
channel->ch_part[part].ch_bufref.br_buf->b_fnum;
|
if (channel->ch_part[part].ch_bufref.br_buf != NULL)
|
||||||
}
|
rettv->vval.v_number =
|
||||||
|
channel->ch_part[part].ch_bufref.br_buf->b_fnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -5259,13 +5261,13 @@ f_ch_getjob(typval_T *argvars, typval_T *rettv)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0);
|
channel = get_channel_arg(&argvars[0], FALSE, FALSE, 0);
|
||||||
if (channel != NULL)
|
if (channel == NULL)
|
||||||
{
|
return;
|
||||||
rettv->v_type = VAR_JOB;
|
|
||||||
rettv->vval.v_job = channel->ch_job;
|
rettv->v_type = VAR_JOB;
|
||||||
if (channel->ch_job != NULL)
|
rettv->vval.v_job = channel->ch_job;
|
||||||
++channel->ch_job->jv_refcount;
|
if (channel->ch_job != NULL)
|
||||||
}
|
++channel->ch_job->jv_refcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -695,6 +695,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 */
|
||||||
|
/**/
|
||||||
|
777,
|
||||||
/**/
|
/**/
|
||||||
776,
|
776,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user