diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-07-13 21:28:03 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-07-13 21:28:03 +0200 |
commit | 3ac9c4701a5f1e39303ca2885956db92215966db (patch) | |
tree | 7387e0cc994b5fd24b9b77cd38ec17c3628dfadc | |
parent | 08f7a41b0a280e5901eb4ee4bbfe682113863492 (diff) | |
download | vim-git-3ac9c4701a5f1e39303ca2885956db92215966db.tar.gz |
patch 8.2.1203: unused assignments in expression evaluationv8.2.1203
Problem: Unused assignments in expression evaluation.
Solution: Move declarations and assignments to inner blocks where possible.
-rw-r--r-- | src/eval.c | 35 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 24 insertions, 13 deletions
diff --git a/src/eval.c b/src/eval.c index 065f7853f..14c2849e8 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2538,8 +2538,6 @@ eval_addlist(typval_T *tv1, typval_T *tv2) static int eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg) { - int evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE); - /* * Get the first variable. */ @@ -2551,6 +2549,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg) */ for (;;) { + int evaluate; int getnext; char_u *p; 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); if (op != '+' && op != '-' && !concat) break; + if (getnext) *arg = eval_next_line(evalarg); - + evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE); if ((op != '+' || (rettv->v_type != VAR_LIST && rettv->v_type != VAR_BLOB)) #ifdef FEAT_FLOAT @@ -2728,14 +2728,9 @@ eval6( evalarg_T *evalarg, int want_string) // after "." operator { - typval_T var2; - int op; - varnumber_T n1, n2; #ifdef FEAT_FLOAT - int use_float = FALSE; - float_T f1 = 0, f2 = 0; + int use_float = FALSE; #endif - int error = FALSE; /* * Get the first variable. @@ -2748,16 +2743,29 @@ eval6( */ for (;;) { - int evaluate = evalarg == NULL ? 0 - : (evalarg->eval_flags & EVAL_EVALUATE); - int getnext; + int evaluate; + 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); if (op != '*' && op != '/' && op != '%') break; + if (getnext) *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) { #ifdef FEAT_FLOAT @@ -2904,7 +2912,6 @@ eval7( evalarg_T *evalarg, int want_string) // after "." operator { - int flags = evalarg == NULL ? 0 : evalarg->eval_flags; int evaluate = evalarg != NULL && (evalarg->eval_flags & EVAL_EVALUATE); int len; @@ -3064,6 +3071,8 @@ eval7( ret = FAIL; else { + int flags = evalarg == NULL ? 0 : evalarg->eval_flags; + if (**arg == '(') // "name(..." recursive! ret = eval_func(arg, evalarg, s, len, rettv, flags, NULL); diff --git a/src/version.c b/src/version.c index ddc6f2e06..fa57356e3 100644 --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1203, +/**/ 1202, /**/ 1201, |