summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-04-04 14:44:18 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-04-04 14:44:18 +0200
commit3bf585ba04e7ff4a95f739e58503da7af3714bc7 (patch)
tree4491e9835a428d94bcb643e519f7e4ce0f47fc7c /src
parent1aefb0a54606071e6aeca89f0cfbfc55a2f356dc (diff)
downloadweechat-3bf585ba04e7ff4a95f739e58503da7af3714bc7.zip
core: evaluate left/right part of comparison after split on the comparison operator in ${if:xxx} (closes #1627)
To force evaluation of the expression before doing the comparison (less safe), the "${eval_cond:xxx}" can be used. With the old behavior we had: >> ${if:a==b} == [0] >> ${if:${raw:a==b}} == [0] >> ${if:${eval_cond:${raw:a==b}}} == [0] And with the new behavior, we have: >> ${if:a==b} == [0] >> ${if:${raw:a==b}} == [1] >> ${if:${eval_cond:${raw:a==b}}} == [0]
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-eval.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c
index 18f582398..8fc2b4754 100644
--- a/src/core/wee-eval.c
+++ b/src/core/wee-eval.c
@@ -666,7 +666,7 @@ char *
eval_string_if (const char *text, struct t_eval_context *eval_context)
{
const char *pos, *pos2;
- char *value, *condition, *tmp, *tmp2;
+ char *value, *condition, *tmp;
int rc;
value = NULL;
@@ -679,13 +679,10 @@ eval_string_if (const char *text, struct t_eval_context *eval_context)
strndup (text, pos - text) : strdup (text);
if (!condition)
return strdup ("");
- tmp = eval_replace_vars (condition, eval_context);
- tmp2 = eval_expression_condition ((tmp) ? tmp : "", eval_context);
- rc = eval_is_true (tmp2);
+ tmp = eval_expression_condition (condition, eval_context);
+ rc = eval_is_true (tmp);
if (tmp)
free (tmp);
- if (tmp2)
- free (tmp2);
if (rc)
{
/*