1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 00:33:13 +02:00

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]
This commit is contained in:
Sébastien Helleu
2021-04-04 14:44:18 +02:00
parent 1aefb0a546
commit 3bf585ba04
3 changed files with 37 additions and 6 deletions
+3 -6
View File
@@ -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)
{
/*