0
0
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:
Yegappan Lakshmanan
2022-10-16 21:43:07 +01:00
committed by Bram Moolenaar
parent 9d8620b519
commit 3f0092c141
3 changed files with 293 additions and 289 deletions

View File

@@ -28,11 +28,12 @@ change_warning(int col)
{
static char *w_readonly = N_("W10: Warning: Changing a readonly file");
if (curbuf->b_did_warn == FALSE
&& curbufIsChanged() == 0
&& !autocmd_busy
&& curbuf->b_p_ro)
{
if (curbuf->b_did_warn
|| curbufIsChanged()
|| autocmd_busy
|| !curbuf->b_p_ro)
return;
++curbuf_lock;
apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf);
--curbuf_lock;
@@ -65,7 +66,6 @@ change_warning(int col)
if (msg_row < Rows - 1)
showmode();
}
}
/*
* Call this function when something in the current buffer is changed.
@@ -159,8 +159,9 @@ check_recorded_changes(
linenr_T lnume,
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;
@@ -180,7 +181,6 @@ check_recorded_changes(
}
}
}
}
/*
* Record a change for listeners added with listener_add().

View File

@@ -203,8 +203,9 @@ ch_log_active(void)
static void
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;
@@ -223,14 +224,14 @@ ch_log_lead(const char *what, channel_T *ch, ch_part_T part)
else
fprintf(log_fd, "%s: ", what);
}
}
#ifndef PROTO // prototype is in proto.h
void
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);
@@ -241,7 +242,6 @@ ch_log(channel_T *ch, const char *fmt, ...)
fflush(log_fd);
did_repeated_msg = 0;
}
}
#endif
static void
@@ -250,8 +250,9 @@ ch_error(channel_T *ch, const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
static void
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);
@@ -262,7 +263,6 @@ ch_error(channel_T *ch, const char *fmt, ...)
fflush(log_fd);
did_repeated_msg = 0;
}
}
#ifdef MSWIN
# undef PERROR
@@ -445,8 +445,9 @@ channel_free_channel(channel_T *channel)
static void
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
@@ -455,7 +456,6 @@ channel_free(channel_T *channel)
channel_free_channel(channel);
}
}
}
/*
* Close a channel and free all its resources if there is no further action
@@ -540,7 +540,9 @@ channel_fd2channel(sock_T fd, ch_part_T *partp)
channel_T *channel;
ch_part_T part;
if (fd != INVALID_FD)
if (fd == INVALID_FD)
return NULL;
FOR_ALL_CHANNELS(channel)
{
for (part = PART_SOCK; part < PART_IN; ++part)
@@ -1214,8 +1216,10 @@ channel_find_buffer(char_u *name, int err, int msg)
if (buf == NULL)
buf = buflist_findname_exp(name);
}
if (buf == NULL)
{
if (buf != NULL)
return buf;
buf = buflist_new(name == NULL || *name == NUL ? NULL : name,
NULL, (linenr_T)0, BLN_LISTED | BLN_NEW);
if (buf == NULL)
@@ -1228,7 +1232,6 @@ channel_find_buffer(char_u *name, int err, int msg)
: "Reading from channel output..."), TRUE);
changed_bytes(1, 0);
curbuf = save_curbuf;
}
return buf;
}
@@ -1479,8 +1482,9 @@ ch_close_part(channel_T *channel, ch_part_T part)
{
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
@@ -1503,7 +1507,6 @@ ch_close_part(channel_T *channel, ch_part_T part)
// channel is closed, may want to end the job if it was the last
channel->ch_to_be_closed &= ~(1U << part);
}
}
void
channel_set_pipes(channel_T *channel, sock_T in, sock_T out, sock_T err)
@@ -1556,8 +1559,9 @@ channel_set_job(channel_T *channel, job_T *job, jobopt_T *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);
@@ -1584,7 +1588,6 @@ channel_set_job(channel_T *channel, job_T *job, jobopt_T *options)
else
in_part->ch_buf_bot = in_part->ch_bufref.br_buf->b_ml.ml_line_count;
}
}
/*
* Set the callback for "channel"/"part" for the response with "id".
@@ -1599,8 +1602,9 @@ channel_set_req_callback(
cbq_T *head = &channel->ch_part[part].ch_cb_head;
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;
item->cq_prev = head->cq_prev;
@@ -1611,7 +1615,6 @@ channel_set_req_callback(
else
item->cq_prev->cq_next = item;
}
}
static void
write_buf_line(buf_T *buf, linenr_T lnum, channel_T *channel)
@@ -2636,17 +2639,19 @@ channel_push_json(channel_T *channel, ch_part_T part, typval_T *rettv)
newitem = ALLOC_ONE(jsonq_T);
if (newitem == NULL)
clear_tv(rettv);
else
{
clear_tv(rettv);
return;
}
newitem->jq_value = alloc_tv();
if (newitem->jq_value == NULL)
{
vim_free(newitem);
clear_tv(rettv);
return;
}
else
{
newitem->jq_no_callback = FALSE;
*newitem->jq_value = *rettv;
if (item == NULL)
@@ -2672,8 +2677,6 @@ channel_push_json(channel_T *channel, ch_part_T part, typval_T *rettv)
newitem->jq_next->jq_prev = newitem;
}
}
}
}
#define CH_JSON_MAX_ARGS 4
@@ -4184,8 +4187,9 @@ common_channel_read(typval_T *argvars, typval_T *rettv, int raw, int blob)
if (opt.jo_set & JO_PART)
part = opt.jo_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);
@@ -4235,7 +4239,6 @@ common_channel_read(typval_T *argvars, typval_T *rettv, int raw, int blob)
rettv->vval.v_number = VVAL_NONE;
}
}
}
theend:
free_job_options(&opt);
@@ -4263,8 +4266,9 @@ channel_handle_events(int only_keep_open)
for (part = PART_SOCK; part < PART_IN; ++part)
{
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)
@@ -4273,7 +4277,6 @@ channel_handle_events(int only_keep_open)
ch_close_part_on_error(channel, part, TRUE,
"channel_handle_events");
}
}
# ifdef __HAIKU__
// Workaround for Haiku: Since select/poll cannot detect EOF from tty,
@@ -4318,8 +4321,9 @@ channel_set_nonblock(channel_T *channel, ch_part_T part)
chanpart_T *ch_part = &channel->ch_part[part];
int fd = ch_part->ch_fd;
if (fd != INVALID_FD)
{
if (fd == INVALID_FD)
return;
#ifdef MSWIN
u_long val = 1;
@@ -4329,7 +4333,6 @@ channel_set_nonblock(channel_T *channel, ch_part_T part)
#endif
ch_part->ch_nonblocking = TRUE;
}
}
/*
* Write "buf" (NUL terminated string) to "channel"/"part".
@@ -5228,11 +5231,11 @@ f_ch_getbufnr(typval_T *argvars, typval_T *rettv)
return;
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)
part = PART_ERR;
else if (STRCMP(what, "out") == 0)
@@ -5245,7 +5248,6 @@ f_ch_getbufnr(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number =
channel->ch_part[part].ch_bufref.br_buf->b_fnum;
}
}
/*
* "ch_getjob()" function
@@ -5259,14 +5261,14 @@ f_ch_getjob(typval_T *argvars, typval_T *rettv)
return;
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;
if (channel->ch_job != NULL)
++channel->ch_job->jv_refcount;
}
}
/*
* "ch_info()" function

View File

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