mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.0.1105: code is indented too much
Problem: Code is indented too much. Solution: Use an early return. (Yegappan Lakshmanan, closes #11756)
This commit is contained in:
committed by
Bram Moolenaar
parent
56310d38d8
commit
87c1cbbe98
187
src/eval.c
187
src/eval.c
@@ -128,14 +128,15 @@ fill_evalarg_from_eap(evalarg_T *evalarg, exarg_T *eap, int skip)
|
||||
{
|
||||
init_evalarg(evalarg);
|
||||
evalarg->eval_flags = skip ? 0 : EVAL_EVALUATE;
|
||||
if (eap != NULL)
|
||||
|
||||
if (eap == NULL)
|
||||
return;
|
||||
|
||||
evalarg->eval_cstack = eap->cstack;
|
||||
if (sourcing_a_script(eap) || eap->getline == get_list_line)
|
||||
{
|
||||
evalarg->eval_cstack = eap->cstack;
|
||||
if (sourcing_a_script(eap) || eap->getline == get_list_line)
|
||||
{
|
||||
evalarg->eval_getline = eap->getline;
|
||||
evalarg->eval_cookie = eap->cookie;
|
||||
}
|
||||
evalarg->eval_getline = eap->getline;
|
||||
evalarg->eval_cookie = eap->cookie;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,15 +405,15 @@ init_evalarg(evalarg_T *evalarg)
|
||||
static void
|
||||
free_eval_tofree_later(evalarg_T *evalarg)
|
||||
{
|
||||
if (evalarg->eval_tofree != NULL)
|
||||
{
|
||||
if (ga_grow(&evalarg->eval_tofree_ga, 1) == OK)
|
||||
((char_u **)evalarg->eval_tofree_ga.ga_data)
|
||||
[evalarg->eval_tofree_ga.ga_len++]
|
||||
= evalarg->eval_tofree;
|
||||
else
|
||||
vim_free(evalarg->eval_tofree);
|
||||
}
|
||||
if (evalarg->eval_tofree == NULL)
|
||||
return;
|
||||
|
||||
if (ga_grow(&evalarg->eval_tofree_ga, 1) == OK)
|
||||
((char_u **)evalarg->eval_tofree_ga.ga_data)
|
||||
[evalarg->eval_tofree_ga.ga_len++]
|
||||
= evalarg->eval_tofree;
|
||||
else
|
||||
vim_free(evalarg->eval_tofree);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -421,39 +422,39 @@ free_eval_tofree_later(evalarg_T *evalarg)
|
||||
void
|
||||
clear_evalarg(evalarg_T *evalarg, exarg_T *eap)
|
||||
{
|
||||
if (evalarg != NULL)
|
||||
if (evalarg == NULL)
|
||||
return;
|
||||
|
||||
garray_T *etga = &evalarg->eval_tofree_ga;
|
||||
|
||||
if (evalarg->eval_tofree != NULL || evalarg->eval_using_cmdline)
|
||||
{
|
||||
garray_T *etga = &evalarg->eval_tofree_ga;
|
||||
|
||||
if (evalarg->eval_tofree != NULL || evalarg->eval_using_cmdline)
|
||||
if (eap != NULL)
|
||||
{
|
||||
if (eap != NULL)
|
||||
{
|
||||
// We may need to keep the original command line, e.g. for
|
||||
// ":let" it has the variable names. But we may also need
|
||||
// the new one, "nextcmd" points into it. Keep both.
|
||||
vim_free(eap->cmdline_tofree);
|
||||
eap->cmdline_tofree = *eap->cmdlinep;
|
||||
// We may need to keep the original command line, e.g. for
|
||||
// ":let" it has the variable names. But we may also need
|
||||
// the new one, "nextcmd" points into it. Keep both.
|
||||
vim_free(eap->cmdline_tofree);
|
||||
eap->cmdline_tofree = *eap->cmdlinep;
|
||||
|
||||
if (evalarg->eval_using_cmdline && etga->ga_len > 0)
|
||||
{
|
||||
// "nextcmd" points into the last line in eval_tofree_ga,
|
||||
// need to keep it around.
|
||||
--etga->ga_len;
|
||||
*eap->cmdlinep = ((char_u **)etga->ga_data)[etga->ga_len];
|
||||
vim_free(evalarg->eval_tofree);
|
||||
}
|
||||
else
|
||||
*eap->cmdlinep = evalarg->eval_tofree;
|
||||
if (evalarg->eval_using_cmdline && etga->ga_len > 0)
|
||||
{
|
||||
// "nextcmd" points into the last line in eval_tofree_ga,
|
||||
// need to keep it around.
|
||||
--etga->ga_len;
|
||||
*eap->cmdlinep = ((char_u **)etga->ga_data)[etga->ga_len];
|
||||
vim_free(evalarg->eval_tofree);
|
||||
}
|
||||
else
|
||||
vim_free(evalarg->eval_tofree);
|
||||
evalarg->eval_tofree = NULL;
|
||||
*eap->cmdlinep = evalarg->eval_tofree;
|
||||
}
|
||||
|
||||
ga_clear_strings(etga);
|
||||
VIM_CLEAR(evalarg->eval_tofree_lambda);
|
||||
else
|
||||
vim_free(evalarg->eval_tofree);
|
||||
evalarg->eval_tofree = NULL;
|
||||
}
|
||||
|
||||
ga_clear_strings(etga);
|
||||
VIM_CLEAR(evalarg->eval_tofree_lambda);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3219,16 +3220,16 @@ eval_addblob(typval_T *tv1, typval_T *tv2)
|
||||
blob_T *b = blob_alloc();
|
||||
int i;
|
||||
|
||||
if (b != NULL)
|
||||
{
|
||||
for (i = 0; i < blob_len(b1); i++)
|
||||
ga_append(&b->bv_ga, blob_get(b1, i));
|
||||
for (i = 0; i < blob_len(b2); i++)
|
||||
ga_append(&b->bv_ga, blob_get(b2, i));
|
||||
if (b == NULL)
|
||||
return;
|
||||
|
||||
clear_tv(tv1);
|
||||
rettv_blob_set(tv1, b);
|
||||
}
|
||||
for (i = 0; i < blob_len(b1); i++)
|
||||
ga_append(&b->bv_ga, blob_get(b1, i));
|
||||
for (i = 0; i < blob_len(b2); i++)
|
||||
ga_append(&b->bv_ga, blob_get(b2, i));
|
||||
|
||||
clear_tv(tv1);
|
||||
rettv_blob_set(tv1, b);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4818,13 +4819,13 @@ f_slice(typval_T *argvars, typval_T *rettv)
|
||||
|| check_for_opt_number_arg(argvars, 2) == FAIL))
|
||||
return;
|
||||
|
||||
if (check_can_index(argvars, TRUE, FALSE) == OK)
|
||||
{
|
||||
copy_tv(argvars, rettv);
|
||||
eval_index_inner(rettv, TRUE, argvars + 1,
|
||||
argvars[2].v_type == VAR_UNKNOWN ? NULL : argvars + 2,
|
||||
TRUE, NULL, 0, FALSE);
|
||||
}
|
||||
if (check_can_index(argvars, TRUE, FALSE) != OK)
|
||||
return;
|
||||
|
||||
copy_tv(argvars, rettv);
|
||||
eval_index_inner(rettv, TRUE, argvars + 1,
|
||||
argvars[2].v_type == VAR_UNKNOWN ? NULL : argvars + 2,
|
||||
TRUE, NULL, 0, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5045,31 +5046,31 @@ partial_free(partial_T *pt)
|
||||
void
|
||||
partial_unref(partial_T *pt)
|
||||
{
|
||||
if (pt != NULL)
|
||||
if (pt == NULL)
|
||||
return;
|
||||
|
||||
int done = FALSE;
|
||||
|
||||
if (--pt->pt_refcount <= 0)
|
||||
partial_free(pt);
|
||||
|
||||
// If the reference count goes down to one, the funcstack may be the
|
||||
// only reference and can be freed if no other partials reference it.
|
||||
else if (pt->pt_refcount == 1)
|
||||
{
|
||||
int done = FALSE;
|
||||
// careful: if the funcstack is freed it may contain this partial
|
||||
// and it gets freed as well
|
||||
if (pt->pt_funcstack != NULL)
|
||||
done = funcstack_check_refcount(pt->pt_funcstack);
|
||||
|
||||
if (--pt->pt_refcount <= 0)
|
||||
partial_free(pt);
|
||||
|
||||
// If the reference count goes down to one, the funcstack may be the
|
||||
// only reference and can be freed if no other partials reference it.
|
||||
else if (pt->pt_refcount == 1)
|
||||
if (!done)
|
||||
{
|
||||
// careful: if the funcstack is freed it may contain this partial
|
||||
// and it gets freed as well
|
||||
if (pt->pt_funcstack != NULL)
|
||||
done = funcstack_check_refcount(pt->pt_funcstack);
|
||||
int depth;
|
||||
|
||||
if (!done)
|
||||
{
|
||||
int depth;
|
||||
|
||||
for (depth = 0; depth < MAX_LOOP_DEPTH; ++depth)
|
||||
if (pt->pt_loopvars[depth] != NULL
|
||||
&& loopvars_check_refcount(pt->pt_loopvars[depth]))
|
||||
for (depth = 0; depth < MAX_LOOP_DEPTH; ++depth)
|
||||
if (pt->pt_loopvars[depth] != NULL
|
||||
&& loopvars_check_refcount(pt->pt_loopvars[depth]))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7225,23 +7226,23 @@ last_set_msg(sctx_T script_ctx)
|
||||
{
|
||||
char_u *p;
|
||||
|
||||
if (script_ctx.sc_sid != 0)
|
||||
if (script_ctx.sc_sid == 0)
|
||||
return;
|
||||
|
||||
p = home_replace_save(NULL, get_scriptname(script_ctx.sc_sid));
|
||||
if (p == NULL)
|
||||
return;
|
||||
|
||||
verbose_enter();
|
||||
msg_puts(_("\n\tLast set from "));
|
||||
msg_puts((char *)p);
|
||||
if (script_ctx.sc_lnum > 0)
|
||||
{
|
||||
p = home_replace_save(NULL, get_scriptname(script_ctx.sc_sid));
|
||||
if (p != NULL)
|
||||
{
|
||||
verbose_enter();
|
||||
msg_puts(_("\n\tLast set from "));
|
||||
msg_puts((char *)p);
|
||||
if (script_ctx.sc_lnum > 0)
|
||||
{
|
||||
msg_puts(_(line_msg));
|
||||
msg_outnum((long)script_ctx.sc_lnum);
|
||||
}
|
||||
verbose_leave();
|
||||
vim_free(p);
|
||||
}
|
||||
msg_puts(_(line_msg));
|
||||
msg_outnum((long)script_ctx.sc_lnum);
|
||||
}
|
||||
verbose_leave();
|
||||
vim_free(p);
|
||||
}
|
||||
|
||||
#endif // FEAT_EVAL
|
||||
|
Reference in New Issue
Block a user