summaryrefslogtreecommitdiffstats
path: root/src/evalvars.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-12 21:36:03 +0100
committerBram Moolenaar <Bram@vim.org>2023-04-12 21:36:03 +0100
commit474891bc89e657100bd37c29129451a0e601879d (patch)
tree595227a90e441361c1f6f2102669873b24ed08cd /src/evalvars.c
parent5299c0933f942c61bfd48064c91365e518fa868c (diff)
patch 9.0.1447: condition is always truev9.0.1447
Problem: Condition is always true. Solution: Remove the useless condition. (closes #12253)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r--src/evalvars.c117
1 files changed, 54 insertions, 63 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index b123542872..b0df0a58b3 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -989,7 +989,6 @@ ex_let(exarg_T *eap)
char_u *arg = eap->arg;
char_u *expr = NULL;
typval_T rettv;
- int i;
int var_count = 0;
int semicolon = 0;
char_u op[4];
@@ -1067,8 +1066,10 @@ ex_let(exarg_T *eap)
list_vim_vars(&first);
}
set_nextcmd(eap, arg);
+ return;
}
- else if (expr[0] == '=' && expr[1] == '<' && expr[2] == '<')
+
+ if (expr[0] == '=' && expr[1] == '<' && expr[2] == '<')
{
list_T *l = NULL;
long cur_lnum = SOURCING_LNUM;
@@ -1096,77 +1097,67 @@ ex_let(exarg_T *eap)
}
clear_tv(&rettv);
}
+ return;
}
- else
- {
- evalarg_T evalarg;
- int len = 1;
- CLEAR_FIELD(rettv);
- i = FAIL;
- if (has_assign || concat)
- {
- int cur_lnum;
+ evalarg_T evalarg;
+ int len = 1;
- op[0] = '=';
- op[1] = NUL;
- if (*expr != '=')
- {
- if (vim9script && (flags & ASSIGN_NO_DECL) == 0)
- {
- // +=, /=, etc. require an existing variable
- semsg(_(e_cannot_use_operator_on_new_variable_str),
- eap->arg);
- }
- else if (vim_strchr((char_u *)"+-*/%.", *expr) != NULL)
- {
- op[0] = *expr; // +=, -=, *=, /=, %= or .=
- ++len;
- if (expr[0] == '.' && expr[1] == '.') // ..=
- {
- ++expr;
- ++len;
- }
- }
- expr += 2;
- }
- else
- ++expr;
+ CLEAR_FIELD(rettv);
- if (vim9script && !eap->skip && (!VIM_ISWHITE(*argend)
- || !IS_WHITE_OR_NUL(*expr)))
- {
- vim_strncpy(op, expr - len, len);
- semsg(_(e_white_space_required_before_and_after_str_at_str),
- op, argend);
- }
+ int cur_lnum;
- if (eap->skip)
- ++emsg_skip;
- fill_evalarg_from_eap(&evalarg, eap, eap->skip);
- expr = skipwhite_and_linebreak(expr, &evalarg);
- cur_lnum = SOURCING_LNUM;
- i = eval0(expr, &rettv, eap, &evalarg);
- if (eap->skip)
- --emsg_skip;
- clear_evalarg(&evalarg, eap);
-
- // Restore the line number so that any type error is given for the
- // declaration, not the expression.
- SOURCING_LNUM = cur_lnum;
- }
- if (eap->skip)
+ op[0] = '=';
+ op[1] = NUL;
+ if (*expr != '=')
+ {
+ if (vim9script && (flags & ASSIGN_NO_DECL) == 0)
{
- if (i != FAIL)
- clear_tv(&rettv);
+ // +=, /=, etc. require an existing variable
+ semsg(_(e_cannot_use_operator_on_new_variable_str), eap->arg);
}
- else if (i != FAIL)
+ else if (vim_strchr((char_u *)"+-*/%.", *expr) != NULL)
{
- (void)ex_let_vars(eap->arg, &rettv, FALSE, semicolon, var_count,
- flags, op);
- clear_tv(&rettv);
+ op[0] = *expr; // +=, -=, *=, /=, %= or .=
+ ++len;
+ if (expr[0] == '.' && expr[1] == '.') // ..=
+ {
+ ++expr;
+ ++len;
+ }
}
+ expr += 2;
}
+ else
+ ++expr;
+
+ if (vim9script && !eap->skip && (!VIM_ISWHITE(*argend)
+ || !IS_WHITE_OR_NUL(*expr)))
+ {
+ vim_strncpy(op, expr - len, len);
+ semsg(_(e_white_space_required_before_and_after_str_at_str),
+ op, argend);
+ }
+
+ if (eap->skip)
+ ++emsg_skip;
+ fill_evalarg_from_eap(&evalarg, eap, eap->skip);
+ expr = skipwhite_and_linebreak(expr, &evalarg);
+ cur_lnum = SOURCING_LNUM;
+ int eval_res = eval0(expr, &rettv, eap, &evalarg);
+ if (eap->skip)
+ --emsg_skip;
+ clear_evalarg(&evalarg, eap);
+
+ // Restore the line number so that any type error is given for the
+ // declaration, not the expression.
+ SOURCING_LNUM = cur_lnum;
+
+ if (!eap->skip && eval_res != FAIL)
+ (void)ex_let_vars(eap->arg, &rettv, FALSE, semicolon, var_count,
+ flags, op);
+ if (eval_res != FAIL)
+ clear_tv(&rettv);
}
/*