0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -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"); 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; ++curbuf_lock;
apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf);
--curbuf_lock; --curbuf_lock;
@@ -65,7 +66,6 @@ change_warning(int col)
if (msg_row < Rows - 1) if (msg_row < Rows - 1)
showmode(); showmode();
} }
}
/* /*
* Call this function when something in the current buffer is changed. * Call this function when something in the current buffer is changed.
@@ -159,8 +159,9 @@ 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; listitem_T *li;
linenr_T prev_lnum; linenr_T prev_lnum;
linenr_T prev_lnume; linenr_T prev_lnume;
@@ -180,7 +181,6 @@ check_recorded_changes(
} }
} }
} }
}
/* /*
* Record a change for listeners added with listener_add(). * Record a change for listeners added with listener_add().

View File

@@ -203,8 +203,9 @@ 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 #ifdef FEAT_RELTIME
proftime_T log_now; proftime_T log_now;
@@ -223,14 +224,14 @@ ch_log_lead(const char *what, channel_T *ch, ch_part_T part)
else else
fprintf(log_fd, "%s: ", what); 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; va_list ap;
ch_log_lead("", ch, PART_COUNT); ch_log_lead("", ch, PART_COUNT);
@@ -241,7 +242,6 @@ ch_log(channel_T *ch, const char *fmt, ...)
fflush(log_fd); fflush(log_fd);
did_repeated_msg = 0; did_repeated_msg = 0;
} }
}
#endif #endif
static void static void
@@ -250,8 +250,9 @@ 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; va_list ap;
ch_log_lead("ERR ", ch, PART_COUNT); ch_log_lead("ERR ", ch, PART_COUNT);
@@ -262,7 +263,6 @@ ch_error(channel_T *ch, const char *fmt, ...)
fflush(log_fd); fflush(log_fd);
did_repeated_msg = 0; did_repeated_msg = 0;
} }
}
#ifdef MSWIN #ifdef MSWIN
# undef PERROR # undef PERROR
@@ -445,8 +445,9 @@ 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) if (safe_to_invoke_callback == 0)
channel->ch_to_be_freed = TRUE; channel->ch_to_be_freed = TRUE;
else else
@@ -455,7 +456,6 @@ channel_free(channel_T *channel)
channel_free_channel(channel); channel_free_channel(channel);
} }
} }
}
/* /*
* Close a channel and free all its resources if there is no further action * 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; channel_T *channel;
ch_part_T part; ch_part_T part;
if (fd != INVALID_FD) if (fd == INVALID_FD)
return NULL;
FOR_ALL_CHANNELS(channel) FOR_ALL_CHANNELS(channel)
{ {
for (part = PART_SOCK; part < PART_IN; ++part) 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) if (buf == NULL)
buf = buflist_findname_exp(name); buf = buflist_findname_exp(name);
} }
if (buf == NULL)
{ if (buf != NULL)
return buf;
buf = buflist_new(name == NULL || *name == NUL ? NULL : name, buf = buflist_new(name == NULL || *name == NUL ? NULL : name,
NULL, (linenr_T)0, BLN_LISTED | BLN_NEW); NULL, (linenr_T)0, BLN_LISTED | BLN_NEW);
if (buf == NULL) if (buf == NULL)
@@ -1228,7 +1232,6 @@ channel_find_buffer(char_u *name, int err, int msg)
: "Reading from channel output..."), TRUE); : "Reading from channel output..."), TRUE);
changed_bytes(1, 0); changed_bytes(1, 0);
curbuf = save_curbuf; curbuf = save_curbuf;
}
return buf; 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; sock_T *fd = &channel->ch_part[part].ch_fd;
if (*fd != INVALID_FD) if (*fd == INVALID_FD)
{ return;
if (part == PART_SOCK) if (part == PART_SOCK)
sock_close(*fd); sock_close(*fd);
else 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 is closed, may want to end the job if it was the last
channel->ch_to_be_closed &= ~(1U << part); channel->ch_to_be_closed &= ~(1U << part);
} }
}
void void
channel_set_pipes(channel_T *channel, sock_T in, sock_T out, sock_T err) 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); 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]; chanpart_T *in_part = &channel->ch_part[PART_IN];
set_bufref(&in_part->ch_bufref, job->jv_in_buf); 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 else
in_part->ch_buf_bot = in_part->ch_bufref.br_buf->b_ml.ml_line_count; 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". * 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 *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); copy_callback(&item->cq_callback, callback);
item->cq_seq_nr = id; item->cq_seq_nr = id;
item->cq_prev = head->cq_prev; item->cq_prev = head->cq_prev;
@@ -1611,7 +1615,6 @@ channel_set_req_callback(
else else
item->cq_prev->cq_next = item; item->cq_prev->cq_next = item;
} }
}
static void static void
write_buf_line(buf_T *buf, linenr_T lnum, channel_T *channel) 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); newitem = ALLOC_ONE(jsonq_T);
if (newitem == NULL) if (newitem == NULL)
clear_tv(rettv);
else
{ {
clear_tv(rettv);
return;
}
newitem->jq_value = alloc_tv(); newitem->jq_value = alloc_tv();
if (newitem->jq_value == NULL) if (newitem->jq_value == NULL)
{ {
vim_free(newitem); vim_free(newitem);
clear_tv(rettv); clear_tv(rettv);
return;
} }
else
{
newitem->jq_no_callback = FALSE; newitem->jq_no_callback = FALSE;
*newitem->jq_value = *rettv; *newitem->jq_value = *rettv;
if (item == NULL) 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; newitem->jq_next->jq_prev = newitem;
} }
} }
}
}
#define CH_JSON_MAX_ARGS 4 #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) 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) if (part == PART_COUNT)
part = channel_part_read(channel); part = channel_part_read(channel);
mode = channel_get_mode(channel, part); 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; rettv->vval.v_number = VVAL_NONE;
} }
} }
}
theend: theend:
free_job_options(&opt); free_job_options(&opt);
@@ -4263,8 +4266,9 @@ 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); int r = channel_wait(channel, fd, 0);
if (r == CW_READY) if (r == CW_READY)
@@ -4273,7 +4277,6 @@ channel_handle_events(int only_keep_open)
ch_close_part_on_error(channel, part, TRUE, ch_close_part_on_error(channel, part, TRUE,
"channel_handle_events"); "channel_handle_events");
} }
}
# ifdef __HAIKU__ # ifdef __HAIKU__
// Workaround for Haiku: Since select/poll cannot detect EOF from tty, // 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]; 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 #ifdef MSWIN
u_long val = 1; u_long val = 1;
@@ -4329,7 +4333,6 @@ channel_set_nonblock(channel_T *channel, ch_part_T part)
#endif #endif
ch_part->ch_nonblocking = TRUE; ch_part->ch_nonblocking = TRUE;
} }
}
/* /*
* Write "buf" (NUL terminated string) to "channel"/"part". * Write "buf" (NUL terminated string) to "channel"/"part".
@@ -5228,11 +5231,11 @@ 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]); char_u *what = tv_get_string(&argvars[1]);
int part; int part;
if (STRCMP(what, "err") == 0) if (STRCMP(what, "err") == 0)
part = PART_ERR; part = PART_ERR;
else if (STRCMP(what, "out") == 0) else if (STRCMP(what, "out") == 0)
@@ -5245,7 +5248,6 @@ f_ch_getbufnr(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number = rettv->vval.v_number =
channel->ch_part[part].ch_bufref.br_buf->b_fnum; channel->ch_part[part].ch_bufref.br_buf->b_fnum;
} }
}
/* /*
* "ch_getjob()" function * "ch_getjob()" function
@@ -5259,14 +5261,14 @@ 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->v_type = VAR_JOB;
rettv->vval.v_job = channel->ch_job; rettv->vval.v_job = channel->ch_job;
if (channel->ch_job != NULL) if (channel->ch_job != NULL)
++channel->ch_job->jv_refcount; ++channel->ch_job->jv_refcount;
} }
}
/* /*
* "ch_info()" function * "ch_info()" function

View File

@@ -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,
/**/ /**/