mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.1203: unused assignments in expression evaluation
Problem: Unused assignments in expression evaluation. Solution: Move declarations and assignments to inner blocks where possible.
This commit is contained in:
31
src/eval.c
31
src/eval.c
@@ -2538,8 +2538,6 @@ eval_addlist(typval_T *tv1, typval_T *tv2)
|
|||||||
static int
|
static int
|
||||||
eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||||
{
|
{
|
||||||
int evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the first variable.
|
* Get the first variable.
|
||||||
*/
|
*/
|
||||||
@@ -2551,6 +2549,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
*/
|
*/
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
int evaluate;
|
||||||
int getnext;
|
int getnext;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
int op;
|
int op;
|
||||||
@@ -2563,9 +2562,10 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
concat = op == '.' && (*(p + 1) == '.' || current_sctx.sc_version < 2);
|
concat = op == '.' && (*(p + 1) == '.' || current_sctx.sc_version < 2);
|
||||||
if (op != '+' && op != '-' && !concat)
|
if (op != '+' && op != '-' && !concat)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (getnext)
|
if (getnext)
|
||||||
*arg = eval_next_line(evalarg);
|
*arg = eval_next_line(evalarg);
|
||||||
|
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
|
||||||
if ((op != '+' || (rettv->v_type != VAR_LIST
|
if ((op != '+' || (rettv->v_type != VAR_LIST
|
||||||
&& rettv->v_type != VAR_BLOB))
|
&& rettv->v_type != VAR_BLOB))
|
||||||
#ifdef FEAT_FLOAT
|
#ifdef FEAT_FLOAT
|
||||||
@@ -2728,14 +2728,9 @@ eval6(
|
|||||||
evalarg_T *evalarg,
|
evalarg_T *evalarg,
|
||||||
int want_string) // after "." operator
|
int want_string) // after "." operator
|
||||||
{
|
{
|
||||||
typval_T var2;
|
|
||||||
int op;
|
|
||||||
varnumber_T n1, n2;
|
|
||||||
#ifdef FEAT_FLOAT
|
#ifdef FEAT_FLOAT
|
||||||
int use_float = FALSE;
|
int use_float = FALSE;
|
||||||
float_T f1 = 0, f2 = 0;
|
|
||||||
#endif
|
#endif
|
||||||
int error = FALSE;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the first variable.
|
* Get the first variable.
|
||||||
@@ -2748,16 +2743,29 @@ eval6(
|
|||||||
*/
|
*/
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int evaluate = evalarg == NULL ? 0
|
int evaluate;
|
||||||
: (evalarg->eval_flags & EVAL_EVALUATE);
|
|
||||||
int getnext;
|
int getnext;
|
||||||
|
typval_T var2;
|
||||||
|
int op;
|
||||||
|
varnumber_T n1, n2;
|
||||||
|
#ifdef FEAT_FLOAT
|
||||||
|
float_T f1, f2;
|
||||||
|
#endif
|
||||||
|
int error;
|
||||||
|
|
||||||
op = *eval_next_non_blank(*arg, evalarg, &getnext);
|
op = *eval_next_non_blank(*arg, evalarg, &getnext);
|
||||||
if (op != '*' && op != '/' && op != '%')
|
if (op != '*' && op != '/' && op != '%')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (getnext)
|
if (getnext)
|
||||||
*arg = eval_next_line(evalarg);
|
*arg = eval_next_line(evalarg);
|
||||||
|
|
||||||
|
#ifdef FEAT_FLOAT
|
||||||
|
f1 = 0;
|
||||||
|
f2 = 0;
|
||||||
|
#endif
|
||||||
|
error = FALSE;
|
||||||
|
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
|
||||||
if (evaluate)
|
if (evaluate)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_FLOAT
|
#ifdef FEAT_FLOAT
|
||||||
@@ -2904,7 +2912,6 @@ eval7(
|
|||||||
evalarg_T *evalarg,
|
evalarg_T *evalarg,
|
||||||
int want_string) // after "." operator
|
int want_string) // after "." operator
|
||||||
{
|
{
|
||||||
int flags = evalarg == NULL ? 0 : evalarg->eval_flags;
|
|
||||||
int evaluate = evalarg != NULL
|
int evaluate = evalarg != NULL
|
||||||
&& (evalarg->eval_flags & EVAL_EVALUATE);
|
&& (evalarg->eval_flags & EVAL_EVALUATE);
|
||||||
int len;
|
int len;
|
||||||
@@ -3064,6 +3071,8 @@ eval7(
|
|||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int flags = evalarg == NULL ? 0 : evalarg->eval_flags;
|
||||||
|
|
||||||
if (**arg == '(')
|
if (**arg == '(')
|
||||||
// "name(..." recursive!
|
// "name(..." recursive!
|
||||||
ret = eval_func(arg, evalarg, s, len, rettv, flags, NULL);
|
ret = eval_func(arg, evalarg, s, len, rettv, flags, NULL);
|
||||||
|
@@ -754,6 +754,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 */
|
||||||
|
/**/
|
||||||
|
1203,
|
||||||
/**/
|
/**/
|
||||||
1202,
|
1202,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user